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

print peritheral.getMethods()

Started by Duster, 30 March 2016 - 07:46 PM
Duster #1
Posted 30 March 2016 - 09:46 PM

methods = peripheral.getMethods("back")
print(methods)
it just outputs "table: 1d4c509e"
how do i make it output all the methods and not just a string of rsandom #s
Dog #2
Posted 30 March 2016 - 09:51 PM
If you're trying to do this from the lua prompt, simply typing peripheral.getMethods("back") will return the methods for you. Otherwise, you'll need to iterate through the table returned, like so…

local methods = peripheral.getMethods("back")
for k, v in pairs(methods) do
  print(k .. " / " .. v)
end
KingofGamesYami #3
Posted 30 March 2016 - 09:52 PM
Either iterate through the table, printing each element, or serialize the table.

Edit: ninja'd
Edited on 30 March 2016 - 07:52 PM
Duster #4
Posted 30 March 2016 - 10:02 PM
If you're trying to do this from the lua prompt, simply typing peripheral.getMethods("back") will return the methods for you. Otherwise, you'll need to iterate through the table returned, like so…

local methods = peripheral.getMethods("back")
for k, v in pairs(methods) do
  print(k .. " / " .. v)
end

thx.

Also This Is Not related But Can I Scroll Up In A Terminal?
Dog #5
Posted 30 March 2016 - 11:08 PM
Also This Is Not related But Can I Scroll Up In A Terminal?
I don't believe there's a way to scroll up in the default terminal, but I could be wrong.