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

Possible for one turtle execute a program on another?

Started by jackmott, 30 September 2015 - 12:40 AM
jackmott #1
Posted 30 September 2015 - 02:40 AM
For instance just say, hypothetically, a crafty turtle crafted another crafty turtle.

What would it take for the parent to send and/or execute a program on the newly crafted turtle?
TYKUHN2 #2
Posted 30 September 2015 - 02:48 AM
One possible way to do it:
Resource packs. Adding in a "startup" script that accepts file transmissions and executes them. Resouce pack files are automatically added to computers.

Another way is a bit more weird with the copyright. Be careful and do not distribute.
Unpack computercraft.jar
Look for the startup script.
Edit.
Repack.
Edited on 30 September 2015 - 12:49 AM
valithor #3
Posted 30 September 2015 - 03:01 AM
The best way to do this would actually be for the first craft turtle to carry a disk drive and a floppy disk with a startup you want the new turtle to run. This startup could contain instructions for copying files over, executing a program, etc…

So what you would do is place the disk drive, put the floppy in the drive (turtle.drop while facing the drive), and then place the turtle by the drive. All that is left is wrapping the turtle you placed as a peripheral and turning it on or turning it on via: peripheral.call(side,"turnOn"), where side is the side the turtle is on.
Edited on 30 September 2015 - 01:05 AM
TYKUHN2 #4
Posted 30 September 2015 - 03:04 AM
You mean turtle.turnOn()? Else skip the wrapping.
valithor #5
Posted 30 September 2015 - 03:05 AM
You mean turtle.turnOn()? Else skip the wrapping.

To remotely turn on another computer you have to either wrap it or do what i did and use peripheral.call.

edit:

You posting that caused me to notice a bad wording I had :P/>
Edited on 30 September 2015 - 01:06 AM
jackmott #6
Posted 30 September 2015 - 03:14 AM
Thanks guys, this helps. Sounds like it is possible!

Once I turn the child turtle on, how do I arrange for it to run a particular program though?
If it is next to a disc drive is there some convention where it looks for a program called startup, or something?
TYKUHN2 #7
Posted 30 September 2015 - 03:15 AM
Startup files are always run when a computer turns on.

Disk startup files are always prefered.

Startup files are the files with the name startup

I have a feeling I got ninja'd Amazingly not!
Edited on 30 September 2015 - 01:16 AM
valithor #8
Posted 30 September 2015 - 03:15 AM
Thanks guys, this helps. Sounds like it is possible!

Once I turn the child turtle on, how do I arrange for it to run a particular program though?
If it is next to a disc drive is there some convention where it looks for a program called startup, or something?

Once you turn the turtle on it will run whatever program is named startup on the floppy disk in the disk drive. So the disk drive with the floppy needs to be placed first.

Ninja'd :P/>
Edited on 30 September 2015 - 01:15 AM
jackmott #9
Posted 30 September 2015 - 03:16 AM
Can turtle A wrap turtle B then call peripheral.call on turtleB to execute commands in the os?
TYKUHN2 #10
Posted 30 September 2015 - 03:17 AM
No not directly, but via a disk with startup program code can be "injected" in a sense into the turtle. Turtle A can modify the startup program and turn on Turtle B which will run the disk program. Unloading the chunk will cause Turtle A to run the disk however.
jackmott #11
Posted 30 September 2015 - 03:18 AM
von Neumann turtle here I come
valithor #12
Posted 30 September 2015 - 03:19 AM
Can turtle A wrap turtle B then call peripheral.call on turtleB to execute commands in the os?

The way I worded it at first is a little confusing. So when you wrap a computer there are limited functions that you can use on the computer. a few of these include: turnOn, shutdown, reboot, isOn etc… However, you can not actually run any code on the computer itself from a external computer.

The two ways I meant:

turt = peripheral.wrap(side)
turt.turnOn()

or


peripheral.call(side,"turnOn")

peripheral.call is essentially a shorter way of calling a single function on a peripheral.
Edited on 30 September 2015 - 01:27 AM
jackmott #13
Posted 30 September 2015 - 03:24 AM
Got it. So easiest way for these things to breed is probably a queen turtle managing "the drive" and worker turtles bring it resources, she crafts the children, programs them, then off go the new workers
TYKUHN2 #14
Posted 30 September 2015 - 03:28 AM
You can also have each run the same code to find the harddrive using GPS and making a new turtle and copying it's code.