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)
local modemSide = utils.getSideOf("modem")
if modemSide then --not nil
rednet.open(modemSide)
lampID = rednet.lookup("reactLamp", "reactLamp")
rednet.open(modemSide)
lampID = rednet.lookup("reactLamp", "reactLamp")
end
print("Monitoring reactor...")
@ -89,15 +89,15 @@ do
mon.setCursorPos(1, 5)
mon.write("REFUEL!")
--send fuel state to lamp
if lampID then --not nil: rednet present and found lamp!
rednet.send(lampID, "1", "reactLamp")
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
if lampID then
rednet.send(lampID, "0", "reactLamp")
end
end
sleep(1)
end

View File

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

View File

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

View File

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

20
utils
View File

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