datdenkikniet

Chat program

Dec 16th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sides = {}
  2. sides[0] = "left"
  3. sides[1] = "right"
  4. sides[2] = "up"
  5. sides[3] = "down"
  6. sides[4] = "front"
  7. sides[5] = "back"
  8. chatID = { ... }
  9. function length(t)
  10. local c = 0
  11. for k,v in pairs(t) do
  12. c=c+1
  13. end
  14. return c
  15. end
  16. local hasOpenSides = false
  17. count = length(chatID)
  18. if count == 1 then
  19. for i=0,5 do
  20. if peripheral.isPresent(sides[i]) then  
  21. rednet.open(sides[i])
  22. hasOpenSides = true
  23. end
  24. end
  25. if hasOpenSides then
  26. rednet.send(chatID[0], "authentication!!!!")
  27. print("starting the chat!")
  28. else
  29. print("no modems attached!")
  30. end
  31. else
  32. print("it didn't work!!")
  33. end
Advertisement
Add Comment
Please, Sign In to add comment