ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: flowfy on Jul 16, 2020, 11:39 AM

Title: Move a turtle
Post by: flowfy on Jul 16, 2020, 11:39 AM
Hello
I'm trying to write my first turtle program and need to know two things.
Maybe someone could easily answer my questions.
My first question is:
My turtle have to move forward a couple of blocks. So far I just write turtle.forward() so many times that I want the turtle to move.
Is there an easier way to do that?
And my second question:
My turtle have to set a block under her and to Redstone power the block
Setting the block is mo problem, but how do I set the direction with the command setredstoneOutput()

I hope my english is understandable
Greetings
Title: Move a turtle
Post by: Lupus590 on Jul 16, 2020, 05:58 PM
For moving, you want to use a loop. In this case a for loop (https://www.lua.org/pil/4.3.4.html) will be best.

As for redstone, have you checked the wiki (https://wiki.computercraft.cc/Redstone_API)?
Title: Move a turtle
Post by: flowfy on Jul 16, 2020, 08:50 PM
I have some trouble with the Redstone.getoutput command
Can you give me an example what I have to add to this command do set the signal to the bottom side of the turtle?
Title: Move a turtle
Post by: Lupus590 on Jul 16, 2020, 10:24 PM
You want the setOutput command, not the getOutput one.
Title: Move a turtle
Post by: QuickMuffin8782 on Aug 15, 2020, 07:54 PM
rs.getOutput("<side>") is entirely different as it returns the redstone level on the given side.
rs.setOutput("<side>", <level int - 0 to 15 limit>) can set the redstone output.
Title: Move a turtle
Post by: Lupus590 on Aug 15, 2020, 11:04 PM
Quote from: QuickMuffin8782 on Aug 15, 2020, 07:54 PMrs.getOutput("<side>") is entirely different as it returns the redstone level on the given side.
Adding to this, getOutput is different from getInput as one gives the redstone value that the computer is emitting and the other is what it's receiving. Honestly, I don't know why getOutput exists other than for backwards compatibility at this point. I seem to remember that the two get's can return different values so they must mean different things (I think it was when two computers were next to each other pushing redstone signals to each other if someone wants to experiment).