Xp Turtle Help?

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

Killer5252

New Member
Jul 29, 2019
61
0
0
Hello, So i recently coded myself this:


m = peripheral.wrap("right")
m.setAutoCollect(true)
local currLevel = 0

while true do



turtle.attack()
currLevel = m.getLevels()
print("Currently Level: "..currLevel)
sleep(1)


And it's spamming this in the turtle:



and i want to take that and put it on a monitor display:




Who could help me with Lua codeing knowledge?

I would like it to display the Current Level

like the turtle has but i dont want it spammed on the monitor

So please Could someone with Lua codeing knowledge Help me with this


Thanks

- Killer5252 ^_^
 

YX33A

New Member
Jul 29, 2019
3,764
0
0
You have a "while true" loop with a command that prints to the console. If you remove the line "print("Currently Level: "..currLevel)" the issue vanishes. But then you have to find a way to extract the info you want to put on that screen.
I can't code for shit (even with LUA!) either. I hope someone can come in here and suggest a way to get the data for that monitor without nesting it in the "while true" loop.
Perhaps using a second turtle (with a exp upgrade as well, obviously) to track how many levels it has stored and print this when requested? You would have to use the top turtle to deposit the XP into the second turtle(at least the way I'm thinking up this) and the second turtle runs this command when given a signal, and then prints it to the screen?
I guess the whole thing could be done with one turtle. But I am not a clever pony nor sergal nor hooman. I can only hope that you find a answer, because this sounds pretty cool.
My planned setup was a Quantum Tank, a Liquid Sensor card, and Liquid XP(plus a fancy Nuclear Control monitor to track this with).
 

Killer5252

New Member
Jul 29, 2019
61
0
0
You have a "while true" loop with a command that prints to the console. If you remove the line "print("Currently Level: "..currLevel)" the issue vanishes. But then you have to find a way to extract the info you want to put on that screen.
I can't code for shit (even with LUA!) either. I hope someone can come in here and suggest a way to get the data for that monitor without nesting it in the "while true" loop.
Perhaps using a second turtle (with a exp upgrade as well, obviously) to track how many levels it has stored and print this when requested? You would have to use the top turtle to deposit the XP into the second turtle(at least the way I'm thinking up this) and the second turtle runs this command when given a signal, and then prints it to the screen?
I guess the whole thing could be done with one turtle. But I am not a clever pony nor sergal nor hooman. I can only hope that you find a answer, because this sounds pretty cool.
My planned setup was a Quantum Tank, a Liquid Sensor card, and Liquid XP(plus a fancy Nuclear Control monitor to track this with).

I do have Liquid Xp but i dont really like the mod to much,So i am just wanted to store all the xp into a turtle, The turtle will hold infinant XP.
 

KyoNeko66

New Member
Jul 29, 2019
96
0
0
Im currently not at my computer so i cant test this out for you, so im going to give the awnsers of the top of my head and might not be perfect. To start with, i dont know if turtles can even interact with monitors.. For now im going to assume this do.

To solve the first problem of the spam you should add

term.clear()
term.setCursorPos(1,1)

before the

print("Currently Level: "..currLevel)
This will make it clear the screen and righ away print its current level afterwards. I dont know if the set curor pos is required but i put it in just in case. As for the montor it is just a peripheral just like the exp part. From your script i asume you are using a exp-melee turtle. Which means that both left and right side are in use. This leaves the back, top and bottom of the turtle free for the monitor. To add in the monitor support you should wrap it first and then call on it like a normal peripheral. Im not that good at explaining so i'll work it out in your script instead. For the sake of showing it i asume the monitor is ontop of the turtle.


Code:
m = peripheral.wrap("right")
m.setAutoCollect(true)
local currLevel = 0
 
mon = peripheral.wrap("top")
 
while true do
 
 
 
turtle.attack()
currLevel = m.getLevels()
term.clear()
term.setCursorPos(1,1)
print("Currently Level: "..currLevel)
mon.clear()
mon.setCurosPos(1,1)
mon.print("Currently Level: "..currLevel)
sleep(1)
This should.. If i remembered thigns correctly, and considinger a turtle can use a monitor which im not sure about. Do what your original script did, just less spammy and printing it on the monitor as well. I hope this helps and that i didn't make any mistakes writing this out.
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0
(Edit: Ninja'd! Ah well, I'm not re-writing the below.)

Haven't yet used external monitors yet, but you might find Term.setCursorPos helpful. This allows you to move the output text cursor to a specific location.

Hence, you can write "Currently Level:" once, then from then on, write the level number at the end of that line (overlapping whatever number was written there before).

I do, however, recommend using your variable to check if the level has CHANGED, rather then to just to see what the level currently IS (just keep referring to "m.getLevels()" for that information). Constantly updating the display when you don't need to will probably lead to slow-down somewhere along the line.

Code:
local lastLevel = m.getLevels()
print("Currently Level: ")
 
while true do
  turtle.attack()
  if  m.getLevels() ~= lastLevel then
      term.setCursorPos(18,1)
      print(currLevel)
      lastLevel = m.getLevels()
  end
  sleep(1) -- Why's this line here?
end
That should work just on the turtle side. I think.

To get the monitor going, I guess you'd hook up a computer to it with a modem, give the turtle a modem, then have the computer wait for signals from the fighter (who should be sending out a message each time his level changes). Or fighters, perhaps, depends: Seems a shame to waste a big display on one turtle. Look into Rednet for further details.
 

KyoNeko66

New Member
Jul 29, 2019
96
0
0
First time i help someone and i ninja someone, cant start much better then this. However bomb block. From the script i asume its a exp-melee turtle. Meaning there is no space for the modem anymore as both left and right side are taken, which the wireless modem uses. Not to mention that the rednet is fairly well advanced compared to this, in my opinion at least.
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0
Indeed, you're right, the turtle would need to touch the monitor (er, assuming they can use the things) - networking's not an option.

I guess if you ditched the "mon.clear()" command, you could still put a line of turtles under the display, and have each one write to a different line.