Creating a Simple Control Panel
xSimplePanel is a Python template for making control panels. To be more precise, for the type of panel where the player has to push all buttons in a predefined sequence in order to unlock something.
Each button that is pushed down becomes unclickable (the Python file takes care of that) so it can only be clicked once per attempt.
When the player has pushed down all the buttons they reset to their initial positions and become clickable again. If the combination was correct the lock will open at this point. If not, the player can give it another try.
For this type of puzzle the length of the solution code should match the number of buttons.
Global Module xSimplePanel
So is this yet another package you need to install? Probably not. Chances are that you already have it since it is included in Offline KI 3.5 or later. For people who do not have the Offline KI installed a global addon pak containing xSimplePanel can be downloaded from here.
Age writers, please DO NOT add xSimplePanel.py or the GlobalAddon.pak file to your age distribution! You can provide links to Offline KI/Drizzle or the download address above, so that users of your age may obtain the module from there.
The template can handle up to 9 buttons. It requires the following components:
- An activator for each button
- A "down" responder for each button
- A single "up" or reset responder which handles ALL buttons at once
- A solution string consisting of numbers
- An SDL variable of type INT to track which buttons are pushed
- An SDL variable of type BOOL to toggle when the puzzle is solved
Details for creating these components will follow later. For now we concentrate on the Python file mod itself.
AlcScript: xSimplePanel Python File Mod
In Blender you can use this AlcScript for the python file mod which activates the template. For 3DS Max Andy Legate will create a tutorial here.
<object name>: logic: actions: - type: pythonfile name: <pythonfile mod name> pythonfile: file: xSimplePanel parameters: - type: activator ref: logicmod:<modifier button 1 name> - type: activator ref: logicmod:<modifier button 2 name> - type: activator ref: logicmod:<modifier button 3 name> - type: activator ref: logicmod:<modifier button 4 name> - type: activator ref: logicmod:<modifier button 5 name> - type: activator ref: logicmod:<modifier button 6 name> - type: skip - type: skip - type: skip - type: responder ref: :<responder button 1 name> - type: responder ref: :<responder button 2 name> - type: responder ref: :<responder button 3 name> - type: responder ref: :<responder button 4 name> - type: responder ref: :<responder button 5 name> - type: responder ref: :<responder button 6 name> - type: skip - type: skip - type: skip - type: responder ref: :<responder to reset all buttons> - type: string value: 123456 - type: string value: <name of INT SDL to track buttons pushed> - type: string value: <name of BOOL SDL to toggle when solved> #Replay if solved? - type: bool value: true #Click time-out - type: float value: 1.2 #Init SDL on first update? - type: bool value: false
If you are not using the maximum of 9 buttons, for example 6, you can simply leave activators and responders 7, 8 and 9 unassigned. The Python code will detect unassigned references and use only the valid ones. In Blender you can do this by skipping them as shown in the AlcScript example.
The last 3 parameters are optional. Python gives them defaults when they are unassigned. The values in this script are in fact the defaults so using these exact settings would have the same result as removing them from the script entirely.
Replay if solved? - By default this is a replayable puzzle. However, if you set this parameter to false the puzzle can be played only until it is solved and then it remains "stuck" into the solved position.
Click time-out - This comes in handy if (like me) you are lazy and use the same sound emitter for all buttons. Though Uru is capable of playing the same sound file twice simultaneously, it can not do so when the sound comes from the same emitter. So if you are clicking buttons fast after one another you won't always hear the click sound. Setting a time-out value fixes this.
Init SDL on first update? - You can use this parameter if your prp file is paged in later. If for example you are building a Pahts shell you need to set this to true.
Note that the response to the SDL that is toggled when the puzzle is solved is not handled by this template. It is recommended to use Cyan's global file xAgeSDLBoolRespond to handle that. See the example below (to be moved to its own page in the future).
AlcScript: xAgeSDLBoolRespond Python File Mod
<object name>: logic: actions: - type: pythonfile tag: BoolRespond pythonfile: file: xAgeSDLBoolRespond parameters: - type: string value: <name of BOOL SDL to toggle when solved> - type: responder ref: :<responder to run if bool true> - type: responder ref: :<responder to run if bool false> #F-Forward on VM notify - type: bool value: false #F-Forward on Init - type: bool value: true
F-Forward is fast forward mode. In this mode all animations and sounds are skipped unless they are looped. In short: It skips to whatever situation you get after your responder has run. I usually set F-Forward to false on VM notify. VM notify happens when a server admin changes an SDL state through the VaultManager or another administration tool. Admins don't do this very often so we should let them have some fun and show all the bells and whistles, right?
On Init is when a player links in. You probably don't want your doors (or whatever) slamming each time a player enters the age so set F-Forward to true here.