Turtle Coding

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Ookami5875

New Member
Jul 29, 2019
73
0
0
I'm using dire's setup of his mob spawner, but I added some more spawners and extended the height of the cieling. I was just doing turtle.drop, but if multiple items came in at once, the items remain in the turtles inventory. I need help getting this code correct. When I use it I get the error "bios:338: [string "startup"]:11: '<eof>' expected"

Ignore the .'s I had to use them to get the spacing to look right.

The code is
dropItems= 1,6
i = dropItems
while true do
. dropInventory()
. . turtle.select(i)
. . turtle.drop()
. end
. turtle.attack()
. dropInventory()
. sleep(1)
end
 

zwahlm14

New Member
Jul 29, 2019
89
0
0
try without puting the period infront of the code under the while loop that is the only problem i can see. oh, i seen another one i am pretty sure you named the drop thing wrong on the wiki it says it is turtle.drop() change thoes things and if it still dusn't work reply and i will try to put it in a turtle myself and try and debug it because it is kinda hard to without being able to run it.
 

MilConDoin

New Member
Jul 29, 2019
1,204
0
0
I'm using dire's setup of his mob spawner, but I added some more spawners and extended the height of the cieling. I was just doing turtle.drop, but if multiple items came in at once, the items remain in the turtles inventory. I need help getting this code correct. When I use it I get the error "bios:338: [string "startup"]:11: '<eof>' expected"

Ignore the .'s I had to use them to get the spacing to look right.

The code is
Code:
dropItems= 1,6
i = dropItems
while true do
  dropInventory()
    turtle.select(i)
    turtle.drop()
  end
  turtle.attack()
  dropInventory()
  sleep(1)
end
I see two ends, but only one while.
 

Belone

New Member
Jul 29, 2019
417
0
0
Can I just run through each line of your program? As this is really confusing me.

dropItems = 1,6 - I'm not sure what you are declaring here, if you are trying to make dropItems a table then you need to add {} around it. Or is this a typo of 16?

i = dropItems - this line isn't needed at all, just replace all your future "i"s with dropItems instead.

while true do - this will cause it to loop forever, is this what you are after? As this means all your code would ever do is:-

dropInventory() - which I'm guessing is the name of this function and therefore is a recursive call - though I have no idea why
turtle.select(i) - well you could replace this with turtle.select(1,6 <instead correction to what dropItems was meant to be>)
turtle.drop


Can you possibly explain exactly what you want your code to do and I'd be happy to give a go at writing it for you?
 

Ookami5875

New Member
Jul 29, 2019
73
0
0
try without puting the period infront of the code under the while loop that is the only problem i can see. oh, i seen another one i am pretty sure you named the drop thing wrong on the wiki it says it is turtle.drop() change thoes things and if it still dusn't work reply and i will try to put it in a turtle myself and try and debug it because it is kinda hard to without being able to run it.
I did both at once and then I isolated each solution and I still end up with the same exact error that is in the OP. I did change the turtle.drop() to turtle.drop(64) as well and still ended up with the same error.

Can I just run through each line of your program? As this is really confusing me.

dropItems = 1,6 - I'm not sure what you are declaring here, if you are trying to make dropItems a table then you need to add {} around it. Or is this a typo of 16?

i = dropItems - this line isn't needed at all, just replace all your future "i"s with dropItems instead.

while true do - this will cause it to loop forever, is this what you are after? As this means all your code would ever do is:-

dropInventory() - which I'm guessing is the name of this function and therefore is a recursive call - though I have no idea why
turtle.select(i) - well you could replace this with turtle.select(1,6 <instead correction to what dropItems was meant to be>)
turtle.drop


Can you possibly explain exactly what you want your code to do and I'd be happy to give a go at writing it for you?

You figured out the dropItems = 1,6
I just like to use a variable and i made sense rather than doing dropItems the whole time. I'm lazy >.>
I do want it to loop forever as I want there to be a constant attack
dropInventory is there so that it will know to use the function that I created above
turtle.select(i) is used so that it will go through the slots 1-6 and drop all items from there. I'm using multiple spawners, so there are multiple items and it isn't isolated to only slot 1 anymore

I have transposers set up directly in front of the turtles and I have for a while now, but I now ran into the issue of the turtles keeping hold of the items. I want them to basically throw their entire inventory in front of them to let the transposers take the items into the barrels. Then of course the constant attacking of mobs.
 

zwahlm14

New Member
Jul 29, 2019
89
0
0
the dropInventory() part is not necessary because it is not a function of any kind unless you have pre defined it elsewhere in the program. I am going to try to put this in a turtle and debug it that way because i think you have some things mis labeled and i can't tell unless i actually test this in game so i will post my results in a bit. also, ignore everything in my first comment, my internet sucks and the first time it loaded it loaded differently that it is supposed to unless of course you changed it which i doubt.
 

Ookami5875

New Member
Jul 29, 2019
73
0
0
the dropInventory() part is not necessary because it is not a function of any kind unless you have pre defined it elsewhere in the program. I am going to try to put this in a turtle and debug it that way because i think you have some things mis labeled and i can't tell unless i actually test this in game so i will post my results in a bit. also, ignore everything in my first comment, my internet sucks and the first time it loaded it loaded differently that it is supposed to unless of course you changed it which i doubt.


