MinoCraft72

ReactorControl

Mar 16th, 2015
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. --Methods:
  2.  
  3.   --getMaxHeat
  4.   --isActive
  5.   --getAllStacks
  6.   --getEUOutput
  7.   --getHeat
  8.   --getInventorySize
  9.  
  10. --Config:
  11.  
  12.   reactorSide = "top"
  13.   redstonSide = "back"
  14.  
  15. --Function:
  16.  
  17. reactor = peripheral.wrap(reactorSide)
  18.  
  19. function firstRun()
  20.   if fs.exists("log.txt") then
  21.    -- Open data
  22.    print("Uranium Slot file Ok")
  23.    file = fs.open("log.txt","r")
  24.    slotFile = file.readAll()
  25.    file.close()
  26.    print(slotFile)
  27.    slotCell = textutils.unserialize(slotFile)  
  28.   else
  29.    shell.run("pastebin get 1JHBtb20 searchCell")
  30.    shell.openTab("searchCell")
  31.     for i = 5,0,-1 do
  32.      term.setCursorPos(1,2)
  33.      print("Searching Uranium Cell ...")
  34.      term.setCursorPos(1,3)
  35.      term.clearLine()
  36.      print("Wait "..i.." s")
  37.      sleep(1)
  38.     end
  39.   end
  40. term.clear()
  41. end
  42.  
  43. function uranium()
  44.   for k,v in pairs(slotCell) do
  45.    slot = v
  46.    --print("slot: "..slot)
  47.    --print(k..": "..tostring(v))
  48.    --sleep(1)
  49.    slotData = reactor.getStackInSlot(slot)
  50.     if slotData ~= nil then
  51.       for k,v in pairs(slotData) do
  52.        dispName = slotData.display_name
  53.        name = slotData.name
  54.        dmg = slotData.dmg      
  55.       end
  56.      maxDmg = 10000
  57.      timeInSec = 10020
  58.      ratio = maxDmg/timeInSec
  59.      calTime_1 = (timeInSec - (dmg*ratio))/60
  60.      --print("Cal_1: "..calTime_1)
  61.      calTime_2 = math.floor(calTime_1)/60 -- hour decimal
  62.      --print("Cal_2: "..calTime_2)
  63.      calTime_3 = (calTime_2 - math.floor(calTime_2)) * 60
  64.      timeH = math.floor(calTime_2)
  65.      timeM = math.floor(calTime_3)
  66.      --print("Cal_3: "..calTime_3)
  67.      --print("H: "..math.floor(calTime_2))
  68.      --print("Min: "..math.floor(calTime_3))
  69.      strg = string.format("%s: %s - %s h %s min",slot,dispName,timeH,timeM)
  70.      print(strg)
  71.      yPos = yPos + 1
  72.      --print(name)
  73.      --print(dmg)
  74.     end
  75.   end
  76. end
  77.  
  78. --for k,v in pairs(reactor) do
  79.  --print(k..": "..tostring(v))
  80.  --sleep(2)
  81. --end
  82. term.clear()
  83. term.setCursorPos(1,1)
  84. firstRun()
  85. while true do
  86.  yPos = 7
  87.  if slotCell == nil then
  88.   firstRun()
  89.  end
  90.  sleep(1)
  91.  temp = reactor.getHeat()
  92.  tempMax = reactor.getMaxHeat()
  93.  energyOut = reactor.getEUOutput()
  94.  energyReal = energyOut*5
  95.  term.setCursorPos(1,4)
  96.  term.clearLine()
  97.  print("°C: "..temp.."/"..tempMax)
  98.  term.setCursorPos(1,5)
  99.  term.clearLine()
  100.  print("Output: "..energyReal.." EU/t")
  101.  term.setCursorPos(1,yPos)
  102.  term.clearLine()
  103.  uranium()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment