ZansoHel Posted October 24, 2012 Share Posted October 24, 2012 Hey! I wanted to make a script for "floating" rock (slow up and down movement mostly). However, it loops for certain amount of times (see "number" in script) and won't reset when the trigger is re-entered. My idea was to make it loop infinite times or atleast (100000 times) everytime you enter the trigger. Anyone got some great ideas how to make it happen? :) Script Scriptname RockFloatScript extends ObjectReference ObjectReference property Rock AutoInt loop = 0 Event OnTriggerEnter(ObjectReference ActionRef) If ActionRef as Actor == Game.GetPlayer() Actor ActorRef = ActionRef as Actor While(loop < "number") Rock.TranslateTo(-465.48740, 330.75350, 665.0, -35.1780, -31.5284, -41.5715, 1.5, 7.0) Utility.Wait(5.2) Rock.TranslateTo(-465.48740, 330.75350, 603.67590, -35.1780, -31.5284, -33.5715, 1.5, 7.0) Utility.Wait(5.2) loop += 1 EndWhile EndIFEndEvent Link to comment Share on other sites More sharing options...
steve40 Posted October 25, 2012 Share Posted October 25, 2012 (edited) This script will activate only once and the rock will float forever (infinite loop). Note that you can't call translate functions on the rock if it's 3D isn't loaded (eg. after the cell unloads), it will spam the Papyrus log with errors, with no way of switching it off. I've added a test to help minimize this, but you might still find that it throws errors into the log from time to time. Also, this loop will keep running even when the cell had unloaded. Need to be careful with scripts like this. A script like this should never be installed as a loose file, make sure to put it in a bsa file or it could cause massive log spam if the user deactivates the esp without deleting the script. Scriptname RockFloatScript extends ObjectReference ObjectReference property Rock Auto AUTO STATE WAITING Event OnTriggerEnter(ObjectReference ActionRef) If ActionRef as Actor == Game.GetPlayer() GoToState("DONE") ; Actor ActorRef = ActionRef as Actor ; (not required unless you want to call functions on the actor who entered the trigger) bool bLoop = True While(bLoop) If Rock.Is3DLoaded() && Rock.GetParentCell() != None ; we can't call translate functions on unloaded objects, it will spam the error log Rock.TranslateTo(-465.48740, 330.75350, 665.0, -35.1780, -31.5284, -41.5715, 1.5, 7.0) EndIf Utility.Wait(5.2) If Rock.Is3DLoaded() && Rock.GetParentCell() != None ; we can't call translate functions on unloaded objects, it will spam the error log Rock.TranslateTo(-465.48740, 330.75350, 603.67590, -35.1780, -31.5284, -33.5715, 1.5, 7.0) EndIf Utility.Wait(5.2) EndWhile EndIF EndEvent ENDSTATE STATE DONE ; do nothing ENDSTATE Edited October 25, 2012 by steve40 Link to comment Share on other sites More sharing options...
ZansoHel Posted October 25, 2012 Author Share Posted October 25, 2012 Script compilation succeeded, but the rock doesn't move in the game. Any ideas why is that? Link to comment Share on other sites More sharing options...
ZansoHel Posted October 25, 2012 Author Share Posted October 25, 2012 It is alive! I don't actually know what was wrong... maybe a typo (by me :P )? But when I switched from my laptop to another computer and placed the script again, it worked. Thanks a lot once more! You are superb! :) Link to comment Share on other sites More sharing options...
Recommended Posts