Creating a Python File
If you need to add game logic beyond what can be accomplished via AlcScript, you will need to create a Python file. But you'll first need to create a Python PAK file. Here's how to do it all.
- Start up PlasmaShop
- Choose File -> New -> Python PAK. This file will hold your age's compiled Python files. When the file browser appears, choose the Python subdirectory of your URU installation and then enter the name of your Python PAK file. The convention is to name it after your age, e.g. Pahts.pak
- PlasmaShop also will display an empty dialog window which shows the contents of the PAK file - which is currently nothing. Leave this window here for the time being.
- Choose File -> New -> Python File. This will create a stub Python file containing a class named myResponder. Change the name of the class to something related to its purpose. For example, if this was for a button in your age named MyAge, rename the class to MyAgeButton
- By default, PlasmaShop will create a subclass of ptResponder. Chances are that you actually need a subclass of ptModifier. So, to change this, replace the ptResponder in the parenthesis after the class name with ptModifier , and replace the ptResponder.__init__(self) with ptModifier.__init__(self).
- Before you do anything else, save this file. Choose File -> Save, then browse to the Python/src subdirectory of your URU installation and give it the same name as your class, e.g. MyAgeButton.py
- Now you can add bits of Python code to the appropriate place in your new Python file.
- Once you've finished, save the file again.
- Add the Python file to your PAK file. To do this, locate your PAK dialog in PlasmaShop and click the "Add Files..." button. Then browse to your Python file and select it. PlasmaShop will then compile your file and add the file to your PAK file, if there were no errors. If it does report an error on a specific line, locate that line in your Python file and make the appropriate correction.
Note: To turn on line numbers in PlasmaShop, go to File -> Options. Click on the Editor tab, then click the "Line Numbers" checkbox.