JetSteele Posted August 22, 2014 Share Posted August 22, 2014 Hi, I am using the DweBREntrance01. I duplicated it and re-wrote the script that would allow it to go both ways, open the staircase when the switch is clicked and close it when pushed again. This is my script: import game import debug import utility bool property isOpen = false auto Conditional {set to true to start open} bool property isClose = true auto Conditional {set to true to start closed} bool property isAnimating = false auto Hidden {is the activator currently animating from one state to another?} string property openAnim = "Down" auto Hidden {animation to play when opening} string property closeAnim = "Up" auto Hidden {animation to play when closing} string property openEvent = "TransDown" auto Hidden {open event name - waits for this event before considering itself "open"} string property closeEvent = "TransUp" auto Hidden {close event name - waits for this event before considering itself "closed"} int myState = 1 ; true when static or animating ; 0 == open or opening ; 1 == closed or closing EVENT OnLoad() if (isOpen) myState = 0 endif if (isClose) myState = 1 endif endEVENT auto STATE waiting ; waiting to be activated EVENT onActivate (objectReference triggerRef) ; switch open state when activated if (isClose) SetOpen(!isOpen) endIf if (isOpen) SetClose(!isClose) endIf endEVENT endState STATE busy ; This is the state when I'm busy animating EVENT onActivate (objectReference triggerRef) trace (self + " Busy") endEVENT endSTATE function SetOpen(bool abOpen = true) ; if busy, wait to finish while getState() == "busy" wait(1) endWhile ; open isAnimating = true if !isOpen gotoState ("busy") trace(self + " Opening") playAnimationandWait(openAnim, openEvent) ; Animate Open endif trace(self + " Opened") isOpen = true gotoState("waiting") isAnimating = false endFunction function SetClose(bool abClose = true) ; if busy, wait to finish while getState() == "busy" wait(1) endWhile ; close isAnimating = true if !isClose gotoState ("busy") trace(self + " Closing") playAnimationandWait(closeAnim, closeEvent) ; Animate Close endif trace(self + " Closed") isClose = true gotoState("waiting") isAnimating = false endFunction The stairs open but when I push the switch again they don't close. Just a little background on what I'm doing with the stairs. I have this switch that opens and closes the stairs then I have 4 other switches that when pushed change what activates and what de-activates. So one switch changes the room to an alchemy lab, another to a smithing forge, a third one to an enchanting room and a final one to a weaponry room. However I want that the room only changes when the stairs are closed. So its sort of like a changing room, everytime the door closes another room is behind the door. Except the changes are controlled by leavers. I would appreciate it if someone can help point me in the right direction on where I'm going wrong, any help would be greatly appreciated. Sorry for the wall of text. Link to comment Share on other sites More sharing options...
Recommended Posts