2 posts
Location
Baltimore, MD
Posted 06 February 2013 - 11:36 AM
Title: Turtles sending info to monitor using rednet
First let me explain. I've been learning CC for about a week now and I have a working system of mining turtles, they work as I planned, but now
I want to add a way for them to report their location and fuel level back through rednet to a monitor. I think I know how to accomplish that part,
my problem is the monitor, I've been looking for a way to update the monitor in real time and display the information in a specific way.
If anyone can give me an idea on how to get this working I'm fairly certain I can figure this out. Thanks in advanced for any help.
286 posts
Location
Bonn Germany
Posted 06 February 2013 - 11:52 AM
Hi,
you could send a rednet message with the coordinates and the fuel level to the computer whenever the coordinates change. The computer has to be in an infinite while loop looking for such a message. It then has to clear the screen and print out your text in which you can integrate the values from your rednet message.
You may wanna look at string.sub() to fin out about splitting up a string. Btw you can concatenate two strings like this print("Fuellevel: "..fl)
2217 posts
Location
3232235883
Posted 06 February 2013 - 11:52 AM
just have the turtle broadcast its fuel level after it moves
then have the monitor display the information on the monitor
EDIT: ninjas
2 posts
Location
Baltimore, MD
Posted 06 February 2013 - 11:59 AM
Thanks for the quick replies. I probably should have been more descriptive in the original post. The turtles do send the info back to the monitor. I'm looking for way to make the monitor look like this:
http://imgur.com/iMXiK6Huntil it receives information, then updates accordingly.
2217 posts
Location
3232235883
Posted 06 February 2013 - 12:03 PM
you will have to use term.setCursorPos and then term.write to print it
286 posts
Location
Bonn Germany
Posted 06 February 2013 - 12:03 PM
As I've said keep the computer in a while loop and wait for the rednet message then split up the coordinates and the fuellevel into variables (string.sub())
now print like this
monitor.write("--------------------------------")
monitor.setCursorPos(0,1)
monitor.write("Position X: "..x)
monitor.setCursorPos(0,2)
monitor.write("Position Y: "..y)
[...]
monitor.setCursorPos(0,3)
monitor.write("--------------------------------")
and so on.
2217 posts
Location
3232235883
Posted 06 February 2013 - 12:12 PM
bah, that will make it a bit flashy
i prefer to render the background once
286 posts
Location
Bonn Germany
Posted 06 February 2013 - 12:34 PM
You're right that would probably be better.