Advertisement
Guest User

Untitled

a guest
May 14th, 2013
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. m = peripheral.wrap("left")
  2. status = {...}
  3. statusvar = (status[1])
  4.  
  5. function checkstatusFile()
  6.     file = fs.open("statusFile", "r")
  7.     validate = file.readAll()
  8.     if validate == "off" and statusvar ~= "off" or validate == "off"then
  9.         forcefield = "off"
  10.     elseif validate == "on" and statusvar ~= "on" or validate == "on" then
  11.         forcefield = "on"
  12.     end
  13.    
  14.     if statusvar == "on" and validate ~= "on" or validate == "on" then
  15.         forcefield = "on"
  16.     elseif statusvar == "off" and validate ~= "off" or validate =="off" then
  17.         forcefield = "off"
  18.     end
  19.     return(forcefield)
  20. end
  21.  
  22.  
  23.  
  24. function applychanges()
  25.     if forcefield == "on" then
  26.         file = fs.open("statusFile", "w")
  27.         file.write("on")
  28.         file.close()
  29.     elseif forcefield == "off" then
  30.         file = fs.open("statusFile", "w")
  31.         file.write("off")
  32.         file.close()
  33.     end
  34.    
  35.     if forcefield == off then
  36.         m.setFreq(6)
  37.         m.set(false)
  38.     else
  39.         m.setFreq(6)
  40.         m.set(true)
  41.     end
  42. end
  43. checkstatusFile()
  44. applychanges()
  45. print(forcefield)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement