In my particular upcoming problem I have a generator that makes a lot of noise which the player has to turn off as part of a puzzle.
I know that I have,
A clickable region
A one time animation toggle,
And SDL states (generator default = 1 on upon entry)
A steaming audio file (Ogg and Wav formats)
A sound region
A 3D sound emitter
Since there is no animation for the generator, it'll be skipped (animation isn't supported by the plugin yet but hard coding with Python is)
So I have been trying to read and understand the sample code from D'Lanor and Nadnerb for such things before jumping in.
D'Lanor suggested this way using a Lamp as an example to turn on and off
D'Lanor wrote: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
Nadnerb suggested the following ALC script for toggling audio
- Code: Select all
<some object>:
logic:
actions:
- type: responder
name: SoundResp (name or tag for modifier ref)
responder:
states:
- cmds:
- type: soundmsg
params:
receivers:
- 0011:<Name of emitter object>
cmds:
- play (start the sound)
- stop (stop the sound)
- setvolume (set the volume)
volume: 1 (volume only set if setvolume cmd is used)
waiton: -1
nextstate: 0
waittocmd: 0
curstate: 0
flags:
- detect_trigger
But this is all very confusing