gelatine87 icon

reactorWiFiempfanger

gelatine87 | PRO | 08/03/16 12:05:43 AM UTC | 0 ⭐ | 411 👁️ | Never ⏰ | []
Lua |

3.49 KB

|

None

|

0 👍

/

0 👎

----------------------------------------------------------
-- Active Cooling Big Reactor Monitor                   --
--                                                      --
-- Minecraft HermitCraft FTB Infinity Episode 28        --
-- https://www.youtube.com/watch?v=cIPxwZJWOiE          --
--                                                      --
-- YouTube Channel http://youtube.com/hypnotizd         --
----------------------------------------------------------
 
local mon = {}
local hasMon = false
local hasRMon = false
local rMonName = ""
local directions = {"top", "bottom", "front", "back", "left", "right"}
 
local function findPeripherals()
  for k, v in pairs(peripheral.getNames()) do
    if string.find(v, "monitor") then
      hasMon = true
      hasRMon = true
      rMonName = v
      print("INFO: Found remote "..v)
      os.sleep(1)
    end
  end
end
 
local function findMon()
  if hasRMon then return end
  for k, v in pairs(directions) do
    local p = peripheral.wrap(v)
    if p ~= nil then
      if string.find(peripheral.getType(v), "monitor") then
        mon = p
        hasMon = true
        return
      end
    end
  end
  print("WARNING: No monitor detected!")
  os.sleep(5)
end
 
local function monClear()
  if hasMon then
    if hasRMon then
      peripheral.call(rMonName, "setCursorPos", 1, 1)
      peripheral.call(rMonName, "clear")
    else
      mon.setCursorPos(1, 1)
      mon.clear()
    end
  else
    term.clear()
    term.setCursorPos(1, 1)
  end
end
 
local function monWrite(x, y, text)
  if hasMon then
    if hasRMon then
      peripheral.call(rMonName, "setCursorPos", x, y)
      peripheral.call(rMonName, "write", text)
    else
      mon.setCursorPos(x, y)
      mon.write(text)
    end
  else
    term.setCursorPos(x, y)
    term.write(text)
  end
end
 
local function init()
  term.clear()
  term.setCursorPos(1, 1)
  findPeripherals()
  findMon()
  monClear()
end
 
init()
 
while true do
 
  local rods = 0
  local casingTemp = 0
  local coreTemp = 0
  local rodLevel = 0
  local fuelReactivity = 0
  local fuelConsumed = 0
  local steamProduced = 0
  local active = ""
  local X = 0
  local Y = 0
  local Z = 0
  
  rednet.open("top")
  local id, msg = rednet.receive()
  local table = textutils.unserialize(msg)
  -- print(table[0]) == getNumberOfControlRods
  -- print(table[1]) == getCasingTemperature
  -- print(table[2]) == getFuelTemperature
  -- print(table[3]) == getControlRodLevel
  -- print(table[4]) == getFuelReactivity
  -- print(table[5]) == getFuelConsumedLastTick
  -- print(table[6]) == getHotFluidProducedLastTick
  -- print(table[7]) == active
  -- print(table[8]) == X
  -- print(table[9]) == Y
  -- print(table[10]) == Z
  
  rods = table[0]
  casingTemp = table[1]
  coreTemp = table[2]
  rodLevel = table[3]
  fuelReactivity = table[4]
  fuelConsumed = table[5]
  steamProduced = table[6]
  active = table[7]
  X = table[8]
  Y = table[9]
  Z = table[10]
  
  monClear()
  monWrite(1, 1, "   Reactor Status: "..active)
  monWrite(1, 2, "     Reactor Size: "..X.."x"..Y.."x"..Z)
  monWrite(1, 3, " Num Control Rods: "..rods)
  monWrite(1, 4, "     Casing Temp.: "..casingTemp)
  monWrite(1, 5, "       Core Temp.: "..coreTemp)
  monWrite(1, 6, "Control Rod Level: "..rodLevel)
  monWrite(1, 7, "  Fuel Reactivity: "..fuelReactivity)
  monWrite(1, 8, "  Fuel Usage/tick: "..fuelConsumed)
  monWrite(1, 9, "   Steam Produced: "..steamProduced)
  
  os.sleep(3)
end

Comments