SHARE
TWEET

startup

a guest Jun 15th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. storage = peripheral.wrap("right")  -- Induction Matrix
  2. mon = peripheral.wrap("top")    -- Monitor side
  3. mon.setTextScale(0.5)   --Scale of text on monitor. 0.5-5
  4.  
  5. total = 0 -- Variable for total usage
  6.  
  7.  
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. term.write("Mekanism Power Control By GammerPro2000")
  11. sleep(1.5)
  12. term.clear()
  13.  
  14.  
  15. if fs.exists("power") == true then -- Does the file exist?
  16.     myFile = fs.open("power", "r") -- If it does, open the file in read mode
  17.     total = myFile.readLine()   -- set total to the amount already used
  18.     myFile.close()  -- close the file
  19. else
  20.     myFile = fs.open("power", "w") -- if not, open the file in write mode
  21.     myFile.writeLine("0") -- set the usage to 0
  22.     myFile.close() -- close the file
  23. end
  24.  
  25. term.setCursorPos(1,1)
  26. print("Reset total power used? y/n: ")
  27. user = io.read()
  28. if user == "y" then
  29.     myFile = fs.open("power", "w") -- if not, open the file in write mode
  30.     myFile.writeLine("0") -- set the usage to 0
  31.     myFile.close() -- close the file
  32.     total = 0
  33. elseif user == "n" then
  34.    
  35. else
  36.     os.reboot()
  37. end
  38.  
  39.  
  40.  
  41.  
  42. while true do
  43.     mon.clear() --Clears the monitor
  44.     mon.setCursorPos(1,1) --Cursor set to 1,1
  45.     mon.write(storage.getOutput()/2.5) --Writes the output to the monitor
  46.     total = total + storage.getOutput()/2.5 * 20  -- Adds to the total amount of RF used
  47.  
  48.     mon.setCursorPos(1,2)                      
  49.     mon.write("Used: ".. total)
  50.  
  51.     myFile = fs.open("power", "w") -- Opens the file for power used
  52.     myFile.writeLine(total) -- Writes the total amount used.
  53.     myFile.close()  -- Closes file
  54.     sleep(1) -- sleeps for one second
  55. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top