Advertisement
cul8ter

Untitled

Oct 14th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. local plr=peripheral.wrap("back")
  2. local mod=peripheral.find("modem")
  3. local addrs=dofile("addrs.lua")
  4. local function dial(addr)
  5. --plr.tell(addr)
  6. mod.open(1337)
  7. mod.transmit(555,1337,addrs[addr] or addr)
  8. local tid=os.startTimer(1)
  9. repeat
  10. name,evid,port,_,msg=os.pullEvent()
  11. until (name=="timer" and evid==tid) or (name=="modem_message" and port==1337)
  12. if msg then plr.tell(msg) end
  13. mod.close(1337)
  14. end
  15. local function main()
  16. while true do
  17. local _,msg=os.pullEvent("chat_capture")
  18. print(msg)
  19. plr.tell(msg)
  20. if string.find(msg,"%.dial") then
  21. _,cend=string.find(msg,"%.dial")
  22. dial(string.sub(msg,cend+2,-1))
  23. elseif string.find(msg,"%.auth")
  24. _,cend=string.find(msg,"%.dial")
  25. mod.transmit(555,1337,{"auth",string.sub(msg,cend+2,-1)
  26. end
  27. end
  28. end
  29. plr.capture("^%.")
  30. local _,err=pcall(main)
  31. plr.uncapture("^%.")
  32. error(err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement