Jump to content




Turtle Program only goes to the second slot when out of blocks, doesn't switch to third and so on


  • You cannot reply to this topic
3 replies to this topic

#1 n1ghtk1ng

  • Members
  • 58 posts

Posted 05 January 2013 - 07:49 AM

I made a turtle program to make a platform levels for my "factory" in Feed-The-Beast. Every time it runs out of blocks in a slot, I wanted it to switch to the next slot, but it only switches from the first slot to the second slot. How can I fix this?
--[[ VARIABLES ]]--

--[[ FUNCTIONS ]]--

function woodSlot()
a = 1
local b = turtle.getItemCount(a)
if b == 0 then
  a = a+1
  turtle.select(a)
end
end

--[[ MAIN CODE ]]--
while true do
if turtle.back() == true then
  turtle.place()
elseif turtle.back() == false then
  turtle.turnRight()
end
woodSlot()
end


#2 Viproz

  • Members
  • 58 posts

Posted 05 January 2013 - 07:51 AM

every time you run the woodSlut function you reset the value to 1, define a = 1 in the "--[[ VARIABLES ]]--" !

#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 05 January 2013 - 07:54 AM

move a = 1 out of the woodSlot() function, it keeps resetting to 1 and then if the amount in slot a is 0 it increases it but then resets back to 1

--[[ VARIABLES ]]--

--[[ FUNCTIONS ]]--
a = 1
function woodSlot()

local b = turtle.getItemCount(a)
if b == 0 then
  a = a+1
  turtle.select(a)
end
end

--[[ MAIN CODE ]]--
while true do
if turtle.back() == true then
  turtle.place()
elseif turtle.back() == false then
  turtle.turnRight()
end
woodSlot()
end


#4 n1ghtk1ng

  • Members
  • 58 posts

Posted 05 January 2013 - 08:37 AM

View PostremiX, on 05 January 2013 - 07:54 AM, said:

move a = 1 out of the woodSlot() function, it keeps resetting to 1 and then if the amount in slot a is 0 it increases it but then resets back to 1

--[[ VARIABLES ]]--

--[[ FUNCTIONS ]]--
a = 1
function woodSlot()

local b = turtle.getItemCount(a)
if b == 0 then
  a = a+1
  turtle.select(a)
end
end

--[[ MAIN CODE ]]--
while true do
if turtle.back() == true then
  turtle.place()
elseif turtle.back() == false then
  turtle.turnRight()
end
woodSlot()
end
Well that was stupid of me! Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users