7 posts
Posted 12 October 2012 - 09:52 AM
Hi,
I want to write some code that would allow me to place multiple turtles from a single turtle, and load those placed turtles with some code that I've already written.
I have written my own excavate program, but I want it to be executed by multiple turtles all deployed from one "master" turtle, in a swarm-like fashion. It is pretty much identical to the setup that eloraam made here at 27:00 [media]
http://www.youtube.com/watch?v=oanR7y4erbU&t=27m0s.[/media] I would greatly appreciate any help that can be offered!
818 posts
Posted 12 October 2012 - 09:57 AM
How much lua experience do you have? If none, I would recommend something easier to code before doing this. also, there is a nice wiki :)/>/>
7 posts
Posted 12 October 2012 - 10:00 AM
I've got python experience but virtually no lua experience. I've been looking through the wiki but I really don't know which part I should be focusing on, if you could direct me to the relevant page(s) that would be good as well
1111 posts
Location
Portland OR
Posted 12 October 2012 - 10:01 AM
Well the activation and installation is pretty simple.
You will want to have the main turtle place the new turtles next to a disk drive. In that disk drive have a disk with two files. One being the program you want copied onto the new turtle and another being startup that copies the other file as startup onto the turtle.
Example startup on disk:
if not fs.exists("/startup") then
fs.copy("disk/fileName", "/startup")
end
disk.eject("sideDiskDriveIsOn")
os.reboot()
Now to activate the turtle simply use the peripheral api:
local computer = peripheral.wrap("front") -- used front since the turtle should be in front of this one after being placed change if that is not true
computer.turnOn()
The rest is not so easy.
7 posts
Posted 12 October 2012 - 10:09 AM
Well the activation and installation is pretty simple.
You will want to have the main turtle place the new turtles next to a disk drive. In that disk drive have a disk with two files. One being the program you want copied onto the new turtle and another being startup that copies the other file as startup onto the turtle.
Example startup on disk:
if not fs.exists("/startup") then
fs.copy("disk/fileName", "/startup")
end
disk.eject("sideDiskDriveIsOn")
os.reboot()
Now to activate the turtle simply use the peripheral api:
local computer = peripheral.wrap("front") -- used front since the turtle should be in front of this one after being placed change if that is not true
computer.turnOn()
The rest is not so easy.
Thanks for the prompt reply. For the startup program, do I need to eject the disk? why can't I keep it in there for the next turtle to use?
Would it be possible copy all my code across on startup, then just add shell.run("quarry") to the startup program? – quarry is the name of the program i want to run automatically
This would make the turtle execute the "quarry" program on startup wouldn't it?
7 posts
Posted 12 October 2012 - 10:19 AM
Actually, on further investigation, this program does seem to be a bit too complicated for my current lua proficiency. I am going to try and find someone who has already written this code (or a similar code), and just try and adapt it for my purpose.
Thank you so much for your help, even though it was beyond me ha, I appreciate it.
1111 posts
Location
Portland OR
Posted 12 October 2012 - 10:45 AM
Thanks for the prompt reply. For the startup program, do I need to eject the disk? why can't I keep it in there for the next turtle to use?
Would it be possible copy all my code across on startup, then just add shell.run("quarry") to the startup program? – quarry is the name of the program i want to run automatically
This would make the turtle execute the "quarry" program on startup wouldn't it?
So for future reference or anyone else that looks at this and is wondering.
That would be possible just by adding a couple of lines of code to the disk startup file.
fs.copy("disk/fileName", "/startup") -- would be good to keep this and have it run quarry in case the turtle gets turned off it.
fs.copy("disk/quarry", "/quarry")
shell.run("/quarry")
I think that would do the trick, haven't tried it but I assume that once the turtle moves away from the drive it should be ready for the next one.
You could also remove the if statements, they are just a habit of mine.
7 posts
Posted 12 October 2012 - 11:04 AM
I'm getting an error when I try and turn on the turtle that has been placed. I am executing the code:
local computer = peripheral.wrap("front")
computer.turnOn()
But I am getting the error: attempt to index ? (a nil value)
If I can get this working, I think I may have a working code. (i've used the fs.copy() function on startup)
Nevermind, I've just found a typo in my code.
Thanks again for all the help!
15 posts
Posted 13 October 2012 - 11:26 PM
I think I may be on the same sort of project here… this post helped me with my little dilemma :)/>/>
with my application all you do is put down a pc on the left of a disk drive and boot it up, this will be the main master controller for all the bots, then you place your bots on the right of the disk drive and automatically it will register to the master controller and be on its way as soon as you boot it :)/>/>
however its horribly unfinished but this, for me anyways, was the first big hurdle… I have a java programming background that may help a bit…
so far in my application you can register a turtle and it will automatically get into position and wait for you to enter GO on the master controller… but the GO isn't done yet
I think I may be on the same sort of project here… this post helped me with my little dilemma :)/>/>
with my application all you do is put down a pc on the left of a disk drive and boot it up, this will be the main master controller for all the bots, then you place your bots on the right of the disk drive and automatically it will register to the master controller and be on its way as soon as you boot it :)/>/>
however its horribly unfinished but this, for me anyways, was the first big hurdle… I have a java programming background that may help a bit…
so far in my application you can register a turtle and it will automatically get into position and wait for you to enter GO on the master controller… but the GO isn't done yet