Posted 11 January 2013 - 04:10 PM
I'm trying to create a system to control multiple wireless mining turtles from a single computer.
It currently functions by running a server program on startup that detects nearby turtles and adds them to a list of clients. Each turtle has a startup script that attempts to connect to the server. Once a connection is established the server sends a client program for the turtle to execute with shell.run("client") The client script contains some basic functions for movement, digging, and placing blocks. The server can also send arbitrary programs to the turtles that get called from the client program. I read about local and global variables and my idea was to use the functions in the client program as a basis for running more complicated routines that can be distributed from the server.
I originally also had the turtles broadcast some information such as their location and fuel level to the server every second so they can all be monitored from the computer terminal through some sort of GUI. The server would automatically disconnect clients that had not responded for a while. I have since disabled this since it caused my game to crash and I thought it might be due to too many rednet messages being sent too quickly. However, it still seems to be pretty unstable even without the regular status updates. More specifically, when I tried running a simple test program called "quarry" from the server on 3 turtles, it would crash in about 10 or so minutes.
I am very new to minecraft and lua so I'm not sure if I'm going about this correctly. In summary, I would like my programs to meet the following requirements without crashing my game:
1. distribute and run programs wirelessly to multiple turtles from a single computer
2. be able to monitor each turtles' status in real time from the terminal
3. individually control any number of connected turtles independently
What changes should be made to my scripts to achieve these goals?
Thanks for taking time to read this. Here are the scripts (I started off commenting things but then got lazy):
Server startup script: http://pastebin.com/er94DY6N
Turtle startup script: http://pastebin.com/gpCe1aN0
Client script: http://pastebin.com/h9DffiFM
Quarry script: http://pastebin.com/ue3az2TH
It currently functions by running a server program on startup that detects nearby turtles and adds them to a list of clients. Each turtle has a startup script that attempts to connect to the server. Once a connection is established the server sends a client program for the turtle to execute with shell.run("client") The client script contains some basic functions for movement, digging, and placing blocks. The server can also send arbitrary programs to the turtles that get called from the client program. I read about local and global variables and my idea was to use the functions in the client program as a basis for running more complicated routines that can be distributed from the server.
I originally also had the turtles broadcast some information such as their location and fuel level to the server every second so they can all be monitored from the computer terminal through some sort of GUI. The server would automatically disconnect clients that had not responded for a while. I have since disabled this since it caused my game to crash and I thought it might be due to too many rednet messages being sent too quickly. However, it still seems to be pretty unstable even without the regular status updates. More specifically, when I tried running a simple test program called "quarry" from the server on 3 turtles, it would crash in about 10 or so minutes.
I am very new to minecraft and lua so I'm not sure if I'm going about this correctly. In summary, I would like my programs to meet the following requirements without crashing my game:
1. distribute and run programs wirelessly to multiple turtles from a single computer
2. be able to monitor each turtles' status in real time from the terminal
3. individually control any number of connected turtles independently
What changes should be made to my scripts to achieve these goals?
Thanks for taking time to read this. Here are the scripts (I started off commenting things but then got lazy):
Server startup script: http://pastebin.com/er94DY6N
Turtle startup script: http://pastebin.com/gpCe1aN0
Client script: http://pastebin.com/h9DffiFM
Quarry script: http://pastebin.com/ue3az2TH