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 - 10:48 AM
Crowdy199 #1
Posted 12 February 2013 - 11:48 AM
how do i save
door1 = open
so when it reboots it nows door1 equals open
remiX #2
Posted 12 February 2013 - 05:00 PM
Check out the fs API.


door1 = "open"

-- lets write it to a file
file = fs.open("myConfigFile", "w") -- 'w' for write mode
file.write(door1)
file.close() -- always close a file handle

-- lets read it from a file
file = fs.open("myConfigFile", "r") -- 'r' for read mode
door1 = file.readLine()
file.close()

print("The door is currently " .. door1)