This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
immibis's profile picture

User-controlled information on timer events.

Started by immibis, 14 December 2012 - 04:04 PM
immibis #1
Posted 14 December 2012 - 05:04 PM
It would be nice if os.startTimer accepted more arguments that will not be interpreted but will be added to the timer event's arguments.
Currently, no more than 4 arguments could be added (see Events are limited to 5 parameters)

For example, so that:

os.startTimer(5, "asdf", "jkl", "xyz")
evt = {os.pullEvent("timer")}
print(table.concat(evt, " "))

prints in 5 seconds:

timer (timer ID goes here) asdf jkl xyz

It could possibly include the ability to change the event name, although this could require a new function:

-- simulate a keypress in 5 seconds
os.startEventTimer(5, "key", keys.up)
dissy #2
Posted 14 December 2012 - 05:34 PM
If you need more info associated with a timer, you really only need one argument for an ID.
You can use an array of tables that have an index matching the timer ID, and the value is a table with as many things in it as you need to keep track of.
immibis #3
Posted 14 December 2012 - 06:57 PM
If you need more info associated with a timer, you really only need one argument for an ID.
You can use an array of tables that have an index matching the timer ID, and the value is a table with as many things in it as you need to keep track of.
I know. Would you rather use timers that way or this way?
Cloudy #4
Posted 14 December 2012 - 07:25 PM
I'm not going to do this. It would over complicate things on our side just to save a few lines of code on your side.