Whenever I have left it to just run and idle I come back to see my program has crashed which is very dangerous because the reactor could explode if im not there to turn it off, so I have come to receive some help with reviewing my code and helping me understand where I am going wrong. I am also using AE2 and OpenPeripherals for this setup.
local setup = { 0, 1, 0, 1, 0, 1, 0, 0, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 2 } local reactor = peripheral.wrap("top") local storage = peripheral.wrap("tileinterface_4") local recycler = peripheral.wrap("tileinterface_5") local full = true local x = 1 local loops = 1 local lzhF = { id = "IC2:item.reactorCondensatorLap", dmg = 0, } local uranF = { id = "IC2:item.reactorUraniumQuad", dmg = 0, } local overF = { id = "IC2:item.reactorVentGold", dmg = 0, } local function reFuel(check) if x == 1 then x = 0 loops = 0 rs.setOutput("front", false) if check then for o = 1, 54 do recycler.pullItem("north", o, 1, 1) end end for i = 1, 54 do if setup[i] == 0 then storage.exportItem(lzhF, "south", 1, i) elseif setup[i] == 1 then storage.exportItem(uranF, "south", 1, i) elseif setup[i] == 2 then storage.exportItem(overF, "south", 1, i) end end rs.setOutput("front", true) end end while true do term.clear() term.setCursorPos(1,1) full = rs.getInput("back") -- MAIN print("Running: " .. tostring(reactor.isActive())) print("Heat: " .. reactor.getHeat()) print("Loops:" .. loops) if reactor.getHeat() >= 100 then rs.setOutput("front", false) for y = 1, 54 do recycler.pullItem("north", y, 1, 1) end elseif reactor.getHeat() < 100 then rs.setOutput("front", true) end if reactor.isActive() and reactor.getHeat() < 100 then for w = 1, 54 do if loops > 540 then rs.setOutput("front", false) x = 1 end if reactor.getStackInSlot(w) ~= nil then if setup[w] == 0 then if reactor.getStackInSlot(w).id == "IC2:item.reactorCondensatorLap" and reactor.getStackInSlot(w).dmg > 50000 then loops = loops + 1 recycler.pullItem("north", w, 1, 1) storage.exportItem(lzhF, "south", 1, w) end elseif setup[w] == 1 then if reactor.getStackInSlot(w).id == "IC2:item.reactorUraniumQuad" and reactor.getStackInSlot(w).dmg > 7500 then loops = loops + 1 recycler.pullItem("north", w, 1, 1) storage.exportItem(uranF, "south", 1, w) end end elseif reactor.getStackInSlot(w) == nil then if setup[w] == 0 then storage.exportItem(lzhF, "south", 1, w) elseif setup[w] == 1 then storage.exportItem(uranF, "south", 1, w) end end end end if full == true then x = 1 elseif full == false and x == 1 then if next(reactor.getAllStacks()) == nil then reFuel(false) x = 0 else reFuel(true) x = 0 end end -- MAIN os.queueEvent("fakeEvent") os.pullEvent() end
The error says something along the lines of "nuclear:69: error getting TileEntity at dim 0 ..."