Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local serialization = require("serialization")
- -- local r = component.proxy(component.list("redstone")())
- local m = component.proxy(component.list("modem")())
- local own_name = "fc_rice"
- m.open(102)
- function isInt(n)
- return type(n) == "number" and math.floor(n) == n
- end
- function validateSide(side)
- return is_int(side) and side > -1 and side < 6
- end
- function validateStrenght(strength)
- return is_int(strength) and strength > -1
- end
- function checkName(instruction)
- return (instruction.name ~= nil and (instruction.name == "*" or instruction.name == own_name))
- end
- function parseInstruction(instruction)
- if (not checkName(instruction)) then return end
- print("Message is for me")
- end
- while true do
- local signal_type, localAddress, remoteAddress, port, distance, instruction = computer.pullSignal()
- if (signal_type == "modem_message") then
- print(signal_type)
- if (instruction ~= nil) then
- instruction = serialization.unserialize(instruction)
- print("Hey")
- print(instruction)
- print(instruction.name)
- if (type(instruction) == "table") then
- parseInstruction(instruction)
- end
- end
- end
- -- if is_int(side) and is_int(mode) and side > -1 and side < 6 and mode > -1 and mode < 2 then
- -- r.setOutput(side, mode)
- -- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement