Advertisement
Alakazard12

lel

Jan 25th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local mLast = 0
  2.  
  3. function start(side)
  4. while true do
  5. pcall(function()
  6. local d = http.get("http://azelk.net84.net/get.php")
  7. local un = textutils.unserialize(d.readAll())
  8. d.close()
  9. if un[pid] ~= mLast then
  10. os.queueEvent("modem_message", side, tonumber(un.channel) or 0, tonumber(un.id) or 1, tostring(un.message))
  11. end
  12. mLast = un[pid]
  13. end)
  14. end
  15. end
  16.  
  17. function send(channel, id, message)
  18. http.post("http://azelk.net84.net/send.php", "message=" .. textutils.serialize({channel = channel, id = id, message = message}))
  19. end
  20.  
  21. local opw = peripheral.wrap
  22. local opc = peripheral.call
  23.  
  24. function peripheral.wrap(side)
  25. local p = opw.wrap(side)
  26. if peripheral.getType(side) == "modem" then
  27. p.transmit = send
  28. end
  29.  
  30. return p
  31. end
  32.  
  33. function peripheral.call(side, ...)
  34. if peripheral.getType(side) == "modem" then
  35. local tb = {...}
  36. if tb[1] == "transmit" then
  37. table.remove(tb, 1)
  38. return send(unpack(tb))
  39. else
  40. table.insert(tb, 1, side)
  41. return opc(unpack(tb))
  42. end
  43. else
  44. local tb = {...}
  45. table.insert(tb, 1, side)
  46. return opc(unpack(tb))
  47. end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement