Jump to content




Wall Building.


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

#1 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

Posted 04 December 2013 - 05:43 PM

Hello! I have created a wall building program, and I need help. So, the program works fine, except for big walls, I want it to detect when the slot it is on is empty and switch to the next slot. I wrote some code for it, but it is not working. No errors, it just does not switch. Any help?
Current code:
print("How long?")
local long = read()
print("How tall?")
local tall = read()
function wall()
 for i = 1, tall do
  turtle.up()
 for i = 1, long do
  turtle.placeDown()
  turtle.forward()
 end
 for i = 1, long do
  turtle.back()
 end 
end
end
a = 1
--Program
if turtle.getItemCount(a) == "0" then
 a = a + 1
 turtle.select(a)
 wall()
else
 wall()
end


#2 mrpoopy345

  • Members
  • 148 posts
  • LocationMy Computer

Posted 04 December 2013 - 06:42 PM

Please? Anyone?

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 04 December 2013 - 06:54 PM

You're checking to see if your block slot is empty, then trying to build the entire wall without checking again.

Instead, you want to rig things so that it performs that check each time it goes to place a block.

Quick untested re-write:

Spoiler






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users