From 38b5f70f2aa8c05d8eff91b8ef4d97c659700c6f Mon Sep 17 00:00:00 2001 From: Hadinos Sanosam Date: Tue, 12 Jan 2021 01:41:11 +0100 Subject: [PATCH] Fixed whitespace --- react | 20 ++++++++++---------- reactLamp | 4 ++-- recv_file | 8 ++++---- send_file | 10 +++++----- utils | 20 ++++++++++---------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/react b/react index 6d507be..c0d9a58 100644 --- a/react +++ b/react @@ -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 diff --git a/reactLamp b/reactLamp index c7d8b52..26639da 100644 --- a/reactLamp +++ b/reactLamp @@ -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 diff --git a/recv_file b/recv_file index 85e51f8..8c76b9a 100644 --- a/recv_file +++ b/recv_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 .. "' !") diff --git a/send_file b/send_file index 16a4487..6a6c340 100644 --- a/send_file +++ b/send_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! diff --git a/utils b/utils index a8080dc..074daac 100644 --- a/utils +++ b/utils @@ -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