To Zer0Cool:
C said:
yes…true… or 1 value will get lost, like in my last code-example. The value in globalaccum 8 will be lost…
It is an incomplete example… just created to show another way of adding/subtracting two accums without a loop (repeatingly calling itself)… i didn’t care to save the value in globalaccum 8 in the 2nd example-code…
Aah, You were talking about a 3 digit number… why not use an extra accum to save the 3 digits as one number as well. I mean, when Your timer triggers, and You are about to increase the player_time digits seperately, why not increase another accum too?..with the whole player_time in 1 accum.
// PSEUDO EXAMPLE CODE
// accum 1 = units
// accum 2 = tens
// accum 3 = hundreds
// accum 4 = the whole number in 1 accum
trigger timer_tick {
increase units
if units>10 then units=0 ; tens=tens+1
if tens>10 then tens=0; hundreds=hundreds+1
// the whole player_time in an accum
accum 4 inc 1
}
in the first kind of comparing when you restore_best_time, you give it the current time and not the best time.
actually, i don’t “give” any value to another function/trigger… there just isn’t the possibility to pass parameters to a trigger…all the globalaccums are always available in every trigger, from any scriptblock…and any accums are always available within the same scriptblock. Since i’ve packed every trigger into the game_manager scriptblock, every accum i use, is accessable in the 1st example-code…
Here’s some explaination to the 1st example-code:
trigger store_new_best_time & trigger restore_best_time are both the same… (now that i look over my own code again),
what the trigger does, is this:
globalaccum 8 = globalaccum 8 + accum 8 // best_time + player_time
trigger compare_time does the following:
accum 8 = globalaccum 7 // copy player_time -> accum 8
globalaccum 8 = globalaccum 8 - globalaccum 7 // best_time - player_time
globalaccum 7 = 0 // …the original value will be lost (but is saved into accum 8)
We always want to have the best_time in globalaccum 8, we need it to be able to check if another player has a better time…
…but in trigger compare_time the value in globalaccum 8 is changed, so i need to change it back again…trigger restore_best_time does this…
In trigger isbetter we detect that the player_time was a better time than the best_time yet, so i don’t want to restore globalaccum 8 to it’s original value, instead i want the new best time to be stored.
I therefore must NOT do: globalaccum 8 = best_time + player_time, but i need to do: globalaccum 8 = player_time…
This is why i give globalaccum 8 a value of 0 just before calling trigger store_new_best_time:
globalaccum 8 set 0
trigger self store_new_best_time
To kamikazee:
Also, saving to cvars is not possible in default W:ET, although most modern mods do support the cvar set sub-command
i did use cvars before in mapscript… in a “modern MOD”… and it worked well… I don’t know if it will work in any other MOD (or original ET), but i take Your word for it that it doesn’t always work… i haven’t tested it under every MOD.