dropItems= 1,6
i = dropItems
while true do
dropInventory()
turtle.select(i)
turtle.drop()
end
turtle.attack()
dropInventory()
sleep(1)
end
The underlined part was my attempt of making the dropInventory a function.
 

zwahlm14

New Member
Jul 29, 2019
89
0
0
ok, i done your code and you was just overcomplicateing it so i refined it:

while true do
for dropitems=1,16 do
turtle.attack()
turtle.select(dropitems)
turtle.drop()
end
end

i tested it and this works fine:) also, you can name dropitems to what ever you want if you want to save on some typing.[DOUBLEPOST=1361475013][/DOUBLEPOST]
dropItems= 1,6
i = dropItems
while true do
dropInventory()
turtle.select(i)
turtle.drop()
end
turtle.attack()
dropInventory()
sleep(1)
end
The underlined part was my attempt of making the dropInventory a function.
oh, ok that is kinda what i thought you make a function like this:

function example()
example code
end

program code goes after you set the functions and not inside the code like you tried, remember you have to tell the code what it is doing what you did was tell the code to try to run the function dropInventory() and it didn't exist which was probably alot of your problem.
 

Ookami5875

New Member
Jul 29, 2019
73
0
0
ok, i done your code and you was just overcomplicateing it so i refined it:

while true do
for dropitems=1,16 do
turtle.attack()
turtle.select(dropitems)
turtle.drop()
end
end

i tested it and this works fine:) also, you can name dropitems to what ever you want if you want to save on some typing.

Thanks for the code. Sadly I tend to overcomplicate things and all it does is lead to a confusing mess.
 

zwahlm14

New Member
Jul 29, 2019
89
0
0
Thanks for the code. Sadly I tend to overcomplicate things and all it does is lead to a confusing mess.
yea, that is what for forums are for though:) also, i think it would be highly beneficial if you watched sethbling's programming tutorials it helped me alot.
 

MilConDoin

New Member
Jul 29, 2019
1,204
0
0
So if I understand this correctly, each run through the loop you define the function anew?
I'm not fluent in LUA (beware syntax errors), but I think something like this would be more like what you want:
Code:
function dropInventory()
  for i=1,6 do
    turtle.select(i)
    turtle.drop()
  end
end
while true do
  turtle.attack()
  dropInventory()
  sleep(1)
end

Edit: It seems, I took waaay to long to type this^^
Edit2: Corrected a typo (to -> do)
 

Ookami5875

New Member
Jul 29, 2019
73
0
0
So if I understand this correctly, each run through the loop you define the function anew?
I'm not fluent in LUA (beware syntax errors), but I think something like this would be more like what you want:
Code:
function dropInventory()
  for i=1,6 do
    turtle.select(i)
    turtle.drop()
  end
end
while true to
  turtle.attack()
  dropInventory()
  sleep(1)
end

Edit: It seems, I took waaay to long to type this^^

But what you have just shown me is very beneficial. I didn't realize that was what I was doing. Now I believe I know how to properly create a function.
 

ILoveGregTech

New Member
Jul 29, 2019
788
0
0
This has nothing to do with mob farming, it's for mining...
What is really easy code for making a turtle mine? I heard on Bdubs video that he said something like mine 100 would work but I forget...
Can anyone help with a simple less than 5 line code for mining?
 

MilConDoin

New Member
Jul 29, 2019
1,204
0
0
It depends on what you want to do.
Does the integrated excavate program do what you want?
Do you want some long tunnels to be dug out, so you can just pick the goodies from the walls?
 

ratchet freak

Well-Known Member
Nov 11, 2012
1,198
243
79
the first end ends the while loop and the second end ends the rest of the code.

you never need to "end" a file it's ended for you, only end things you start otherwise it's a compile error

the compiler didn't expect a "end" (as it wasn't inside anything that needed ending) so it errored on that line
 

Scaffolding

New Member
Jul 29, 2019
170
0
0
Yes long tunnels if you know it :p
BDoubleO was using the "tunnel 100" or whatever number you want to make 2 block high & 3 block wide tunnels of however much length specified.
If you want a Quarry like option then you use the excavate command making sure to have a chest next to the turtle when it starts.

Keep in mind if the turtle fills up during the tunnel program, any excess items will be dropped on the ground but this shouldn't be a problem since you will most likely be close behind it mining the walls.

Edit: If you want a better program for doing quarry work you can use OreQuarry or some other popular script or write one yourself.
 

ILoveGregTech

New Member
Jul 29, 2019
788
0
0
BDoubleO was using the "tunnel 100" or whatever number you want to make 2 block high & 3 block wide tunnels of however much length specified.
If you want a Quarry like option then you use the excavate command making sure to have a chest next to the turtle when it starts.

Keep in mind if the turtle fills up during the tunnel program, any excess items will be dropped on the ground but this shouldn't be a problem since you will most likely be close behind it mining the walls.

Edit: If you want a better program for doing quarry work you can use OreQuarry or some other popular script or write one yourself.
When you say "tunnel 100 or whatever" is that the command? That's all I was really talking about