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

Autostartup

Started by KaoS, 15 June 2012 - 05:29 AM
KaoS #1
Posted 15 June 2012 - 07:29 AM
I have been trying a few things out in my single player - creative test map. one of them is to make turtles/computers automatically do something when placed. what I do is add a string to the startup file (I know it won't work online) that makes turtles run one program and computers another when they start up. the program then activates the modem on the right if present and waits for 1 second for input which is interpreted in various ways, I place a host or master PC and broadcast the command to be executed when I start up my turtles etc so when placed they automatically begin a pre-programmed routine determined by the master PC. THIS DOES NOT WORK. the turtle does not run the startup file until you open its interface so I cannot make one turtle run around and place computers in the sky to act as GPS satellites etc as he cannot activate them. it makes things 10x harder. is there a way to make it run the startup file when placed?? I may be asking a stupid question but I only got the MOD yesterday, not much time to learn. thanks in advance
Cloudy #2
Posted 15 June 2012 - 09:37 AM
The Turtle and the Computer expose peripheral methods. Place a computer by the side listening for the peripheral attach method - and then call peripheral.call(side, "turnOn"). It will turn on the turtle which will execute the file as specified.

Incidentally, rather than placing the startup code in rom, you could put a disk drive on another side with a startup file on it, as all computers and turtles will look there as part of the boot process.
KaoS #3
Posted 16 June 2012 - 07:11 AM
Yes, you are correct. I am just working on the concept. However if I do as you say I still have to actually right click the turtle/computer to make it start up, only then does it run the startup file. that is what I am trying to eliminate
Cloudy #4
Posted 16 June 2012 - 09:10 AM
I just told you a method above to avoid right clicking on the turtle - read what I said about the peripheral interface. You can have a computer automatically start up turtles which are placed by it.
MysticT #5
Posted 16 June 2012 - 07:12 PM
Like Cloudy said, you can use the peripheral api to do it, you would need to start the computer just once, and then it turns on any turtle that's placed next to it. The code for the computer would be really simple, and you can place a disk drive and a floppy with a startup program that copies a program to the turtle startup.
KaoS #6
Posted 17 June 2012 - 05:15 AM
Ah excellent!! thanks for the help. one remaining question. turtles can listen for peripherals can't they?
KaoS #7
Posted 17 June 2012 - 05:48 AM
tested. works. thanks so much for the help. now I can set up GPS satellites and then set up new ones. the turtle just places them and in their initial listening state when they wait for input from the master PC there is a command to become a GPS satellite which will be broadcast from the turtle placing the computer. the computer then gets its co-ordinates from the nearest GPS satellite outpost to auto set up, that way I can have one turtle run around and place GPS sites all over the place for my nuke bombing strategy (I can have turtles bombing any co-ordinates and as they go they stop and listen for input for a fraction of a second so they can be cancelled or redirected mid-bombing, I just need to input a command relay so my satellites also transfer these commands)
KaoS #8
Posted 17 June 2012 - 07:54 AM
1 problem. a turtle cannot place a disk into a disk drive and/or retrieve it afterwards. any solutions?