CC Melee turtle- Need a very simple script

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here

Affex

New Member
Jul 29, 2019
176
0
0
Hey, Im searching for a script for CC melee turtles.
The script should simply make the turtle attack when there is something to attack,
but NOT pick up any loot! I have found dozens of scripts, but in every single one
the turtle is picking up loot.

I could get into programming it myself (Which would´nt take too long)
but Im out of time and rather spend it playing than programming
 

Bibble

New Member
Jul 29, 2019
1,089
0
0
Hey, Im searching for a script for CC melee turtles.
The script should simply make the turtle attack when there is something to attack,
but NOT pick up any loot! I have found dozens of scripts, but in every single one
the turtle is picking up loot.

I could get into programming it myself (Which would´nt take too long)
but Im out of time and rather spend it playing than programming
Picking up the loot is a part of the turtle.attack() command. AFAIK, there are no options or arguments that would prevent it.

The best you could do would be to fill the turtle's inventory, so it drops the loot on the ground.
 

Affex

New Member
Jul 29, 2019
176
0
0
Picking up the loot is a part of the turtle.attack() command. AFAIK, there are no options or arguments that would prevent it.

The best you could do would be to fill the turtle's inventory, so it drops the loot on the ground.
Oh okay... Thanks
 

Golrith

Over-Achiever
Trusted User
Nov 11, 2012
3,834
2,137
248
while true do
turtle.attack()
sleep(1)
turtle.select(1)
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
end

Is what I use. Just fill the remaining slots with junk, and the turtle will eject in front of itself anything in it's first 4 inventory slots.
So in front of the turtles, put some transposers or obsidian pipes to pick up the items.
 
  • Like
Reactions: Affex

Affex

New Member
Jul 29, 2019
176
0
0
while true do
turtle.attack()
sleep(1)
turtle.select(1)
turtle.drop()
turtle.select(2)
turtle.drop()
turtle.select(3)
turtle.drop()
turtle.select(4)
turtle.drop()
end

Is what I use. Just fill the remaining slots with junk, and the turtle will eject in front of itself anything in it's first 4 inventory slots.
So in front of the turtles, put some transposers or obsidian pipes to pick up the items.
Awesome! Thanks. Just a quick question, This is a complete script right?

EDIT: Tested it and its awesome!
 

Golrith

Over-Achiever
Trusted User
Nov 11, 2012
3,834
2,137
248
Yep. Just chuck it in your turtles Startup script and don't stand close! I'm finding in my game world that turtles are damaging me if I stand directly behind them now.
 

Affex

New Member
Jul 29, 2019
176
0
0
Yep. Just chuck it in your turtles Startup script and don't stand close! I'm finding in my game world that turtles are damaging me if I stand directly behind them now.
It works great, But I notice I lost some efficiency. Is there a script to make it so when the turtles inventory is full it drops all the stuff?
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
And a script that will be faster:

Code:
while true do
if turtle.attack() then
  print("Burn it with FIRE!")
else
  print("Don't fire until you see the whites of their eyes....")
end
 
if turtle.getItemCount(14) > 0 then
  print("Oh gods, so much stuff.... VOID VOID VOID!")
  for vSlotCount = 16, 1, -1 do
    if turtle.getItemCount(vSlotCount) > 1 then
    turtle.select(vSlotCount)
    turtle.drop()
    print("Slot voided!")
  end
end
end
 
print("And now we play the waiting game...")
sleep(0.2)
end

Specifically, the turtle attacks, and if it hits something (turtle.attack() returns TRUE) it tells you as much, otherwise it tells you as much (with my strange way of defining those, as you can see).

Then it looks to see if there are any items in slot fourteen, which means "Have I filled up with junk?". If it has, it then starts tossing stuff in front of it (the direction it attacks, as well), then it waits 0.2 seconds (you can adjust this timing to your liking) and repeats the fun.

Also, and I have yet to try this as all of my attack turtles actually eject things into my sorting system, but if you fill the turtle's inventory up with something that won't be dropped, say smooth stone, it shouldn't pick up the drops then. If that is the case (test it!) you can remove the entire part of the script that deals with dropping things, and it'll be even faster.

Good luck!

