dontpanic Posted July 28, 2009 Share Posted July 28, 2009 I have created a companion I would like to go back to her fired location if one full game day passes. How would I set up this in the script shown below? The Code box contains a single button among many other in a menu system created for the NPC. If someone manages to help me figure out how to activate a timer. How would I be able to cancel it so the NPC does not fire itself after coming out of the hold position state? ;--------------------------------------------------------------------- ; Option 5 - Hold Selection 1 ---------------------------------------- ;--------------------------------------------------------------------- elseif iButton == 5 ; Option 5 - Hold Current Position set follow to 0 set Hold to 1 set Scavenge to 0 set TempBase to 0 set HoldMenu to 0 EvaluatePackage Link to comment Share on other sites More sharing options...
Cipscis Posted July 28, 2009 Share Posted July 28, 2009 For relatively long timers, you'll want to use the hard-coded global variable "GameDaysPassed[/url]. The timer will have two sections - an initialisation step in which the timer's "finish time" is specified, and a condition that checks if the timer has finished. For example:float fEndTime ... ; Initialisation set fEndTime to GameDaysPassed + 1; 1 game-day from now ... if GameDaysPassed > fEndTime; The timer has finished ; do stuff endifCipscis Link to comment Share on other sites More sharing options...
dontpanic Posted July 28, 2009 Author Share Posted July 28, 2009 For relatively long timers, you'll want to use the hard-coded global variable "GameDaysPassed[/url]. The timer will have two sections - an initialisation step in which the timer's "finish time" is specified, and a condition that checks if the timer has finished. For example:;--------------------------------------------------------------------- ; Option 5 - Hold Selection 1-------------------------------------- ;--------------------------------------------------------------------- elseif iButton == 5 ; Option 5 - Hold Position set follow to 0 set Hold to 1 set Scavenge to 0 set TempBase to 0 set HoldMenu to 0 EvaluatePackage set fEndTime to GameDaysPassed + 1; 1 game-day from now if GameDaysPassed > fEndTime && Hold 1; The timer has finished set fired to 1 set Hired to 0 set hold to 0 set follow to 0 set TempBase to 0 SetPlayerTeammate 0 RemoveFromFaction FollowerFaction EvaluatePackage endif Link to comment Share on other sites More sharing options...
Cipscis Posted July 28, 2009 Share Posted July 28, 2009 The initalisation step needs to only happen once, and the condition needs to be checked constantly. The value of "fEndTime" needs to remain constant until the end condition returns true. It's hard to say how you should include it in your script without knowing how it's set up, but you'll basically need to initialise the timer when the button is pressed, and then check the condition after the button has been pressed. If you could post your entire script I should be able to tell you how to include the timer within your script. P.S. Your script is a little difficult to follow due to inconsistent indentation. If you don't know how to indent your scripts, here is a link to a web-based tool that can do it for you, as well as checking for a few structural errors - Script Validator Cipscis EDIT: I've replied to your PM with what's hopefully a working script. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts