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

shrinking code?

Started by protexxi, 10 December 2013 - 03:37 PM
protexxi #1
Posted 10 December 2013 - 04:37 PM
Ok so making a program use in this function to place items into a ender chest

turtle.select(1)
turtle.placeDown()
turtle.select(2)
turtle.dropDown()
turtle.select(3)
turtle.dropDown()
turtle.select(4)
turtle.dropDown()
turtle.select(5)
turtle.dropDown()
turtle.select(6)
turtle.dropDown()
turtle.select(7)
turtle.dropDown()
turtle.select(8)
turtle.dropDown()
turtle.select(9)
turtle.dropDown()
turtle.select(1)
turtle.digDown

I remember there was a way to do this in one line something like .drop(2,9)?
Bubba #2
Posted 10 December 2013 - 04:39 PM
Use a for loop:

for i=1,9 do
  turtle.select(i)
  turtle.dropDown()
end

You could condense that into one line, though it is unnecessary.
protexxi #3
Posted 10 December 2013 - 04:40 PM
thanks