This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ErlangPriest's profile picture

Cannot print getMethods table from playerDetector peripheral

Started by ErlangPriest, 12 July 2013 - 07:09 AM
ErlangPriest #1
Posted 12 July 2013 - 09:09 AM
Title: Cannot print getMethods table from playerDetector peripheral

Hi,

I'm helping my son to learn how to program in CC, but we have run into a problem.

We want to list all methods of a peripheral with this code:

m=peripherals.getMethod("left")
for i,v in pairs(m) do print(i..": "..v) end

This works perfectly for all other peripherals.

Cheers,
Torben
Cranium #2
Posted 12 July 2013 - 11:13 AM
Split into new topic.

First of all, I would like to welcome you to the forums, and I congratulate you for wanting to teach your children useful skills they can use in the future. Good on ya!
Engineer #3
Posted 12 July 2013 - 01:16 PM
The problem is, that the player detector doesnt have any methods. All it does is queue an event when someone right clicks it.
To catch that event:
local event, player = os.pullEvent( "player" )
ErlangPriest #4
Posted 13 July 2013 - 02:33 PM
I'm already getting behind on this… my son sort of guessed at this after playing some more around and now we have the evidence!

Thanks for the explanation - now we can continue working with peripherals.

So far ComputerCraft has been the most motivational intro for my son into the world of programming, so I'm grateful for the work done here.

Thanks,
Torben