Need help understanding timers and counters.
Posted: Wed Sep 19, 2012 2:25 pm
I want to use a timer for a puzzle, so started out by trying a very basic script to get the idea of timers and counters... but I can't even get that to work, so wondered if someone could advise...
I created counter "time_01" initial 0
I created timer "button_timer" interval 1 and running at start.
I added connectors from button_timer to time_01 to increment
I also added a connector from button_timer to the following script
When the timer activates it prints the value of the counter to the hud (so I can see that the timer is running and the counter is going up). However the output I get is "table: 0x05e4f8b0"
I tried without the tostring() function and it crashed saying bad argument, string expected
ultimately what I want to do is have 2 buttons... when either is pressed the script checks whether the timer is running.. if it's not, start the time and decrement a door counter. If it is running, check if it's over the alloted time: yes, reset everything. No, decrement the door counter, opening the door.
I created counter "time_01" initial 0
I created timer "button_timer" interval 1 and running at start.
I added connectors from button_timer to time_01 to increment
I also added a connector from button_timer to the following script
Code: Select all
function printTime()
hudPrint(tostring(time_01))
end
I tried without the tostring() function and it crashed saying bad argument, string expected
ultimately what I want to do is have 2 buttons... when either is pressed the script checks whether the timer is running.. if it's not, start the time and decrement a door counter. If it is running, check if it's over the alloted time: yes, reset everything. No, decrement the door counter, opening the door.