This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Sphaeranthus's profile picture

Wireless turtle server crashing my game

Started by Sphaeranthus, 11 January 2013 - 03:10 PM
Sphaeranthus #1
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
Heracles421 #2
Posted 11 January 2013 - 04:58 PM
Hmm, have you tried running multiple built in programs at the same time?
Also, a crash log would be better to determine the cause of the crash
Sphaeranthus #3
Posted 11 January 2013 - 06:53 PM
No, I'm not quite sure what you mean by running multiple programs at the same time. My script has the client rename any program it gets sent from the server as TEMP and just runs that. I don't have any crash logs because what happens is the game begins to slow down and then computercraft objects become unresponsive to right clicks. Then the turtles stop moving after another minute or so but I can still move around and interact with other parts of the world. When I am playing in a single player mode it everything just freezes and I have to kill the game with task manager. When I host a multiplayer server on another computer I get disconnected with a java socket error and when I try to log back in it gets stuck at "loggin in…" and the log does not even show player disconnecting or anything.
Northfleet #4
Posted 21 January 2013 - 08:53 AM
Please can you gve me the pastebin for the original code before you disabled the real-time as this should save me time trying help you. thanks.
ChunLing #5
Posted 21 January 2013 - 02:23 PM
I'm pretty sure my last posted version of clfn/rctrl accomplished all of this with a fairly compact code. It might be easier for you to read it and see how I was doing what I was doing and adapt that to your needs rather than me figuring out how to modify what you've got to the same end (partly because your code is longer and partly because you know your end goal better than I would).