Posted 11 September 2012 - 05:50 AM
Hello!
My calculator is working fine.
I am trying to use a program to build a custom house using length, width, and heighth. However, something is wrong with my length. Lets say I input length=3. That would normally dig a 1x3 column and would fill the hole with blocks. However, instead my program keeps doubling the length, im not sure why though. Please tell me what I did wrong. I tried seeing if I accidentaly changed the length later in the code by accident, but I didn't see any problems. I only used the length method, but I never changed it.
Heres the code
My calculator is working fine.
I am trying to use a program to build a custom house using length, width, and heighth. However, something is wrong with my length. Lets say I input length=3. That would normally dig a 1x3 column and would fill the hole with blocks. However, instead my program keeps doubling the length, im not sure why though. Please tell me what I did wrong. I tried seeing if I accidentaly changed the length later in the code by accident, but I didn't see any problems. I only used the length method, but I never changed it.
Heres the code
function iGotEnough()
if response=="yes" then
print("Initiating building stage")
Build()
end
if response=="no" then
print("OK, stopping program")
end
end
function TrueRemainder()
if q==1 then
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
turtle.forward()
if q==2 then
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.forward()
end
end
end
function Total()
l=length-1
w=width-1
h=heighth-1
base1=2*(w*h)
base2=2*(l*h)
floorandroof=2*(length*width)
total=base1+base2+floorandroof
print("I need "..total.." blocks to make a house with these dimensions")
end
function getTotalItemCount()
local a="I currently have "
local b=" blocks"
ItemAmount=0
for f=1,16 do
ItemAmount=ItemAmount+turtle.getItemCount(f)
end
print()
print(a..ItemAmount..:D/>/>
end
function RequiredAmount()
if ItemAmount >= total then
write("I have enought blocks to build, proceed?:")
response=read()
iGotEnough()
end
if ItemAmount < total then
print("I don't have enough blocks, please insert the correct amount of blocks and run this program again.")
end
end
function ReadyUp()
print("All sides must exceed 2")
write("Enter Length:")
length=read()
write("Enter Width:")
width=read()
write("Enter Heighth:")
heighth=read()
end
function FloorAndRoof()
for n=1,length do
turtle.digDown()
turtle.placeDown()
turtle.forward()
end
end
function Build()
FloorAndRoof()
end
ReadyUp()
Total()
getTotalItemCount()
RequiredAmount()
Build()