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

General Questions (GPS, Rednet and Events)

Started by Arduin, 03 April 2012 - 10:43 AM
Arduin #1
Posted 03 April 2012 - 12:43 PM
Hi there!

I got some questions.

First of all the range of rednet. I found this line in die mod_ComputerCraft.cfg "modem_range=64"
If I do change the 64 to lets say 128, will this be the new range in blocks a modem can send?

I ask because I wanted to setup a gps network around our homebase (got a small server with some friends).
The setup I use is 4 Computers around the base, all running "gps host x y z". But if I now setup a new computer
in the middle of our base I can't get my position by "gps locate". It just says no host in range.
The reason for this gps network are turtles which are able to get their position through the gps for navigating.

(Edit: the computers use modems)

The second question is about rednet and events. I am able to start a programm on a turtle through rednet
(basically the program on the turtle listens to events and starts if the right one comes in). But is there a possibility to
stop a running program through a rednet event? So that I can start and stop a turtle? I read about coroutines but we
use minecraft 1.2.3 with computercraft 1.3.1 and there is still this bug mentioned, that coroutines will generate threads
which run forever..

Hope somebody can help

Greetings,
Ben
Liraal #2
Posted 03 April 2012 - 01:58 PM
I think that to stop a program you can do something like:

function waitAndTerminate()
while true do
a,b=rednet.receive()
if b=="terminate" then os.queueEvent("terminate") end
end
end
function splitThread()
parallel.waitForAll(
waitAndTerminate,
function() os.run({},"rom/programs/shell") end
)
return true
end

Then you run splitThread() and it automatically terminates running program whenever you send a message. It should work, but I haven't tested it.
Arduin #3
Posted 03 April 2012 - 02:17 PM
[deleted]
Arduin #4
Posted 03 April 2012 - 02:23 PM
[deleted]
Arduin #5
Posted 03 April 2012 - 02:26 PM
ouch I'm stupid ^^ misunderstood everything. Your code works fine. Just didn't realize that it has to run the shell and then I can start myprogram seperately.

Thank you :)/>/>