Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 14th, 2013  |  syntax: Lua  |  size: 0.97 KB  |  views: 167  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)