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

peripheral.getMethods() help

Started by jewelshisen, 20 January 2013 - 03:11 AM
jewelshisen #1
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?
theoriginalbit #2
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
jewelshisen #3
Posted 20 January 2013 - 04:19 AM
Oh… ok then.
ChunLing #4
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 on 20 January 2013 - 03:36 AM
jewelshisen #5
Posted 20 January 2013 - 04:43 AM
Ok new problem. The methods are all just numbers. So how do I use it?
theoriginalbit #6
Posted 20 January 2013 - 04:49 AM
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 on 20 January 2013 - 03:51 AM
jewelshisen #7
Posted 20 January 2013 - 04:59 AM
Yes! Got it working now!