2 posts
Posted 05 April 2014 - 12:42 AM
Ok so im fairly new to computer craft and I dont know much about programing. I have a program i made saved on a disk and the drive is connected to my computer. I have a modem on my computer and a wireless crafty turtle. How do I turn on the modem and connect my turtle to my computer. Also would I beable to run the program thats on the disk through the network and have it run on the turtle?
1281 posts
Posted 05 April 2014 - 10:57 AM
What you need is the rednet API.
http://computercraft.info/wiki/Rednet_%28API%29As for your other question, you can, but it's gonna take some programming on your part. As you'll have to transmit the program wirelessly. There's no pre-installed function to do this.
1852 posts
Location
Sweden
Posted 05 April 2014 - 11:12 AM
When you've read the link above posted by CometWolf, You can run the program that's on the disk through rednet
Sender( Computer )
rednet.open( "<Side>" ) -- Change to the side you have the modem on
local args = { ... }
if #args < 2 then
error( "Usage: <Filename> <ID>", 0 )
end
if fs.exists( args[1] ) then
if not tonumber( args[2] ) then
error( "ID must be a number!", 0 )
end
local file = fs.open( args[1] )
local code = file.readAll()
file.close()
rednet.send( tonumber( args[2] ), code )
else
error( "File doesn't exist!", 0 )
end
Receiver( Turtle )
rednet.open( "right" ) -- Change 'right' to the side you're using, Right is usually the default on wireless turtles
local _id = 0 -- Change 0 to the computers id, This is to prevent from other computers sending to this turtle while it's listening
local id, code
repeat
id, code = rednet.receive()
until id == _id
local func = loadstring( code )
func()
To get the id of the turtle and computer just type id then press enter in the shell and it will show the id.
This is just a simple example of how you can run the file that's on the computer on the turtle without actually creating a new file on the turtle.
Edited on 05 April 2014 - 09:12 AM