Added refueling indicator lamp to react

This commit is contained in:
Hadinos Sanosam 2021-01-12 00:52:28 +01:00
parent 0ff72b6606
commit 2b3cae705a
2 changed files with 36 additions and 2 deletions

View File

@ -1,3 +1,6 @@
--import utils for lamp rednet stuffs
dofile("/git-scripts/utils")
--regulate in between these in normal operation --regulate in between these in normal operation
NORMAL_THRESHOLD_U = 8000000 NORMAL_THRESHOLD_U = 8000000
NORMAL_THRESHOLD_L = 7000000 NORMAL_THRESHOLD_L = 7000000
@ -16,6 +19,13 @@ local ctrl_rods = NORMAL_ROD_POS
local reactor = peripheral.wrap("back") local reactor = peripheral.wrap("back")
local mon = peripheral.wrap("right") 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...") print("Monitoring reactor...")
while (true) while (true)
@ -78,7 +88,18 @@ do
then then
mon.setCursorPos(1, 5) mon.setCursorPos(1, 5)
mon.write("REFUEL!") 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) sleep(1)
end end
--infinite loop; rednet never gets closed

13
reactLamp Normal file
View File

@ -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