turtle.refuel()
print("turtle refuele")
print("Length:")
n=io.read()
print("Width:")
i=io.read()
print("Hight:")
j=io.read()
j=j+1
print(n)
print(i)
print(j)
turtle.forward(n)
turtle.placeDown(n)
turtle.turnLeft()
turtle.forward(i)
turtle.placeDown(i)
turtle.turnLeft()
turtle.forward(n)
turtle.placeDown(n)
turtle.turnLeft()
turtle.forward(i)
turtle.placeDown(i)
turtle.turnLeft()
turtle.up(j)
turtle.placeDown(j)
turtle.forward(n)
turtle.placeDown(n)
turtle.turnLeft()
turtle.forward(i)
turtle.placeDown(i)
turtle.turnLeft()
turtle.forward(n)
turtle.placeDown(n)
turtle.turnLeft()
turtle.forward(i)
turtle.placeDown(i)
turtle.turnLeft()
turtle.back()
turtle.down(j)
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Cube Outline
Started by kmtompkins, 03 September 2014 - 12:56 AMPosted 03 September 2014 - 02:56 AM
the turtle only moves 1 block for all the moves when it should be moving the given number. if i input 3, 3, 3 it still moves 1, 1, 1 even though the variable is changed.
Posted 03 September 2014 - 03:31 AM
Your problem here is that all of your turtle functions you're using do not support arguments and as such doing turtle.forward(599123158) and turtle.forward(2) will both move the turtle forward one block.
Posted 03 September 2014 - 03:39 AM
so… how would i make it so the turtle goes the set blocks.
Posted 03 September 2014 - 03:40 AM
Have a look at the Turtle API
Posted 03 September 2014 - 03:53 AM
I looked through the turtle API i did not see anything that would allow it to move multiple blocks dis I miss anything
Is it possible that I could use the variables of the lengths to create a loop that make it loop the movement command x amount of times and x being the amount of blocks I want to move for that side.
Is it possible that I could use the variables of the lengths to create a loop that make it loop the movement command x amount of times and x being the amount of blocks I want to move for that side.
Posted 03 September 2014 - 04:07 AM
I looked through the turtle API i did not see anything that would allow it to move multiple blocks dis I miss anything
Is it possible that I could use the variables of the lengths to create a loop that make it loop the movement command x amount of times and x being the amount of blocks I want to move for that side.
Absolutely!
function TurtleForward(HowManyTimesIWannaMove) --# Example
for i=1,HowManyTimesIWannaMove do
turtle.forward()
end
end
Posted 03 September 2014 - 04:20 AM
I think that as he's wanting to also place blocks every time he moves it needs to beI looked through the turtle API i did not see anything that would allow it to move multiple blocks dis I miss anything
Is it possible that I could use the variables of the lengths to create a loop that make it loop the movement command x amount of times and x being the amount of blocks I want to move for that side.
Absolutely!function TurtleForward(HowManyTimesIWannaMove) --# Example for i=1,HowManyTimesIWannaMove do turtle.forward() end end
function TurtleForward(HowManyTimes)
for 1,HowManyTimes do
turtle.forward()
turtle.placeDown()
end
end
Posted 03 September 2014 - 04:54 AM
I set up a test program to test it independently but I cant get it to move at all
n=Io.read()
function TurtleForward(n)
For n=1,n do
turtle.forward()
turtle.placeDown()
end
end
Posted 03 September 2014 - 05:03 AM
I'm surprised your Io.read() works (it should be io.read - lower case).
You need to call your function to make it do its work. Put this at the end of your code…
A couple other things you should consider are localizing your variables and functions and changing the variables you are using in your function (instead of trying to re-use n for different purposes). Like so…
Hope that helps :)/>
You need to call your function to make it do its work. Put this at the end of your code…
TurtleForward(n)
A couple other things you should consider are localizing your variables and functions and changing the variables you are using in your function (instead of trying to re-use n for different purposes). Like so…
local n = io.read()
local function TurtleForward()
for i = 1,n do
turtle.forward()
turtle.placeDown()
end
end
TurtleForward()
Hope that helps :)/>
Edited on 03 September 2014 - 03:04 AM
Posted 03 September 2014 - 05:15 AM
He's going to use that for length and width, so using n inside the function wouldn't work well. he'd have to call the function i put up earlier with TurtleForward(n) and TurtleForward(i)I'm surprised your Io.read() works (it should be io.read - lower case).
You need to call your function to make it do its work. Put this at the end of your code…TurtleForward(n)
A couple other things you should consider are localizing your variables and functions and changing the variables you are using in your function (instead of trying to re-use n for different purposes). Like so…local n = io.read() local function TurtleForward() for i = 1,n do turtle.forward() turtle.placeDown() end end TurtleForward()
Hope that helps :)/>
Edited on 03 September 2014 - 03:26 AM
Posted 03 September 2014 - 05:20 AM
Thanks for the clarification, Dragon. fwiw, I was just helping get the test program straightened out. Once that's done and he's ready to tackle the whole thing we'll be here :)/>