Timer modifications

Post ideas & suggestions you have pertaining to the game here.
Post Reply
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

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:

Code: Select all

(objHasTimerEvent gSource 'Timer)
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.
Image
Image
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Number 2 you can handle yourself. When the timer starts running, set a value you can access somewhere to true. When you cancel it (if you cancel it) set it to false. Then, when you are wondering if you should start a new timer, check if that value is true.

Number 1 would be nice, but takes a bit more work. They are basically anonymouse events. I would like to see some new functions for that. You have to think of:

1) How do you cancel them (probably a return value you can pass to another function)
2) are they still bound to an object, or should that be optional (ie. gSource)
3) are they still bound to a system, or should that be optional (would be nice to have recurring events that crossed systems)
4) ???
5) Profit!
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

1. I think that an easy way to make it work would be to have a new data field in the timer that saves the timer under a variable, i.e.

Code: Select all

(sysAddObjTimerEvent "TimerA" 100 gSource (setq randomNumber (random 1 100)))
That would save the timer under the variable "TimerA" which could then be called by name, i.e.

Code: Select all

(sysCancelTimerEvent gSource "TimerA")

So it cancels in the same format, but it cancels the timer directly. If you want to use events like normal, you could do

Code: Select all

(sysAddObjTimerEvent "TimerB" 100 gSource 'TimerTag)
Which runs the event "TimerTag" and can be canceled by:

Code: Select all

(sysCancelTimerEveng gSource "TimerB")

2. I think that they should be bound to an object, because otherwise they would be running globally, and could conflict if multiple ships have the same timer, like Xen. Worldship. It would be nice to have the ability to do global timers. Maybe an option in the location field to put gGlobal or something to run it globally?
3. I'm not really sure.
4. What?
5. What? (again)
Image
Image
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?
Post Reply