Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mLast = 0
- function start(side)
- while true do
- pcall(function()
- local d = http.get("http://azelk.net84.net/get.php")
- local un = textutils.unserialize(d.readAll())
- d.close()
- if un[pid] ~= mLast then
- os.queueEvent("modem_message", side, tonumber(un.channel) or 0, tonumber(un.id) or 1, tostring(un.message))
- end
- mLast = un[pid]
- end)
- end
- end
- function send(channel, id, message)
- http.post("http://azelk.net84.net/send.php", "message=" .. textutils.serialize({channel = channel, id = id, message = message}))
- end
- local opw = peripheral.wrap
- local opc = peripheral.call
- function peripheral.wrap(side)
- local p = opw.wrap(side)
- if peripheral.getType(side) == "modem" then
- p.transmit = send
- end
- return p
- end
- function peripheral.call(side, ...)
- if peripheral.getType(side) == "modem" then
- local tb = {...}
- if tb[1] == "transmit" then
- table.remove(tb, 1)
- return send(unpack(tb))
- else
- table.insert(tb, 1, side)
- return opc(unpack(tb))
- end
- else
- local tb = {...}
- table.insert(tb, 1, side)
- return opc(unpack(tb))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement