jc2xs

Get Sensor Data

Nov 4th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local sensor = peripheral.wrap("top")
  2. local players = sensor.getPlayers()
  3. for k, v in pairs(players) do --# start a generic loop
  4.   print(k , " / " , v) --# print each key/value pair in the table
  5.   if type(v) == "table" then --# if the value is another table, then iterate though that table
  6.     for i, n in pairs(v) do --# start another generic loop
  7.       print(i , " / " , n) --# print each key/value pair in the table
  8.     end
  9.   end
  10. end
  11.  
  12. pdata = sensor.getPlayerByName("jc2xs").basic().position
  13. for k, v in pairs(pdata) do --# start a generic loop
  14.   print(k , " / " , v) --# print each key/value pair in the table
  15.   if type(v) == "table" then --# if the value is another table, then iterate though that table
  16.     for i, n in pairs(v) do --# start another generic loop
  17.       print(i , " / " , n) --# print each key/value pair in the table
  18.     end
  19.   end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment