Jump to content




openperipherials sensor help


  • You cannot reply to this topic
1 reply to this topic

#1 DotaCross

  • New Members
  • 1 posts

Posted 27 February 2015 - 10:38 PM

I'm fairly new to CC programming from scratch, most my experiance is with adapting basic programs to fit my needs so bare with me. I'm trying to design a simple program that looks for nearby players and prints the list to a monitor, however I'm having a hard time understanding the new syntax for the sensor.getPlayers. It outputs a table, however the table is always returned as something like "table: 6beec85", my question is how do you translate the table into names, or is there a better method that I'm just not seeing?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 28 February 2015 - 12:00 PM

for key, value in pairs(myTable) do
  print(key..": "..tostring(value))
end

Let's say you did this, and discovered that there's a sub-table in your first table with eg a key-name of "inventory", or somesuch. You'd then iterate through that:

for key, value in pairs(myTable.inventory) do
  print(key..": "..tostring(value))
end

... and so on.

If you're still stuck, post the code you're using.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users