jamesmorlock Posted October 25, 2009 Share Posted October 25, 2009 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 1else playgroup backward 1 LOGentrance01.playgroup backward 1 set open to 0endifend 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 More sharing options...
welwork Posted October 25, 2009 Share Posted October 25, 2009 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 StateFloat Timer begin onActivate if State == 0if qv.open == 0set qv.open to 1set State to 1elseset qv.open to 0Set State to 2endifendifend Begin GameModeif State == 0Returnendif if State == 1playgroup forward 1LOGentrance01.playgroup forward 1set State to 3Set Timer to 2endif if State == 2playgroup backward 1LOGentrance01.playgroup backward 1set State to 3Set Timer to 2endif if State == 3Set Timer to Timer - GetSecondsPassedif timer <= 0set State to 0endifend Link to comment Share on other sites More sharing options...
Recommended Posts