1mike44 Posted July 15, 2012 Share Posted July 15, 2012 I have the following script attached to a lever. In my room a have a square of spikes that blockade the player off when raised. In the middle of the spikes is the lever, and it's supposed to make the spikes go up when activated, wait a few seconds then make them go back down. When I hit the switch I get the debugging messages I set up and the lever animations work but the spikes have no animation. One more thing, the spikes are all organized in a FormList, and there are 69 of them in the list. Scriptname SpikeLeverScript extends ObjectReference FormList Property Spikes Auto string On = "FullPull" string Off = "FullPush" bool Able = true Int iIndex ObjectReference Reference function SetState() OpenGate() PlayAnimation(On) endfunction Event OnLoad() SetState() endEvent function OpenGate() Debug.MessageBox("Opening") iIndex = -1 Debug.Notification(iIndex) While(iIndex < 70) iIndex = iIndex + 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("open") Debug.Notification("Hello, world!") EndWhile endfunction function CloseGate() iIndex = -1 Debug.Notification(iIndex) While(iIndex < 70) iIndex = iIndex + 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("close") Debug.Notification("Hello, world!") EndWhile endfunction Auto State Inactive Event OnActivate(ObjectReference akActivateRef) GoToState("Active") PlayAnimation(Off) if(Able == true) CloseGate() Utility.Wait(15) OpenGate() endif Debug.MessageBox("Resetting") Able = false Utility.Wait(30) Able = true PlayAnimation(On) Utility.Wait(1) GoToState("Inactive") EndEvent EndState State Active EndState Any idea what is going wrong? Link to comment Share on other sites More sharing options...
1mike44 Posted July 16, 2012 Author Share Posted July 16, 2012 bump! Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 16, 2012 Share Posted July 16, 2012 Can you please tell which spikes you are using? Also, I think there's a problem with the states in your script. It will begin with the Inactive-state, then jump to the Active-state and will never leave it again. Link to comment Share on other sites More sharing options...
1mike44 Posted July 16, 2012 Author Share Posted July 16, 2012 (edited) They are called PortGatePoleDwemer (00018425) Edited July 16, 2012 by 1mike44 Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 16, 2012 Share Posted July 16, 2012 I didn't test with a formlist, only with a single spike. It should do what you described: When the lever gets pulled, the spikes go up, after a few seconds the spikes lower down and the lever reverts. Scriptname SpikeLeverScript extends ObjectReference FormList Property Spikes Auto string On = "FullPull" string Off = "FullPush" bool Able = true Int iIndex ObjectReference Reference function SetState() OpenGate() PlayAnimation(On) endfunction function OpenGate() Debug.MessageBox("Opening") iIndex = -1 Debug.Notification(iIndex) While(iIndex < 70) iIndex = iIndex + 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("open") Debug.Notification("Hello, world!") EndWhile endfunction function CloseGate() iIndex = -1 Debug.Notification(iIndex) While(iIndex < 70) iIndex = iIndex + 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("close") Debug.Notification("Hello, world!") EndWhile endfunction Event OnLoad() SetState() endEvent Event OnActivate(ObjectReference akActivateRef) if (able == true) able = false PlayAnimation(Off) CloseGate() Utility.Wait(15) OpenGate() PlayAnimation(on) able = true endif EndEvent Link to comment Share on other sites More sharing options...
1mike44 Posted July 16, 2012 Author Share Posted July 16, 2012 Still not working :(If this helps, when the game starts I get the message box saying "opening", then a notification saying "-1", and the hello world notification once. When i proceed to the area with the spikes all the spikes are still up. When I pull the lever I get the message box, and the "-1" notification and the "hello world" notification once again. After a while I get the message box again, and both notifications and the lever returns to it's "ON" position. So it seems to me like the error must be somewhere in my while statement for the FormsList, but I cannot figure out what is wrong. Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 17, 2012 Share Posted July 17, 2012 Try this, don't forget to fill the property. Scriptname SpikeLeverScript extends ObjectReference FormList Property Spikes Auto string On = "FullPull" string Off = "FullPush" bool Able = true Int iIndex ObjectReference Reference function SetState() OpenGate() PlayAnimation(On) endfunction function OpenGate() Debug.MessageBox("Opening") iIndex = Spikes.getsize() Debug.Notification(iIndex) While(iIndex > 0) iIndex -= 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("open") Debug.Notification("Hello, world!") EndWhile endfunction function CloseGate() iIndex =Spikes.getsize() Debug.Notification(iIndex) While(iIndex > 0) iIndex -= 1 Reference = Spikes.GetAt(iIndex) as ObjectReference Reference.PlayAnimation("close") Debug.Notification("Hello, world!") EndWhile endfunction Event OnLoad() SetState() endEvent Event OnActivate(ObjectReference akActivateRef) if (able == true) able = false PlayAnimation(Off) CloseGate() Utility.Wait(15) OpenGate() PlayAnimation(on) able = true endif EndEvent Link to comment Share on other sites More sharing options...
1mike44 Posted July 17, 2012 Author Share Posted July 17, 2012 Still not working properly, but I think it's an animation thing. When the game starts the poles go partway down then go back up, and the animations wont play again when pull the lever. If I use the sae (Send Animation Event) command in the console i can get individual poles to go down or up. Link to comment Share on other sites More sharing options...
Ghaunadaur Posted July 18, 2012 Share Posted July 18, 2012 (edited) I tested the script with a formlist of 4 spikes and it worked as it should. nothing wrong with the animation. Maybe test from another save or coc to the cell. Edited July 18, 2012 by Ghaunadaur Link to comment Share on other sites More sharing options...
Recommended Posts