Frictional Games Forum (read-only)
[SCRIPT] World Timer? - 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: [SCRIPT] World Timer? (/thread-26018.html)



World Timer? - i3670 - 08-31-2014

Is it possible to have timer that runs through all of the maps? If you for instance were to place the timer in the global.hps, would it work?


RE: World Timer? - FlawlessHappiness - 08-31-2014

(08-31-2014, 01:58 PM)i3670 Wrote: Is it possible to have timer that runs through all of the maps? If you for instance were to place the timer in the global.hps, would it work?

Placing it in the global.hps is just worth trying. I don't know if that'll work.

But it is possible, by using variables.

All you'd need is a second timer, that calls itself each second, lowering a variable.

Then when you change map, you set a global variable to the timer-variable.

When entering a map, it should then set the timer-amount to the new global variable.


RE: World Timer? - DnALANGE - 08-31-2014

Iirc..
This thing was impossible..
There were a couple of guys who tried this before.
Altho, i still think it could be possible with Flawless idea, or let the script capture the time with a variable?
Let it count and when leaving save that variable and into another map try to make it continue...


RE: World Timer? - MrBehemoth - 08-31-2014

It's eminently possible! Smile

Like FlawlessHappiness was getting at, just use a looping timer. But you can just increment the global variable, like so:

PHP Code:
void OnStart()
{
      
AddTimer("GlobalClockTimer"1"IncrementGlobalClock");
}

void IncrementGlobalClock(string &in asTimer)
{
      
SetGlobalVarInt("GlobalClock"GetGlobalVarInt("GlobalClock") + 1);
      
AddTimer("GlobalClockTimer"1"IncrementGlobalClock");


You could also make it count down, or use floats and a shorter delay to make it more accurate.


RE: World Timer? - i3670 - 08-31-2014

Alrighty then. I'll try. Thank you all.

Double Post! While I have your attention, I got an error.

main (1, 27190): ERR : 'f' is not a member of const double'

weirdly large number


RE: World Timer? - FlawlessHappiness - 08-31-2014

(08-31-2014, 05:19 PM)i3670 Wrote: Alrighty then. I'll try. Thank you all.

Double Post! While I have your attention, I got an error.

main (1, 27190): ERR : 'f' is not a member of const double'

weirdly large number

To solve that problem, I think we need to see your script.

Since the number is that large I'm gonna guess it's a for-loop problem.


RE: World Timer? - i3670 - 08-31-2014

Found it, it was a stupid . between a number and an f


RE: World Timer? - Mudbill - 08-31-2014

@MrBehemoth

Might as well use the AddLocalVarInt instead of SetLocalVarInt with +1 to its current value. Not that it would make a difference, but ya know, that's why it's there.


RE: World Timer? - MrBehemoth - 08-31-2014

(08-31-2014, 07:48 PM)Mudbill Wrote: @MrBehemoth

Might as well use the AddLocalVarInt instead of SetLocalVarInt with +1 to its current value. Not that it would make a difference, but ya know, that's why it's there.

Absolutely, forgot about that one! Big Grin