I was coding and ran into two problems with timers:
A. You can't put code into the timer, you have to have tags i.e. you can't do:
Code: Select all
(sysAddObjRecurringTimerEvent 60 gSource (setq roll (random 1 100)))
To pick a new random number every 2 seconds. You would have to do:
Code: Select all
<OnCreate>
(sysAddObjRecurringTimerEvent 60 gSource 'NewRandom)
</OnCreate>
<NewRandom>
(setq roll (random 1 100))
</NewRandom>
Normally this isn't a problem, but if you're putting a weapon so it has an effect every 15 ticks after it hits something, then it gets very complicated.
B. There isn't a function that says if an object has a timer on it. If you want to make sure that you don't have 2 identical timers running at the same time, you have to cancel the timer then add the new one, which then resets the timer. I'm asking for code like this:
Which would return nil if there isn't a timer on it called "Timer" and would return true if there is the timer called "Timer". Then you could do this:
Code: Select all
(if (not (objHasTimerEvent gSource 'Timer))
(sysAddObjTimerEvent ### gSource 'Timer)
)
Then it adds the timer if it isn't already there, and won't make two identical timers, or reset the timer.

Play in over
100 systems in a network. Play the
2011 Mod Of the Year
and the highest rated mod on Xelerus,
The Network.
Play the July Mod of the Month,
Fellow Pilgrims!
Play
My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?