diff --git a/react.lua b/react similarity index 78% rename from react.lua rename to react index 4ab9ffd..aa7ca80 100644 --- a/react.lua +++ b/react @@ -1,3 +1,6 @@ +--import utils for lamp rednet stuffs +dofile("/git-scripts/utils") + --regulate in between these in normal operation NORMAL_THRESHOLD_U = 8000000 NORMAL_THRESHOLD_L = 7000000 @@ -16,6 +19,13 @@ local ctrl_rods = NORMAL_ROD_POS local reactor = peripheral.wrap("back") local mon = peripheral.wrap("right") +--connect to lamp via rednet (if present) +local modemSide = utils.getSideOf("modem") +if modemSide then --not nil + rednet.open("modemSide") + local lampID = rednet.lookup("reactLamp", "reactLamp") +end + print("Monitoring reactor...") while (true) @@ -78,7 +88,18 @@ do then mon.setCursorPos(1, 5) mon.write("REFUEL!") - end - + + --send fuel state to lamp + if lampID then --not nil: rednet present and found lamp! + rednet.send(lampID, "1", "reactLamp") + end + else + if lampID then + rednet.send(lampID, "0", "reactLamp") + end + end + sleep(1) end + +--infinite loop; rednet never gets closed diff --git a/reactLamp b/reactLamp new file mode 100644 index 0000000..c7d8b52 --- /dev/null +++ b/reactLamp @@ -0,0 +1,13 @@ +LAMP_SIDE = "bottom" + +dofile("/git-scripts/utils") + +local modemSide = utils.getSideOf("modem") +rednet.open(modemSide) +rednet.host("reactLamp", "reactLamp") --register as lamp + +while (true) +do + id, msg, sth = rednet.receive("reactLamp") + redstone.setOutput(LAMP_SIDE, msg == "1") +end