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

when i = nTimes?

Started by twiinkee, 15 December 2012 - 04:17 AM
twiinkee #1
Posted 15 December 2012 - 05:17 AM
Sorry if im just stupid for asking this but i cant figure it out, becouse im new with lua.

i have "written" an turtle program:


local args = { ... }
local times = args[1]
local nTimes = tonumber(args[1])
local slotNum = 2
local function checkslot()
turtle.select(slotNum)
if turtle.getItemCount(slotNum) < 1 then
slotNum = slotNum + 1
end
end
for i = 1, nTimes do
checkslot()
turtle.forward()
turtle.placeDown()
end


But after the last end i want the turtle to do something more. how do i do that?
bjornir90 #2
Posted 15 December 2012 - 05:26 AM
You just have to add code after it … I must misunderstood…
theoriginalbit #3
Posted 15 December 2012 - 05:29 AM
put this inside the for loop


if i == nTimes then
  -- do what you want here
end
theoriginalbit #4
Posted 15 December 2012 - 05:32 AM
can I ask what this code on your turtle is actually doing? It seems to me that it is checking the slots from 2 through to the provided number to see if they are empty is this correct? And placing and moving.