Posted 18 March 2013 - 12:06 PM
Title: math problems
so my problem is how can i tell how many percent of work is done?
e.g.
you gave your turtle two numbers (length, width) and his job is to walk all around a square (like the excavate program except it doesn't mine blocks) can I use the two numbers given to the computer to tell how many percent of work is done and send that percent to another computer ( via rednet ). if so can anyone help me?
btw here's the code:
so my problem is how can i tell how many percent of work is done?
e.g.
you gave your turtle two numbers (length, width) and his job is to walk all around a square (like the excavate program except it doesn't mine blocks) can I use the two numbers given to the computer to tell how many percent of work is done and send that percent to another computer ( via rednet ). if so can anyone help me?
btw here's the code:
local wlk = { ... }
local length, width = tonumber(wlk[1]), tonumber(wlk[2])
if #wlk ~= 2 or type(length) ~= "number" or type(width) ~= "number" then --checking user'sInput
print( "use the program properly!" )
return
end
local function walkLength() --move forward for (length) times
for i = 2, length do
turtle.forward()
end
end
face = 0
local function altTurn() --alternating turn (left, left),(right, right)
if face < 2 then
face = face+1
turtle.turnLeft()
elseif face == 2 then
face = face+1
turtle.turnRight()
else
face = 0
turtle.turnRight()
end
end
local cWidth = 0
turtle.turnRight()
while width ~= cWidth do
walkLength()
cWidth = cWidth+1
if width ~= cWidth then -- rechecking
altTurn()
turtle.forward()
altTurn()
end
end