Jump to content

Another problem: wireless modem


Supershadow30

Recommended Posts

Wrapping a modem (or more generally a peripheral) is the term used when you execute something like:


modem = peripheral.wrap("back")



 

which then allows you to do this:

 



modem.open(2)



 

instead of:

 



peripheral.call("back", "open", 2)

So it's a convenience more than anything. The peripheral.wrap function works on any peripheral not just modems.

As to where you would wrap the modem and open the network channel would be early if not first before the rest of your functionality. Typically you'd have some form of configuration and setup to do before the meat of your code comes into play.

Just a question, and I'm making an assumption that you're new to CC programming at least, why did you jump to using modems as a first step? You don't have to wirelessly send it commands. In fact, that's more work to make that function properly. You can place a turtle down and get the same basic console as you would when using a computer. You can place a disk drive next to a turtle just like a computer and be able to access the files on it. In fact, if there is a script named "startup" on a disk the turtle will execute that script on the disk when the turtle boots up. A turtle boots up when first placed or when you press and hold ctrl + R (command + R on a mac I think).

With turtles I recommend that approach because it's so easy to impulsively remove a turtle to move it and after the fact realize that had your code on it. The files are recoverable but not while in game. Someone with access to the server files would have to retrieve it for you. Pain in the ass.

Link to comment
Share on other sites

Just put a label on the turtel and all programs will remain when you breake the turtle. But still backup all programs to a disk since there is a chance that an active turtle will be reseted into an new created normal turtleif the server crash or is rebooting. So that means you have lost all programs in it and the tool if you had on on it.

But what you said about "startup" from a diskdrive sounds intresting. Is it a program I have to program and name it to startup or is it a buildin program in turles?

Link to comment
Share on other sites

Just put a label on the turtel and all programs will remain when you breake the turtle. But still backup all programs to a disk since there is a chance that an active turtle will be reseted into an new created normal turtleif the server crash or is rebooting. So that means you have lost all programs in it and the tool if you had on on it.

But what you said about "startup" from a diskdrive sounds intresting. Is it a program I have to program and name it to startup or is it a buildin program in turles?

Just like real computers, CC computers (and turtles, which are literally computers with the ability to move and perform certain actions) are able to be booted off a removable media device. In CC's case that mean's disk drives with disks in them. It's already a feature of CC to execute any script (program) named startup in the root directory. If there is a disk drive attached to a computer with a disk inside with a script named startup it will run that instead. It's a file you would create as or rename to startup and not a built in program.

I once used a "swarm" based turtle mining script which utilized a "master" turtle placing blank "slave" turtles next to a previously positioned disk drive. The slave turtles would boot up, run the startup script from the disk and head off on their way to dig the hole I'd requested. It was complicated as hell to get to work but it was pretty cool to have 16 turtles digging a 64x64xbedrock hole when I did have it working. It was far too error prone to use as a primary mining technique though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...