Jump to content




peripheral.getMethods() help


  • You cannot reply to this topic
6 replies to this topic

#1 jewelshisen

  • Members
  • 164 posts

Posted 20 January 2013 - 04:11 AM

Every time i try to run peripheral.getMethods() on an ICBMLauncher it just returns "table: 502cb323" or something like that. Am i doing something wrong?

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 January 2013 - 04:15 AM

no this is correct... peripheral.getMethods() returns a table of all the methods you can call on the peripheral... to look at these functions names just do this

for k,_ in pairs( peripheral.getMethods( side ) ) do
  print( k )
end


#3 jewelshisen

  • Members
  • 164 posts

Posted 20 January 2013 - 04:19 AM

Oh... ok then.

#4 ChunLing

  • Members
  • 2,027 posts

Posted 20 January 2013 - 04:36 AM

To actually use those methods, you'll need to assign the table:
local tpm = peripheral.getMethods(side)
for k in pairs(tpm) do
  print(k)
end
Use tpm.methodName() to call the method listed as methodName (or tpm.whatever() to call whatever).

Edited by ChunLing, 20 January 2013 - 04:36 AM.


#5 jewelshisen

  • Members
  • 164 posts

Posted 20 January 2013 - 04:43 AM

Ok new problem. The methods are all just numbers. So how do I use it?

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 January 2013 - 04:49 AM

View Postjewelshisen, on 20 January 2013 - 04:43 AM, said:

Ok new problem. The methods are all just numbers. So how do I use it?
is that using the loop? if it is make this change
for _, v in pairs( peripheral.getMethods( side ) ) do
  print( v )
end
that will get you the method names.... i forgot that ICBM has their methods thing done wrong...

EDIT:
how all peripherals react with the getMethods...
{ function name, the actual function! }

how ICBM reacts with the getMethods...
{ function name }

it doesn't actually get the methods, it gets their name...... stupid ICBM devs...

Edited by TheOriginalBIT, 20 January 2013 - 04:51 AM.


#7 jewelshisen

  • Members
  • 164 posts

Posted 20 January 2013 - 04:59 AM

Yes! Got it working now!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users