Fixed whitespace

This commit is contained in:
Hadinos Sanosam 2021-01-12 01:41:11 +01:00
parent aec5a1d0e4
commit 38b5f70f2a
5 changed files with 31 additions and 31 deletions

20
react
View File

@ -22,8 +22,8 @@ local mon = peripheral.wrap("right")
--connect to lamp via rednet (if present) --connect to lamp via rednet (if present)
local modemSide = utils.getSideOf("modem") local modemSide = utils.getSideOf("modem")
if modemSide then --not nil if modemSide then --not nil
rednet.open(modemSide) rednet.open(modemSide)
lampID = rednet.lookup("reactLamp", "reactLamp") lampID = rednet.lookup("reactLamp", "reactLamp")
end end
print("Monitoring reactor...") print("Monitoring reactor...")
@ -89,15 +89,15 @@ do
mon.setCursorPos(1, 5) mon.setCursorPos(1, 5)
mon.write("REFUEL!") mon.write("REFUEL!")
--send fuel state to lamp --send fuel state to lamp
if lampID then --not nil: rednet present and found lamp! if lampID then --not nil: rednet present and found lamp!
rednet.send(lampID, "1", "reactLamp") rednet.send(lampID, "1", "reactLamp")
end end
else else
if lampID then if lampID then
rednet.send(lampID, "0", "reactLamp") rednet.send(lampID, "0", "reactLamp")
end end
end end
sleep(1) sleep(1)
end end

View File

@ -8,6 +8,6 @@ rednet.host("reactLamp", "reactLamp") --register as lamp
while (true) while (true)
do do
id, msg, sth = rednet.receive("reactLamp") id, msg, sth = rednet.receive("reactLamp")
redstone.setOutput(LAMP_SIDE, msg == "1") redstone.setOutput(LAMP_SIDE, msg == "1")
end end

View File

@ -2,8 +2,8 @@ dofile("/git-scripts/utils")
modemSide = utils.getSideOf("modem") --get side the modem is on modemSide = utils.getSideOf("modem") --get side the modem is on
if modemSide == nil then if modemSide == nil then
print("Error: No modem detected!") print("Error: No modem detected!")
return return
end end
rednet.open(modemSide) rednet.open(modemSide)
@ -20,8 +20,8 @@ content = data.content
--write to file --write to file
local file = fs.open(filename, "w") local file = fs.open(filename, "w")
if file == nil then if file == nil then
print("Error: failed to write file " .. filename) print("Error: failed to write file " .. filename)
return return
end end
file.write(content) file.write(content)
print("Received '" .. filename .. "' !") print("Received '" .. filename .. "' !")

View File

@ -15,8 +15,8 @@ end
local filename = args[1] local filename = args[1]
local file = fs.open(filename, "r") local file = fs.open(filename, "r")
if file == nil then if file == nil then
print("Error: File not found") print("Error: File not found")
return return
end end
content = file.readAll() content = file.readAll()
local data = {} --pack filename, content local data = {} --pack filename, content
@ -29,14 +29,14 @@ local receiver = tonumber(args[2])
--init rednet --init rednet
modemSide = utils.getSideOf("modem") modemSide = utils.getSideOf("modem")
if modemSide == nil then if modemSide == nil then
print("Error: No modem detected!") print("Error: No modem detected!")
return return
end end
rednet.open(modemSide) rednet.open(modemSide)
print("Waiting for receiver...") print("Waiting for receiver...")
repeat repeat
id, msg, sth = rednet.receive("fileRX") --keep waiting id, msg, sth = rednet.receive("fileRX") --keep waiting
until id == receiver until id == receiver
--receiver is online! --receiver is online!

20
utils
View File

@ -3,19 +3,19 @@ if utils then return end --avoid loading twice
utils = {} utils = {}
function utils.getSideOf(name) --get which side, if any, a peripheral p is connected to function utils.getSideOf(name) --get which side, if any, a peripheral p is connected to
local sides = peripheral.getNames() local sides = peripheral.getNames()
for i = 1, #sides do for i = 1, #sides do
if peripheral.getType(sides[i]) == name then if peripheral.getType(sides[i]) == name then
--found it! --found it!
return sides[i] return sides[i]
end end
end end
end end
function printToMon(mon, text) function printToMon(mon, text)
local x, y = mon.getCursorPos() local x, y = mon.getCursorPos()
mon.write(text) mon.write(text)
mon.setCursorPos(x, y+1) mon.setCursorPos(x, y+1)
end end
return utils return utils