Here's my Alcscript for the lever:
- Code: Select all
animations:
- name: LeverPull
autostart: 0
loop: 0
logic:
modifiers:
- tag: AutoClick
- cursor: poised
flags:
- localelement
activators:
- type: objectinvolume
remote: RgnLever02
triggers:
- any
conditions:
- type: activator
activators:
- type: picking
- type: objectinbox
satisfied: true
actions:
- type: responder
ref: Lever02Responder
- type: pythonfile
ref: $LeverPull
actions:
- type: pythonfile
tag: LeverPull
pythonfile:
file: puzzle
parameters:
parameters:
- type: activator
ref: logicmod:$AutoClick
- type: string
value: Lever02
- type: pythonfile
tag: DownRespond
pythonfile:
file: xAgeSDLBoolRespond
parameters:
- type: string
value: ColumDownToggle
- type: responder
ref: :ColumDownResponder
- type: responder
ref: :ColumDownResponder
- type: bool
value: false
- type: bool
value: true
- type: pythonfile
tag: UpRespond
pythonfile:
file: xAgeSDLBoolRespond
parameters:
- type: string
value: ColumUpToggle
- type: responder
ref: :ColumUpResponder
- type: responder
ref: :ColumUpResponder
- type: bool
value: false
- type: bool
value: true
- type: responder
name: Lever02Responder
responder:
states:
- cmds:
- type: oneshotmsg
params:
receivers:
- oneshotmod:Lever02OneShot
callbacks:
- marker: LeverBack
receiver:
respondermod:Lever02Responder
user: 0
event: 0
waiton: -1
- type: soundmsg
params:
receivers:
- 0011:LeverPullEmitter
cmds:
- play
- setvolume
volume: 0.8
waiton: 0
- type: animcmdmsg
params:
receivers:
- 006D:Lever02
animname: LeverPull
cmds:
- continue
waiton: -1
nextstate: 0
waittocmd:
- key: 0
msg: 0
curstate: 0
flags:
- detecttrigger
And for the colum:
- Code: Select all
Colum02:
animations:
- name: Colum02Move
autostart: 0
loop: 0
logic:
actions:
- type: responder
name: ColumUpResponder
responder:
states:
- cmds:
- type: animcmdmsg
params:
receivers:
- 006D:Colum02
animname: Colum02Move
cmds:
- setforewards
- continue
waiton: -1
- type: timercallbackmsg
params:
receivers:
- respondermod:ColumUpResponder
id: 0
time: 4.2
waiton: -1
- type: animcmdmsg
params:
receivers:
- 006D:Colum02
animname: Colum02Move
cmds:
- stop
waiton: 0
nextstate: 1
waittocmd:
- key: 0
msg: 0
curstate: 0
flags:
- detecttrigger
- type: responder
name: ColumDownResponder
responder:
states:
- cmds:
- type: timercallbackmsg
params:
receivers:
- respondermod:ColumDownResponder
id: 0
time: 2
waiton: -1
- type: animcmdmsg
params:
receivers:
- 006D:Colum02
animname: Colum02Move
cmds:
- setbackwards
- continue
waiton: 0
nextstate: 0
waittocmd:
- key: 0
msg: 0
curstate: 1
flags:
- detecttrigger
and here's the python (extract):
- Code: Select all
def OnNotify(self, state, id, events):
if (state):
global butName
butName = buttonName.value
print ' button clicked!: '+butName
if butName=='Lever02':
colum=PtFindSceneobject('Colum02',AgeName)
colPos=colum.position()
colZ=colPos.getZ()
print 'Colum position is: '+str(colZ)
ageSDL['ColumPosition']=(colZ,)
count = ageSDL['LeverPullCount'][0]
print 'Count = '+str(count)
if count<5:
ageSDL['LeverPullCount']=(count+1,)
PtAtTimeCallback(self.key, 3, 4)
elif count==5:
ageSDL['LeverPullCount']=(0,)
PtAtTimeCallback(self.key, 3, 5)
def OnTimer(self,id):
if id==4:
currentStste=ageSDL['ColumUpToggle'][0]
if currentStste==0:
ageSDL['ColumUpToggle'] = (1,)
if currentStste==1:
ageSDL['ColumUpToggle']=(0,)
if id==5:
currentStste=ageSDL['ColumDownToggle'][0]
if currentStste==0:
ageSDL['ColumDownToggle'] = (1,)
if currentStste==1:
ageSDL['ColumDownToggle']=(0,)
As I say , this works to a point. What it doesn't do is keep track of the colum position between visits. I've tried saving the value and warping to the saved position on link in using python. This doesn't work, I guess this instruction is overridden by the anim messages in the alcscript..?
So my questions are these:
1. Is there a more elegant way of firing the 'up' and 'down' responders?
2. Is there a way of keeping track of an anim that has only played part way through? I seem to recall reading a topic where chopping an anim with loopstart and loopend commands was discussed, but I can't find it now I need it..
3. Other than using the Quickscript method, how do I go about disabling the clickable while the colum is moving?
Grateful for any assistance s