It works great, But I notice I lost some efficiency. Is there a script to make it so when the turtles inventory is full it drops all the stuff?
Wow, good timing on my part, eh? But yes, try my latter suggestion first (filling up the turtle's inventory with smooth stone) to see if that tells the turtle the name of the game, as it were. Good luck!
 

Golrith

Over-Achiever
Trusted User
Nov 11, 2012
3,834
2,137
248
If you fill a turtles inventory, then they will still pick up items, but automatically spit them out behind them up to 1-2 blocks away, which is a tad annoying :D

Always wondered how to do loops, so I will definitely update my turtles once I've got more soul shard mob spawn types in my mob farm.
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
If you fill a turtles inventory, then they will still pick up items, but automatically spit them out behind them up to 1-2 blocks away, which is a tad annoying :D

Always wondered how to do loops, so I will definitely update my turtles once I've got more soul shard mob spawn types in my mob farm.

Now that could be useful. For example: If they spit them out in a way that, if you were to put a chest there, they'd drop them into the chest's inventory, that would mean passthrough collection of materials. Otherwise, an obsidian pipe should work. That would then remove the problem of having them dump things.

Loops are easy, especially in LUA. Look through this http://computercraft.info/wiki/Loops and if you have any loop questions ask away. Maybe in a new thread, though, if you have a lot of questions so we don't bugger up this one with off-topic loopification.
 

Affex

New Member
Jul 29, 2019
176
0
0
And a script that will be faster:

Code:
while true do
if turtle.attack() then
  print("Burn it with FIRE!")
else
  print("Don't fire until you see the whites of their eyes....")
end
 
if turtle.getItemCount(14) > 0 then
  print("Oh gods, so much stuff.... VOID VOID VOID!"
  for vSlotCount = 16, 1, -1
    if turtle.getItemCount(vSlotCount) > 1 then
    turtle.select(vSlotCount)
    turtle.drop()
  print("Slot voided!")
  end
  end
end
 
print("And now we play the waiting game...")
sleep(0.2)
end

Specifically, the turtle attacks, and if it hits something (turtle.attack() returns TRUE) it tells you as much, otherwise it tells you as much (with my strange way of defining those, as you can see).

Then it looks to see if there are any items in slot fourteen, which means "Have I filled up with junk?". If it has, it then starts tossing stuff in front of it (the direction it attacks, as well), then it waits 0.2 seconds (you can adjust this timing to your liking) and repeats the fun.

Also, and I have yet to try this as all of my attack turtles actually eject things into my sorting system, but if you fill the turtle's inventory up with something that won't be dropped, say smooth stone, it shouldn't pick up the drops then. If that is the case (test it!) you can remove the entire part of the script that deals with dropping things, and it'll be even faster.

Good luck!


Wow, good timing on my part, eh? But yes, try my latter suggestion first (filling up the turtle's inventory with smooth stone) to see if that tells the turtle the name of the game, as it were. Good luck!
Wow, Thanks! But I got a Bios 338 error, "do expected"

And extra question: How do I set a script as the startup script?
I cant seem to find much info about CC overall..
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Wow, Thanks! But I got a Bios 338 error, "do expected"

D'oh! Pardon, but add a "do" at the end of the "for vSlotCount = 16, 1, -1" statement. I constantly forget my "do"s and "then"s as LUA is a very expansive language, in regards to excess vocabulary required. Thanks!
 

Affex

New Member
Jul 29, 2019
176
0
0
D'oh! Pardon, but add a "do" at the end of the "for vSlotCount = 16, 1, -1" statement. I constantly forget my "do"s and "then"s as LUA is a very expansive language, in regards to excess vocabulary required. Thanks!
Woho, There we go! This one is the fastest yet, My Xp turtle setup is producing a enchanted book every 35-40 seconds with a tier 5 skeleton and tier 5 blaze soul shard :D
 

Golrith

Over-Achiever
Trusted User
Nov 11, 2012
3,834
2,137
248
Now that could be useful. For example: If they spit them out in a way that, if you were to put a chest there, they'd drop them into the chest's inventory, that would mean passthrough collection of materials. Otherwise, an obsidian pipe should work. That would then remove the problem of having them dump things.

Loops are easy, especially in LUA. Look through this http://computercraft.info/wiki/Loops and if you have any loop questions ask away. Maybe in a new thread, though, if you have a lot of questions so we don't bugger up this one with off-topic loopification.
I'm used to VB6 programming (whey!), just need to get my head around the different presentation of the same commands.


Chests stuck behind a turtle will work, only issue I have there is that it's also my XP farm, so a chest will be in the way to collect the orbs (as I'm not using brain in a jar)
 

trunksbomb

New Member
Jul 29, 2019
390
0
0
I have four turtles above a layer of water in a 9x9 spawning area, surrounding a 1x1 hole. The spawned mobs get pushed into the turtles and attacked. The items get spit out and into the water, and fall into the 1x1 hole along with the experience orbs. Works fine for me.
 

TheBaz

New Member
Jul 29, 2019
13
0
0
I have four turtles above a layer of water in a 9x9 spawning area, surrounding a 1x1 hole. The spawned mobs get pushed into the turtles and attacked. The items get spit out and into the water, and fall into the 1x1 hole along with the experience orbs. Works fine for me.
Screenshot? :D It sounds very interesting. I'm always happy to see other peoples designs it really makes you rethink things.
 

trunksbomb

New Member
Jul 29, 2019
390
0
0
That would involve opening Mindcrack and logging in to the server.. ain't nobody got time for that!

I'll get you a screenshot later.
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Woho, There we go! This one is the fastest yet, My Xp turtle setup is producing a enchanted book every 35-40 seconds with a tier 5 skeleton and tier 5 blaze soul shard :D

Nice, I haven't tested it with two T5 spawners, so I'm glad it works for that. If you need more efficiency, we can find ways to do that. Otherwise, though, adding more turtles is another useful way to gain more speed.

I'm used to VB6 programming (whey!), just need to get my head around the different presentation of the same commands.

Yup, but thankfully after the first programming language, new ones are almost always cake in compare.

Chests stuck behind a turtle will work, only issue I have there is that it's also my XP farm, so a chest will be in the way to collect the orbs (as I'm not using brain in a jar)


Ah, I have yet to use an XP turtle, so I am not sure of how that mechanic works in that regard, but what about an obsidian pipe one block back? Might that work to allow things to be sucked into it (and then stored in a chest, or barrels, or whatnot)? I may need to play around with this later on, myself, as the increase in speed would be a good bit.

UPDATE: Filled all turtles with stone, Now its even faster :)
Whoo! Yeah, stoned turtles will do the work without ever complaining. Perfect!
 

trunksbomb

New Member
Jul 29, 2019
390
0
0
OI5p7nO.png


NbglNDW.png


First one's just a glamour shot. The spawning area is the same on both sides.