Posted 24 February 2013 - 10:43 PM
I've written this code to give out software for free on an SMP server and it all works, but I'm having this major (and most likely - nooby) problem of not able to increment by one. Also, because the computers restart every time the server restarts, I want to make sure each count is stored in a file.
Code is:
Code is:
if fs.exists("count") == true then
asdf = fs.open("count", "r")
local hold = asdf.readLine()
asdf.close()
count = tonumber(hold)
else
asdf = fs.open("count", "w")
asdf.close()
local count = tonumber(0)
end
term.write(count)
while true do
if disk.isPresent("top") == true then
if fs.exists("disk/startup") == true then
fs.delete("disk/startup")
end
if fs.exists("disk/readme") == true then
fs.delete("disk/readme")
end
fs.copy("time", "disk/startup")
fs.copy("readme", "disk/readme")
disk.setLabel("top", "Script")
disk.eject("top")
count = count + 1
file = fs.open("count", "w")
file.write(count)
file.close()
end
sleep(1)
end