34 posts
Posted 24 January 2013 - 12:24 PM
hay guys i want to log how many times the computer is opened how do i do that i thought i would do it like this
timesopened = timesopend + 1
print(times opened)
but i just get errors how do i do it
1054 posts
Posted 24 January 2013 - 12:28 PM
hay guys i want to log how many times the computer is opened how do i do that i thought i would do it like this
timesopened = timesopend + 1
print(times opened)
but i just get errors how do i do it
You just have a bunch of spelling errors in there. Can you post your exact code and the error message?
392 posts
Location
Christchurch, New Zealand
Posted 24 January 2013 - 12:29 PM
Well firstly there is a spelling error.
Here's some code to help
local timesOpened = 0
local function loadHistory()
local h = fs.open("times", "r")
if h then
timesOpened = tonumber(h.readAll())
h.close()
else
timesOpened = 0
end
end
local function saveHistory()
local h = fs.open("times", "w")
if h then
h.write(tostring(timesOpened))
h.close()
end
end
loadHistory()
timesOpened = timesOpened + 1
saveHistory()
Edit: Ninja'd by the spelling errors comment, Blast!