Tuesday, October 25, 2011

Pingus script to play extra levels

Pingus is a nice Lemmings clone. Many of the levels are loadable only by the level editor or command line. You can also create custom Levelsets, but whichever method you use, they are all somewhat cumbersome.

I found a nice bash script here that loads individual levels and used it as a basis to create my own with some improvements. The new script gives you the option to open Pingus normally or select an individual level.

1. Change the PINGUS_DIR path to your pingus binary

2. Edit the Pingus command line parameters a few lines down (/pingus $f -g 1280x720 -f) if you want to change screen dimensions, etc

#!/bin/bash

#####################
# Pingus launcher #
#####################


# Pingus directory
PINGUS_DIR=~/pingus-0.7.4

# How do you wan to run Pingus
function runPingus {
  cd $PINGUS_DIR
  ./pingus $f -R 1280x720 -f
}

# Pingus level directory
PINGUS_LVL_DIR=$PINGUS_DIR/data/levels

function doExit {
  # if exit code equals 1, dialog was cancelled, exit
  if [[ $? == 1 ]]
  then
    exit
  fi
}

# show zenity menu for selecting how to start Pingus
ans=$(zenity --list --text "Pingus" --radiolist --column "" --column "" --hide-header TRUE "Start Pingus normally" FALSE "Select individual level")
# run doExit function to test if menu was cancelled
doExit

# if individual level was selected...
if [[ $ans == "Select individual level" ]]
then
  cd $PINGUS_LVL_DIR
  exec >/dev/null 2>&1
  f=1
  while [ "$f" != "" ]
  do
    # prompt for level select
    f="$(zenity --title="Last Level: $(cat ~/.pingus.last)" --file-selection)"
    [ "$f" != "" ] && echo $(basename $f) > ~/.pingus.last
    # check to see if dialog was cancelled
    doExit
    # change to Pingus dir and run
    runPingus
    cd $(dirname $f)
  done
else
  # if starting Pingus normally, just run it
  runPingus
fi

No comments:

Post a Comment