Renpy

From OLPC
Jump to: navigation, search

Introduction

Renpy is a fast rapid development role play engine that allows the creation of interactive experiences quite quickly and easily. It's based on Pygame however there are a few issues to be overcome to make it work on the XO properly. This is being used in OLPC Afghanistan to create interactive roleplay / avatar based learning experiences.

There are a few gotchas in this. I hope I have them all documented here. Also when renpy makes distributions it creates it's own Python bundle, so rather than using the OLPCGame wrapper for now this is using normal sugar coating.

Getting Started

Download the normal Renpy from www.renpy.org . The program has excellent documentation and tutorials. Go through making the roleplay as normal, and click build distributions.

  • Make sure that you do not select full screen by default. This has a really weird bug that when running as the sugar temporary user it will get the screen position completely wrong.
  • Recommended to make the game at 800x600.

Adjustments for use on the XO

  • You need to make sure that you have the latest video driver installed on the XO so that we can change the resolution - see [[1]]
  • Sugar coat it using [[2]] - if you are doing this on a normal Linux (e.g. Ubuntu) distro make sure that you have installed the sugar emulator package or at least have a folder /usr/share/activities
    • When running this enter any command you like - it doesn't matter, we will have to change this later.
    • Use a name without spaces
  • This should create /usr/share/activities/NameYouEntered.activity , under that there is bin/sugarNameYouEntered which is a shell script. Open it in a text editor and change the lines as commented below:
#!/bin/sh
while [ -n "$2" ] ; do
     case "$1" in
         -b | --bundle-id)     export SUGAR_BUNDLE_ID="$2" ;;
         -a | --activity-id)   export SUGAR_ACTIVITY_ID="$2" ;;
         -o | --object-id)     export SUGAR_OBJECT_ID="$2" ;;
         -u | --uri)           export SUGAR_URI="$2" ;;
         *) echo unknown argument $1 $2 ;;
     esac
     shift;shift
done
export LD_PRELOAD="$SUGAR_BUNDLE_PATH/lib/libsugarize.so"
export NET_WM_NAME="TheInterview"

#Add this line as the renpy script will need this variable
export SUGAR_BUNDLE_PATH

#change this from the command that you entered
exec $SUGAR_BUNDLE_PATH/interview3.sh
  • Open up the renpy generated .sh script that comes in it's folder and make the following changes:
#!/bin/sh

# We assume Darwin means Mac OS X. Sorry, Darwin guys.
if [ "x`uname -s`" = "xDarwin" ]; then
    dir=`dirname "$0"`
    dir=`cd "$dir"; pwd`
    base=`basename "$0"`

    export RENPY_LAUNCHER_DIR="$dir"

    if [ -e "$dir/${base%.sh}.app/Contents/MacOS/${base%.sh}" ] ; then
        launcher="$dir/${base%.sh}.app/Contents/MacOS/${base%.sh}"
    else
        launcher="$dir/${base%.sh}.app/Contents/MacOS/Ren'Py Launcher"
    fi

    exec "$launcher" "${0%.sh}.py" "$@"
fi

# This section is needed to change the screen resolution and remembering
# that we are now running as the temporary user created by rainbow

rm $HOME/.xsession

if [ ! -e $HOME/.xsession ]; then
        echo "xrandr --newmode 800x600 0 800 0 0 0 600 0 0 0" >> $HOME/.xsession
        echo "xrandr --addmode default 800x600" >> $HOME/.xsession
        echo "xrandr --newmode 1200x900 0 1200 0 0 0 900 0 0 0" >> $HOME/.xsess$
        echo "xrandr --addmode default 1200x900" >> $HOME/.xsession
fi

#changes the screen res
xrandr --output default --mode 800x600
"$SUGAR_BUNDLE_PATH/lib/python" "-OO" "$SUGAR_BUNDLE_PATH/interview3.py" "$@"

#puts it back when we are done
xrandr --output default --mode 1200x900
  • Now you can turn this into a .xo file, copy it into an activities folder, etc. should be good to go!

Localization / About RTL

Normally one would argue that roleplays should be available in all languages no matter what the interface is running - e.g. do an interview sim in your language and then in English. You can do this with renpy by defining named points and separating the script out according to language effectively.

Was in contact with the developers and testing this out for Afghanistan - is only in the recent version - author recently added free bidi. Will add more info here as soon as it's tested.