This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Epicmonkeydude's profile picture

HELP programming

Started by Epicmonkeydude, 15 December 2012 - 09:13 PM
Epicmonkeydude #1
Posted 15 December 2012 - 10:13 PM
It says I need to have a do command when it's already there. Please can you HELP me. Thank you


function Mine()
   turtle.dig()
   turtle.digDown()
   turtle.digUp()
   turtle.turnLeft()
   turtle.dig()
   turtle.turnRight()
   turtle.turnRight()
   turtle.dig()
   turtle.turnLeft()
   turtle.forward()
end
-- Gets how many times to repeat Mine()
local a = 1
local c = 1
print("How many times would you like to complete the process?")
local b = tostring( read())
-- 'while a = 1 do' says expected 'do'
while a = 1 do
   for c = 1,b do
	  Mine()
   end
   if c = b then
	  a = a+1
   end
end
KaoS #2
Posted 15 December 2012 - 10:19 PM
you need another =
while a == 1 do
theoriginalbit #3
Posted 15 December 2012 - 10:28 PM
It says I need to have a do command when it's already there. Please can you HELP me. Thank you


function Mine()
   turtle.dig()
   turtle.digDown()
   turtle.digUp()
   turtle.turnLeft()
   turtle.dig()
   turtle.turnRight()
   turtle.turnRight()
   turtle.dig()
   turtle.turnLeft()
   turtle.forward()
end
-- Gets how many times to repeat Mine()
local a = 1
local c = 1
print("How many times would you like to complete the process?")
local b = tostring( read())
-- 'while a = 1 do' says expected 'do'
while a = 1 do
   for c = 1,b do
	  Mine()
   end
   if c = b then
	  a = a+1
   end
end

I think you may come across some issues with the variable naming conflict on c

can i suggest you change it to this
Spoiler

local function Mine()
   turtle.dig()
   turtle.digDown()
   turtle.digUp()
   turtle.turnLeft()
   turtle.dig()
   turtle.turnRight()
   turtle.turnRight()
   turtle.dig()
   turtle.turnLeft()
   turtle.forward()
end

-- Gets how many times to repeat Mine()
print("How many times would you like to complete the process?")
local times = tostring(read())

for i = 1, times do
	  Mine()
end

unless I've understood your intentions with the variables a and c neither of them are actually needed.
Epicmonkeydude #4
Posted 15 December 2012 - 10:34 PM
Thanks guys from this I can actually correct multiple of my programs :D/>