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

saving variable

Started by Crowdy199, 12 February 2013 - 11:41 AM
Crowdy199 #1
Posted 12 February 2013 - 12:41 PM
how do i save
door1 = open
so when it reboots it nows door1 equals open
lieudusty #2
Posted 12 February 2013 - 12:44 PM
Like this:

local function saveVar(text)
  f = fs.open("var", "w")
  f.write(text)
  f.close()
end
local function getVar(text)
  f = fs.open("var", "r")
  local data = f.readAll()
  f.close()
  return data
end
Crowdy199 #3
Posted 12 February 2013 - 01:09 PM
can u explain what that does step by sterp and where i put the name and what it equals
lieudusty #4
Posted 12 February 2013 - 02:31 PM

saveVar("true")
status = getVar()
print(status) --> true