1 posts
Posted 30 January 2014 - 05:39 PM
I have a turtle that I want to attack then spit out any items that it has in its inventory. So far this is what I have in my program
theend = true
repeat
stuff
until theend == false
(Which I got from here:
http://www.computerc...te-loop-in-lua/)
What can I do to make it so that it'll attack and spit out any items it gets into its inventory?
1281 posts
Posted 30 January 2014 - 06:13 PM
What you posted isn't an actual program, it's just an idea of how to do one.
This should be all you need
http://computercraft.info/wiki/Loops loops tutorial
http://computercraft.info/wiki/Turtle_Tutorial turtle tutorial
and the full turtle API
http://computercraft.info/wiki/Turtle_%28API%29
1852 posts
Location
Sweden
Posted 31 January 2014 - 08:15 AM
This is very easy to accomplish
--# Loop forever
while true do
--# Loop until it doesn't detect anything infront of it
while turtle.detect() do
turtle.attack()
for i = 1, 16 do
turtle.select( i )
turtle.drop()
end
end
sleep( 0 )
end
Also, Check out the regular Lua page about
loops and the
turtle api page.
Edited on 31 January 2014 - 07:15 AM
110 posts
Posted 04 February 2014 - 07:30 AM
Hellkid98's program should work, but the turtle will attack very slowly, since it takes time to empty out all 16 slots. With some experimentation on that program, you will be able to find out how to optimize it and speed it up. …Going so far as to fill the turtle's inventory with junk like stone swords so it can't pick up any loot, but then it's not technically "spitting".