Turtle Tips for a Slow Computer?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • 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

RedLion86

New Member
Jul 29, 2019
17
0
0
I'm playing Mindcrack pack v.8.1.1 on my crappy Laptop. I use Optfine, fast graphics, short render distance, with most of the video performance settings on "max FPS." With all those settings, the game runs fine most of the time, except there's a decent amount of lag in my main base (where I have a pretty complex sorting system that uses several timers, relays, and other lag-inducing things). It's still tolerable though.

I recently built a wither skeleton spawner with a soul shard. I have the mobs flow into a 1x1 hole and then drop down so a single melee turtle can take care of them. The only problem is... the turtle doesn't attack like it's supposed to. Usually it doesn't attack at all. Once in a while, when I start up the game, it will work fine and kill a bunch of skeletons, but then it stops attacking. The program I am using (named startup so it should be running all the time) is:

Code:
while true do
turtle.attack()
end

I don't think I made any coding mistakes, but let me know if that's the case.

I tried putting a chunk loader next to the turtle, which seemed to work for a minute or two the next time I quit and relogged, but again the turtle stopped attacking.

I've tried going into the turtle's GUI and holding CTRL+T to terminate the program, then CTRL+R to restart it. I'm getting the messages in the GUI, which shows the turtle is responding my commands. But it doesn't attack.

The only thing I can think of is that the lag is messing with the turtle. Has anyone else had this issue, or had success at solving/mitigating it? Would it help to add a sleep(1) line to the end of the code? Any other suggestions?
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
The only thing I can think of is that the lag is messing with the turtle. Has anyone else had this issue, or had success at solving/mitigating it? Would it help to add a sleep(1) line to the end of the code? Any other suggestions?

Bingo, add a "sleep(0.2)" or so and it should be fine.
 

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
Also, does the turtle have fuel? I don't know whether or not melee turtles need fuel to attack if they're not moving around, but throwing in one piece of coal (or an RE-battery) should do the trick, or at least tell you if that was actually the problem.
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Also, does the turtle have fuel? I don't know whether or not melee turtles need fuel to attack if they're not moving around, but throwing in one piece of coal (or an RE-battery) should do the trick, or at least tell you if that was actually the problem.

Turtles only need fuel for movement actions. They will attack forever plus four sans fuel. Not having a sleep in place, though, will cause the turtle to throw an error in the TurtleOS, ergo the reason for adding the delay.

The next problem is going to be them filling up with stuff, which can be solved with, you guessed it, more code!
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
Are you kidding?! I have the exact same problem!!! I have your settings, I have that spawner, I have that sorting system!!! I decided to chunkload it while I lived in a void world that I turned into a cloud village, but...yeah!!! I just thought that was a problem with the computer, so I put two, and it still has problems! :D I even use that same code (well....so does everyone)
Bingo, add a "sleep(0.2)" or so and it should be fine.
...How I do this where this go
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Or a redstone engine or similar.

Boo, redstone engines. Yay, more coding! You can increase the efficiency with more coding, well beyond what a redstone engine could ever even dream of as such.

Are you kidding?! I have the exact same problem!!! I have your settings, I have that spawner, I have that sorting system!!! I decided to chunkload it while I lived in a void world that I turned into a cloud village, but...yeah!!! I just thought that was a problem with the computer, so I put two, and it still has problems! :D I even use that same code (well....so does everyone)

...How I do this where this go

Go with this:

Code:
vCounter = 0
 
while true do
 if turtle.attack() then
  print("MURDERTURTLE9001: TARGET ATTACKED!")
 else
  print("MURDERTURTLE9001: TARGET NOT IN SIGHT!")
 end
 
 if turtle.getItemCount(15) > 0 then
  print("MURDERTURTLE9001: PURGING ITEMS!")
 for vCounter = 16, 1, -1 do
  turtle.dropDown(vCounter)
  print("MURDERTURTLE9001: ITEM SLOT PURGED!")
 end
 end
 
 sleep(0.2)
end

I have not tested that code, specifically, but that should make the turtle attack once every tenth of a second until it is almost filled with items in its inventory. Then it will start dropping all of the items downwards, and then go back to attacking.
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
Oooh...Okay, thanks, I've gotten a few spawners over the world, and I think I'm ready to set up a chunk loader out of my loading zone (which I can't say is far considering I'm on tiny+0), and put a couple spawners up. Let's hope I can put creepers and endermen together and let's hope I can figure out how not to lag the server with the thousands of entities they call "exp orbs" with an enchanting turtle underneath it and some books and a Gregarious approved Magic Generator.
 

RedLion86

New Member
Jul 29, 2019
17
0
0
I tried both sleep(0.2) and sleep(1), and it works better but still stops working after a couple minutes.

The turtle filling up with items isn't a problem; I'm just using a transposer + timer to suck all the items out and send them to my sorting system.
 

Hydra

New Member
Jul 29, 2019
1,869
0
0
Don't write any output in those tight loops. It'll spam your console 5 times per second and will still do so if you're not looking at it. You're better off removing the "print()" lines.
 

Revemohl

New Member
Jul 29, 2019
595
0
0
I had turtles working a few updates ago, and I just ran into this problem after I tried building a new system as well... and apparently, the solution is kind of silly.
Just put the turtles under what they're supposed to attack.
 
  • Like
Reactions: RedLion86

Guswut

New Member
Jul 29, 2019
2,152
0
0
Don't write any output in those tight loops. It'll spam your console 5 times per second and will still do so if you're not looking at it. You're better off removing the "print()" lines.

Feel free to do as much, but, personally, I enjoy knowing where my turtle is in the loop. I have yet to see any difference in regards to the speed with and without the print commands.
 

slay_mithos

New Member
Jul 29, 2019
1,288
0
0
Any action your turtle takes has a consequence on the CPU, and potentially lags you.

Seeing as the title stipulates "slow computer", you want to only have what is strictly required for it to run.

Printing every step is more of a debug function usually, but if you prefer having a verbose mode on your programs, that is up to you.
Do note that too many messages will tend clog your memory a bit.
 

RedLion86

New Member
Jul 29, 2019
17
0
0
I had turtles working a few updates ago, and I just ran into this problem after I tried building a new system as well... and apparently, the solution is kind of silly.
Just put the turtles under what they're supposed to attack.
Hmm, I will have to try that tonight when I get home from work.
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
I'll test it using the print to make sure everything works, and if it doesn't, then I'll just delete the lines. I don't think the computer's even going to be in an easily accessible place, so it's not a huge deal.
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
I'll test it using the print to make sure everything works, and if it doesn't, then I'll just delete the lines. I don't think the computer's even going to be in an easily accessible place, so it's not a huge deal.

Yeah, then go for it. I'm sure MURDERTURTLE9001 won't mind that you are stealing its voice forever. Just remember why the screen appears to be "frozen".
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
Oh yeah! I hate the frozen screens! Okay then MURDLETURDER9001, I guess you're reinstated.

You can always set up a counter that'll only print the screen every so often. Here is an example:

Code:
vCounter = 0
 
while true do
 if vCounter > 9 then
  print("Hey, the counter filled up!")
  vCounter = 0
 else
  vCounter = vCounter + 1
 end
 
sleep(0.1)
 
end

That should cause an output every second (or maybe every 9/10th of a second, I wouldn't be surprised as I do that sometimes). You can tweak it as needed.