Dufftacular Posted December 17, 2021 Share Posted December 17, 2021 Hello, Is it possible to make a script for the purpose of having 2 static objects switch spots on a timer that loops? Example, _ At Start_Static Object 1 Static Object 2 (after 5 seconds) Static Object 2 Static Object 1 (after 5 seconds) Back to start to repeat. I'm not good at scripting so I need all the help I can get. Thanks in advance! Link to comment Share on other sites More sharing options...
SKKmods Posted December 17, 2021 Share Posted December 17, 2021 As static objects can not have scripts attached you would need to place a third object like an invisible activator to attach a script to, something like this: Scriptname MyObjectSwitchScript extends ObjectReference ObjectReference Property MySlaveObjectA Auto Const Mandatory ObjectReference Property MySlaveObjectB Auto Const Mandatory int iTimer = 10 Event OnLoad() MySlaveObjectA.Enable() MySlaveObjectB.Disable() Self.StartTimer(5.0, iTimer) EndEvent Event OnTimer(int aiTimerID) If (MySlaveObjectA.IsEnabled() == True) MySlaveObjectA.Disable() MySlaveObjectB.Enable() Else MySlaveObjectA.Enable() MySlaveObjectB.Disable() EndIf Self.StartTimer(5.0, iTimer) EndEvent Event OnUnload() Self.CancelTimer(iTimer) MySlaveObjectA.Disable() MySlaveObjectB.Disable() EndEvent Many different ways to do this tho. Link to comment Share on other sites More sharing options...
Dufftacular Posted December 17, 2021 Author Share Posted December 17, 2021 As static objects can not have scripts attached you would need to place a third object like an invisible activator to attach a script to, something like this: Scriptname MyObjectSwitchScript extends ObjectReference ObjectReference Property MySlaveObjectA Auto Const Mandatory ObjectReference Property MySlaveObjectB Auto Const Mandatory int iTimer = 10 Event OnLoad() MySlaveObjectA.Enable() MySlaveObjectB.Disable() Self.StartTimer(5.0, iTimer) EndEvent Event OnTimer(int aiTimerID) If (MySlaveObjectA.IsEnabled() == True) MySlaveObjectA.Disable() MySlaveObjectB.Enable() Else MySlaveObjectA.Enable() MySlaveObjectB.Disable() EndIf Self.StartTimer(5.0, iTimer) EndEvent Event OnUnload() Self.CancelTimer(iTimer) MySlaveObjectA.Disable() MySlaveObjectB.Disable() EndEvent Many different ways to do this tho.Hmm, I tried this out, I used a DefaultActivator and attached the script to that and filled the properties with the 2 objects but when I load in game I only see one object and it doesn't appear to be working. Am I doing something incorrectly? Link to comment Share on other sites More sharing options...
Zorkaz Posted December 17, 2021 Share Posted December 17, 2021 Movable Statics can have internal and external scripts on it. So you might make them into such ones.You might need to add a third, invisible object (A marker) ObjectReference Property OtherObject Auto ObjectReference Property TheMarker Auto Event OnLoad() StartTimer (10, 200) EndEvent Event OnTimer (Int AITimerID) If AiTimerID == 200 OtherObject.moveto(Self) Self.moveto(TheMarker) Utility.wait(0.1) TheMarker.moveto (OtherObject) StartTimer (10, 200) Endif EndEvent Link to comment Share on other sites More sharing options...
SKKmods Posted December 17, 2021 Share Posted December 17, 2021 Stick some Debug.Trace or DEebug.Notification statements in to see if the script is running. Link to comment Share on other sites More sharing options...
Dufftacular Posted December 17, 2021 Author Share Posted December 17, 2021 Movable Statics can have internal and external scripts on it. So you might make them into such ones.You might need to add a third, invisible object (A marker) ObjectReference Property OtherObject Auto ObjectReference Property TheMarker Auto Event OnLoad() StartTimer (10, 200) EndEvent Event OnTimer (Int AITimerID) If AiTimerID == 200 OtherObject.moveto(Self) Self.moveto(TheMarker) Utility.wait(0.1) TheMarker.moveto (OtherObject) StartTimer (10, 200) Endif EndEventThanks! Even though this is for movable statics, I did a workaround for Statics. Which is just replacing the movable static model with a Static model. Works well! Link to comment Share on other sites More sharing options...
Dufftacular Posted December 17, 2021 Author Share Posted December 17, 2021 (edited) Stick some Debug.Trace or DEebug.Notification statements in to see if the script is running.Thank you also for the help. I went ahead and tried yours again and it worked. Only issue was they weren't movable statics I was using. So two different versions of the script! Edited December 17, 2021 by Dufftacular Link to comment Share on other sites More sharing options...
Recommended Posts