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

[Lua] Controlling computers with turtles.

Started by GhostShadow, 09 January 2013 - 12:00 AM
GhostShadow #1
Posted 09 January 2013 - 01:00 AM
I have seen a youtube video[http://www.youtube.c...?v=fLR_tgXiq7Q] where turtles place multiple computers, install a software and run the computer.
I know this has to be done with peripherals but how?
theoriginalbit #2
Posted 09 January 2013 - 01:03 AM
take a look at the turtle, fs and peripheral apis on the wiki :)/> everything you should need is in those :)/>
GhostShadow #3
Posted 09 January 2013 - 04:53 AM
I already went through these.


Method name Description
computer.turnOn() Turns on the Computer or Turtle.
computer.shutdown() Shuts off the Computer or Turtle.
computer.reboot() Reboots the Computer or Turtle.
computer.getID() Gets the ID of the Computer or Turtle.
I went through the turtle API too. Not much luck. :(/>
theoriginalbit #4
Posted 09 January 2013 - 05:02 AM
its all about combining whats in these APIs. for example:

turtle.forward() turtle.turnLeft() turtle.turnRight() can all be used to get the turtle into place.
turtle.select( slotNumber ) turtle.place() turtle.dig() can be used to place and pickup computers / disk drives
turtle.drop() and turtle.suck() are useful for putting things into inventories (say a disk drive maybe? )
peripheral( "front", turnOn ) seems a good way to turn on a computer to me.

and as it goes for installing code have a startup file on a disk similar to this:

local file = io.open( "/startup", "w" )
file:write( [[

-- Program to install goes here

]] )
file:close()

as long as the computer is turned on after the disk is in the adjacent drive that code will 'install' the program onto the computer, then the turtle can collect the drive again and move on…
GhostShadow #5
Posted 09 January 2013 - 05:04 AM
Ah I see.
kinda weird, I thought editing the startup file would affect the startup file of the turtle.
GhostShadow #6
Posted 09 January 2013 - 05:16 AM
Nah dude, IDK what am I doing wrong, but the turtle is editing its own startup file, not the adjacent computer's :(/>
GhostShadow #7
Posted 09 January 2013 - 05:20 AM
Ow, I got it! The disk itself has a autoplay feature. Thanks a lot :D/>
theoriginalbit #8
Posted 09 January 2013 - 05:58 AM
haha yeh. its the turtle that has the startup file that installs onto the computer. the turtle is just the medium it moves around with. and its obviously in charge of turning on the computer too.