m = peripheral.wrap("left")
status = {...}
statusvar = (status[1])
function checkstatusFile()
file = fs.open("statusFile", "r")
validate = file.readAll()
if validate == "off" and statusvar ~= "off" or validate == "off"then
forcefield = "off"
elseif validate == "on" and statusvar ~= "on" or validate == "on" then
forcefield = "on"
end
if statusvar == "on" and validate ~= "on" or validate == "on" then
forcefield = "on"
elseif statusvar == "off" and validate ~= "off" or validate =="off" then
forcefield = "off"
end
return(forcefield)
end
function applychanges()
if forcefield == "on" then
file = fs.open("statusFile", "w")
file.write("on")
file.close()
elseif forcefield == "off" then
file = fs.open("statusFile", "w")
file.write("off")
file.close()
end
if forcefield == off then
m.setFreq(6)
m.set(false)
else
m.setFreq(6)
m.set(true)
end
end
checkstatusFile()
applychanges()
print(forcefield)