Posted 20 March 2012 - 04:07 PM
hey i got a little problem
i am making a little shape make script with turtles. but when i tried to test it i came across a problem whenever i try to make a square it ask's me the question what size vertical?
this question belongs to the retangle and not the the square. i think i need to fix it with functions but i don't know how to use them.
here is the code:
print(" shape maker 1.0 beta build made by michiel")
print("what shoud i make?(choose between retangle, triangle, square or rhomedros)")
local choise = io.read()
if choise == "retangle" then
print(" What size horiozontaly?")
sleep(2)
h = io.read()
h = tonumber(h)
end
print("what size vertical?")
v = io.read()
v = tonumber(v)
if h <= 0 then
print("error it can not be 0")
end
if v <= 0 then
print("error it can not be 0")
end
if turtle.detectDown()then
turtle.up()
end
for i=1,v do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
for i=1,v do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
os.shutdown()
if choise == "square" then
print("how long does it need to be?")
end
local s = io.read()
local x = s-1
s = tonumber(s)
x = tonumber(x)
if s <= 0 then
print("error length can not be 0")
sleep(2)
end
if turtle.detectDown()then
turtle.up()
end
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,x do
print(i)
turtle.placeDown()
turtle.forward()
end
os.shutdown()
anyway sorry for taking your time and i promiss this will be my last stupid question. so bye bye and already thank you
michiel
i am making a little shape make script with turtles. but when i tried to test it i came across a problem whenever i try to make a square it ask's me the question what size vertical?
this question belongs to the retangle and not the the square. i think i need to fix it with functions but i don't know how to use them.
here is the code:
print(" shape maker 1.0 beta build made by michiel")
print("what shoud i make?(choose between retangle, triangle, square or rhomedros)")
local choise = io.read()
if choise == "retangle" then
print(" What size horiozontaly?")
sleep(2)
h = io.read()
h = tonumber(h)
end
print("what size vertical?")
v = io.read()
v = tonumber(v)
if h <= 0 then
print("error it can not be 0")
end
if v <= 0 then
print("error it can not be 0")
end
if turtle.detectDown()then
turtle.up()
end
for i=1,v do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
for i=1,v do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
os.shutdown()
if choise == "square" then
print("how long does it need to be?")
end
local s = io.read()
local x = s-1
s = tonumber(s)
x = tonumber(x)
if s <= 0 then
print("error length can not be 0")
sleep(2)
end
if turtle.detectDown()then
turtle.up()
end
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,s do
print(i)
turtle.placeDown()
turtle.forward()
end
turtle.back()
turtle.turnRight()
for i=1,x do
print(i)
turtle.placeDown()
turtle.forward()
end
os.shutdown()
anyway sorry for taking your time and i promiss this will be my last stupid question. so bye bye and already thank you
michiel