Jump to content

Help with a gate open & close script


jamesmorlock

Recommended Posts

I'm trying to write a script for a portcullis to open and close on activation by a script, but it's really stumping me. This script is on the switch.

 

Here's my code:

 

scn LOGgateControl01

 

short open

 

begin onActivate

 

if open == 0

playgroup forward 1

LOGentrance01.playgroup forward 1

set open to 1

else

playgroup backward 1

LOGentrance01.playgroup backward 1

set open to 0

endif

end

 

The gate raises just fine, but when I lower it, it repeats the lowering animation in an infinite loop.

I'm not seeing the logic error here, but I'm sure it's something stupidly simple.

Thanks.

Link to comment
Share on other sites

Try using Open as a quest variable, as this won't be retained if you leave the cell.

Also Use GameMode to do the playgroup, as the OnActivate block is triggered more than once by the same activation.

 

Something like..

 

scn LOGgateControl01

 

short State

Float Timer

 

begin onActivate

 

if State == 0

if qv.open == 0

set qv.open to 1

set State to 1

else

set qv.open to 0

Set State to 2

endif

endif

end

 

Begin GameMode

if State == 0

Return

endif

 

if State == 1

playgroup forward 1

LOGentrance01.playgroup forward 1

set State to 3

Set Timer to 2

endif

 

if State == 2

playgroup backward 1

LOGentrance01.playgroup backward 1

set State to 3

Set Timer to 2

endif

 

if State == 3

Set Timer to Timer - GetSecondsPassed

if timer <= 0

set State to 0

endif

end

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...