Advertisement
Guest User

listplayers

a guest
Oct 20th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1.  
  2. -- Variabelen
  3. local sensor = peripheral.wrap("top")
  4. local monitor = peripheral.wrap("left")
  5. local modem = peripheral.wrap("right")
  6. local modemPort = 6       --unieke poort voor wissellocatie
  7. local mainFramePort = 5   --poort van mainframe
  8. local messagestore = 0
  9.  
  10. -- Startcode
  11. modem.open(modemPort)
  12.  
  13.  
  14. -- Whilecode
  15. while true do
  16.  nearusers = sensor.getPlayerNames()
  17.  print("Nearby User: ", nearusers[1])
  18.  
  19.  if nearusers[1] ~= nil then
  20.     modem.transmit(mainFramePort,modemPort,nearusers[1])
  21.  
  22.     local event, ModemSide, senderChannel, replyChannel,
  23.           message, senderDistance = os.pullEvent("modem_message")
  24.     print("switch information recieved on port ", senderChannel)
  25.     print("switch number is ", message)
  26.     messagestore=message
  27.  end
  28.  
  29.  if messagestore == 1 then
  30.   --Destination 1
  31.     print("setting for destination 1")
  32.  elseif messagestore == 2 then
  33.   --Destination 2
  34.     print("setting for destination 2")
  35.  elseif messagestore == 3 then
  36.   --Destination 3
  37.     print("setting for destination 3")
  38.  elseif messagestore == 4 then
  39.   --Destination 4
  40.     print("setting for destination 4")
  41.  else
  42.   --Geen mensen in de buurt
  43.    print("no destinations nearby")
  44.  end
  45.  
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement