I did not have much time yesterday, but I will pick up where I left.
The conditional object should at least contain a lamp. I am not sure if we can combine objects to produce a full fetched conditional lightbulb. Perhaps object groups? Anyway, for now it will be just one lamp object called
Lamp01 which has the following Alcscript attached.
- Code: Select all
Lamp01:
quickscript:
sdl:
type: "boolshowhide"
Be sure to turn on your
AgeSDLHook in the script for your
Book (which you'll find in the Text Editor window).
- Code: Select all
config:
agesdlhook: True
Then create your SDL file:
- Code: Select all
#==============================================================
# READ: When modifying an SDL record, do *not* modify the
# existing record. You must copy and paste a new version
# below the current one and make your changes there.
#==============================================================
#
# State Description Language for yourage
STATEDESC yourage
{
VERSION 1
VAR BOOL Lamp01Vis[1] DEFAULT=0 DEFAULTOPTION=VAULT
}
The default is 0 which means the lamp will be initially off.
Next you have to make a clickable button, for example
LightButton01 which activates the Python file
LightButton.py. I believe clickables are documented for the new PyPRP so I will not repeat it here.
Finally make your Python file
LightButton.py. The basic Python code looks like this:
- Code: Select all
from Plasma import *
from PlasmaTypes import *
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')
class LightButton(ptModifier,):
def __init__(self):
ptModifier.__init__(self)
self.version = 'your version here'
def OnNotify(self, state, id, events):
if ((id == actClickableObject.id) and state):
if (not PtWasLocallyNotified(self.key)):
return
if (ObjectMsg.value == 'LightButton01'):
ageSDL = PtGetAgeSDL()
LampOn = ageSDL['Lamp01Vis'][0]
if LampOn:
ageSDL['Lamp01Vis'] = (0,) #switch lamp off
else:
ageSDL['Lamp01Vis'] = (1,) #switch lamp on