Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getmodems(mode)
- mode = mode or "default"
- if mode == "default" then
- allp = peripheral.getNames()
- d = {}
- x = 0
- for i,value in ipairs(allp) do
- c = peripheral.getType(value)
- if c == "modem" then
- c = peripheral.wrap(value)
- x = x + 1
- d[x] = c
- end
- end
- d["a"] = x
- d["amount"] = x
- return d
- elseif mode == "sides" or mode =="s" then
- allp = peripheral.getNames()
- d = {}
- x = 0
- for i,value in ipairs(allp) do
- c = peripheral.getType(value)
- if c == "modem" then
- x = x + 1
- d[x] = value
- end
- end
- d["a"] = x
- d["amount"] = x
- return d
- end
- end
- function getmsg()
- while true do
- d = {}
- event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message")
- d["e"] = event
- d["s"] = side
- d["f"] = frequency
- d["rf"] = replyFrequency
- d["m"] = message
- d["d"] = distance
- return d
- end
- end
- function transmitall(p,rp,message)
- modems = getmodems()
- print(modems["a"])
- if modems["a"] == 0 then else
- for modem = 1,modems["a"] do
- cm = modems[modem]
- cm.transmit(p,rp,message)
- end
- end
- end
- function relay(p,rp,message,exclude)
- sides = getmodems("s")
- if modems["a"] == 0 then else
- for side = 1,modems["a"] do
- cs = sides[side]
- if cs == exclude then else
- cm.transmit(p,rp,message)
- end
- end
- end
- end
- modems = getmodems()
- for modemc = 1, modems["a"] do
- modems[modemc].open(313)
- end
- doormodem = peripheral.wrap("back")
- d = {}
- while true do
- msg = getmsg()
- msgm = msg["m"]
- if msgm == "oa1" then
- d["password"] = "openaxelsnygg"
- doormodem.transmit(313,313,d)
- elseif msgm == "ca1" then
- d["password"] = "closeaxelsnygg"
- doormodem.transmit(313,313,d)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement