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

Magnet Turtle

Started by THE_FACELESS_ONE, 01 October 2014 - 10:09 PM
THE_FACELESS_ONE #1
Posted 02 October 2014 - 12:09 AM
I'm playing on the yogscast complete pack and trying to use the magnet turtle for a small project but i can't understand how to use it, i've got all the commands but everytime i try to run them it returns a nil value, any help would be appreciated. the commands i've tried running are magnet.activate(left) and peripheral.activate(left) and also with left in quotes.

please help, and please don't link me to this topic, i've already read it…
Bomb Bloke #2
Posted 02 October 2014 - 03:36 AM
First you'd want to wrap the peripheral, then you'd want to activate it:

local magnet = peripheral.wrap("left")  -- Assuming the magnet is to the turtle's left.

if magnet.isAboveEntity() then
  print("I should be above something I can grab. Grabbing....")
  magnet.activate()
  if magnet.isGrabbing() then
    print("Grabbed!")
  else
    print("Failure...")
  end
else
  print("I'm not above something I can grab.")
end

You may find this guide useful when dealing with peripherals.
THE_FACELESS_ONE #3
Posted 02 October 2014 - 05:55 PM
Thanks for replying, i understand now how to run the commands but i can't seem to understand how they work… could you please explain them for me?

i have this list:
i used the "getMethods" command but i don't understand what anything actually does :/ i can't really use the magnet at the moment…
THE_FACELESS_ONE #4
Posted 02 October 2014 - 05:59 PM
i should probably be specific and point out that i want to use it to move a block…
Bomb Bloke #5
Posted 03 October 2014 - 02:58 AM
I've not used the magnet myself.

My assumption is that you move the turtle directly over the block you want, activate the magnet, move the turtle over where you want the block to go, then deactivate the magnet. It sounds like the magnet can pick up blocks which are a few spaces below it.

It may be the case that the magnet doesn't work on blocks, but instead only on dropped items, or on mobs. Dunno.

OpenPeripheral's documentation can be accessed by running a script with the side of the peripheral you want to query:

openp/docs <side>

For specific info on a function, you'd then enter:

openp/docs <side> <functionName>

If you're lucky, this'll give you more info about the activate/deactivate functions than pointless stuff such as "activates/deactivates the magnet". Try it and see, anyway.