Glenstorm Posted February 18, 2011 Share Posted February 18, 2011 I need to run a script ONCE for the lifetime of a mod I'm making. At the very start. How do I go about doing this? Thanks in advance. Link to comment Share on other sites More sharing options...
PaladinRider Posted February 18, 2011 Share Posted February 18, 2011 not sure of the syntax... but anything like this int x; if x == 0 do stuff set x to 1 endif Link to comment Share on other sites More sharing options...
Skevitj Posted February 18, 2011 Share Posted February 18, 2011 What Paladin posted is pretty much spot on. The code block has to be contained within a script which is always in existance though, ie a startgame enabled quest, or on a persistent reference. If it's on an object which is destroyable, or there are multiple objects of a type, ie food, it will run once for every object. Link to comment Share on other sites More sharing options...
jhardingame Posted February 18, 2011 Share Posted February 18, 2011 (edited) Here's a more specific way to do it. :P at the top of the script(where you define some extra variables), you can do bdoonce Example: SCN Scriptname short bDoOnce Begin OnActivate (or OnTrigger) if (bDoOnce == 0) result script set bDoOnce to 1 end if I currently use a script using this function in a mod I'm making, and works like a charm. :thumbsup: Edited February 18, 2011 by jhardingame Link to comment Share on other sites More sharing options...
b3w4r3 Posted February 18, 2011 Share Posted February 18, 2011 If you need the script to run as soon as the mod is loaded, and I think that's what you asked, best way is to use a quest script. You can create a special quest just for running the script, and set it to a lvl 60 or so priority, with start game enabled checked. Then in the script you call stopquest Questname, and the script will stop running. This it typically used to add items to the player when starting a mod, but you can do whatever you need. short once Begin GameMode if once == 0 ;do stuff stopquest QuestName set once to 1 endif End Link to comment Share on other sites More sharing options...
Glenstorm Posted February 19, 2011 Author Share Posted February 19, 2011 If you need the script to run as soon as the mod is loaded, and I think that's what you asked, best way is to use a quest script. You can create a special quest just for running the script, and set it to a lvl 60 or so priority, with start game enabled checked. Then in the script you call stopquest Questname, and the script will stop running. This it typically used to add items to the player when starting a mod, but you can do whatever you need. short once Begin GameMode if once == 0 ;do stuff stopquest QuestName set once to 1 endif End Just what I was looking for. I didn't know of the function stopquest. Haven't explored the quest portion of the GECK yet, as you probably guessed. Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts