Can a Constant "Get" Script Run? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: Can a Constant "Get" Script Run? (/thread-11261.html) Pages:
1
2
|
Can a Constant "Get" Script Run? - Statyk - 11-09-2011 Okay, I know that sounds funny... but simply, I want the game to check for something every 0.01f second if possible, and when it's not there anymore, another script will run. Is it possible to have a global timer CONSTANTLY run through the map? RE: Can a Constant "Get" Script Run? - nemesis567 - 11-09-2011 Depending on what it calls it may or may not affect performance. RE: Can a Constant "Get" Script Run? - Obliviator27 - 11-09-2011 Would something along the lines of PHP Code: void OnStart() RE: Can a Constant "Get" Script Run? - Your Computer - 11-09-2011 Though i'm not entirely sure of the workings of the global.hps, you could probably define your callback there and then add a timer wherever you need to check for something. RE: Can a Constant "Get" Script Run? - Statyk - 11-09-2011 So what you two are saying is that setting a global timer will have it constantly run in that map? RE: Can a Constant "Get" Script Run? - Your Computer - 11-09-2011 What i'm saying is, your only chance for a "global" timer may be through global.hps (but i haven't done anything with a global.hps file for my story yet, so i wouldn't know for sure). Otherwise, you're stuck with "local" timers, having to specify the same callback and adding the same timer to all the maps you want check for something constantly. RE: Can a Constant "Get" Script Run? - palistov - 11-09-2011 (11-09-2011, 02:54 AM)Your Computer Wrote: ...your only chance for a "global" timer may be through global.hps...I've actually tried writing out void functions in the global.hps script but they're not responsive, at least when I tried called them using local scripts. I haven't dug deep into that though, so I may be wrong. But the best way I can think of creating a "global" timer would be using global vars. global.hps PHP Code: void OnGameStart() map1.hps & map2.hps & map3.hps etc... PHP Code: // may have to add a looping timer to constantly save the time left, just in case the player saves and exits the game, which does NOT count as OnLeave RE: Can a Constant "Get" Script Run? - Statyk - 11-09-2011 (11-09-2011, 07:22 PM)palistov Wrote:I'm sorry to have put you through all that, but are you saying a GLOBAL function is set for ALL maps? I only need it in one, and I thought LOCAL functions were only at the player. (like, if the player had a variable, say health or sanity). I just need it in one map.(11-09-2011, 02:54 AM)Your Computer Wrote: ...your only chance for a "global" timer may be through global.hps...I've actually tried writing out void functions in the global.hps script but they're not responsive, at least when I tried called them using local scripts. I haven't dug deep into that though, so I may be wrong. But the best way I can think of creating a "global" timer would be using global vars. RE: Can a Constant "Get" Script Run? - Apjjm - 11-10-2011 If you need it in one map, the following really simple loop will suffice: Code: const float TIMESTEP = 1.0f / 60.0f; Note: OnSaveLoad only exists if you add a timer and routine to check for it (see here if you are interested). This isn't necessary in this case as timers are preserved when the game is saved, and the user cannot save the game in the middle of executing a function. Therefore, in whatever map you want you can really just get away with 1 timer. RE: Can a Constant "Get" Script Run? - palistov - 11-10-2011 Statyk, as far as I know, timers don't carry over between maps. The little script I put together is a possible way to keep track of a timer across multiple maps. A suggestion, if you will. But you'll above to do some testing and see if you can get something working. |