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

Simple Log Time Open

Started by Crowdy199, 05 January 2013 - 08:43 AM
Crowdy199 #1
Posted 05 January 2013 - 09:43 AM
i just want to make a simple program i dont no how to do it i just want to make it so every time it runs the code it makes the veriable times open +1 so the veriable will be the times that line of code was run but i dont no how to do it
Luanub #2
Posted 05 January 2013 - 10:05 AM
To increment a value simply add +1 to it.

timesOpened = timesOpened + 1

If you want it to be persistant you will want to save it to a file, you can use either fs or the io API to take care of that. There is tutorials here on the forum on how to use those so there is no sense in me explaining it here. If you run into any problems let us know.