SHARE
TWEET

startup

a guest Jun 15th, 2019 60 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. if fs.exists("power") == true then -- Does the file exist?
  8.     myFile = fs.open("power", "r") -- If it does, open the file in read mode
  9.     total = myFile.readLine()   -- set total to the amount already used
  10.     myFile.close()  -- close the file
  11. else
  12.     myFile = fs.open("power", "w") -- if not, open the file in write mode
  13.     myFile.writeLine("0") -- set the usage to 0
  14.     myFile.close() -- close the file
  15. end
  16.  
  17. while true do
  18.     mon.clear() --Clears the monitor
  19.     mon.setCursorPos(1,1) --Cursor set to 1,1
  20.     mon.write(storage.getOutput()/2.5) --Writes the output to the monitor
  21.     total = total + storage.getOutput()/2.5 * 20 -- Adds to the total amount of RF used
  22.  
  23.     mon.setCursorPos(1,2)                      
  24.     mon.write("Used: ".. total)
  25.  
  26.     myFile = fs.open("power", "w") -- Opens the file for power used
  27.     myFile.writeLine(total) -- Writes the total amount used.
  28.     myFile.close()  -- Closes file
  29.     sleep(1) -- Sleeps for one second
  30. 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