Are you using this code?
side ntoe: use [
code][
/code] tags
Something like this would do it
local args = {...} -- this gets the runtime args as long as its not in a function
local height = tonumber(args[1])
local width = tonumber(args[2])
for i = 1, height do
for x = 1, 4 do -- we have 4 sides
for y = 1, width - 1 do -- we need to -1 so it lines up and is the actual width
turtle.forward()
turtle.placeDown()
turtle.turnRight()
end
end
turtle.up()
end
There are a number of places where you could mess this up. What is your exact error?
A missing tonumber() wouldn't really matter, since both for parameters and arithmetic automatically tonumber (but it is better style to tonumber things if they're numbers). Your previous error must have been because you didn't supply all the necessary command line parameters…you can put in a default value by editing those lines like so:
local height = tonumber(args[1]) or 5 --default height value
local width = tonumber(args[2]) or 3 --default width value
That way if you omit a command line parameter (or supply something that isn't convertible to number) the program doesn't error.
Anyway, you need to post the exact code you're using and the exact error (or other unexpected behavior) you're seeing. Don't just keep saying "it doesn't work". We have no real idea what "it" is, and we have no idea what "doesn't work" means.
Looking over this code, it does indeed seem odd. It should be:
local args = {...}
local height = tonumber(args[1]) or 5
local width = tonumber(args[2]) or 3
for i = 1, height do
for x = 1, 4 do
for y = 1, width-1 do
turtle.forward()
turtle.placeDown()
end
turtle.turnRight()
end
turtle.up()
end
The other code would have produced a 2x2 tower…in time…with a lot of running around in circles (okay, tight squares).