1 posts
Posted 04 September 2012 - 11:12 PM
Sorry if i posted this in the wrong place, this is my first post. Anyway, I have been trying to get this to work for some time now, but I cant completely figure it out. I would like to somehow make a server within the game so i could go on any computer in my house, and access the network. I am looking to have the server control all the doors, and lights, so I could go up to any console, and turn on the lights, doors, ect. I think wireless redstone would work, but I am unsure of how to write a program to tell all the other computers to look on the server, and which door/light to power. Any help would be appreciated. Thanks!
65 posts
Location
The Internet
Posted 05 September 2012 - 01:22 AM
Sorry if i posted this in the wrong place, this is my first post. Anyway, I have been trying to get this to work for some time now, but I cant completely figure it out. I would like to somehow make a server within the game so i could go on any computer in my house, and access the network. I am looking to have the server control all the doors, and lights, so I could go up to any console, and turn on the lights, doors, ect. I think wireless redstone would work, but I am unsure of how to write a program to tell all the other computers to look on the server, and which door/light to power. Any help would be appreciated. Thanks!
Well, Computercraft comes shipped with a form of the internet,
rednet. It allows connections between computers and turtles that have modems attached to them. Only wireless turtles can access the rednet, and not normal/mining/farming/etc. turtles. Computers need to have modems attached to any of the sides, which can be done by pressing your sneak key, and then the key to place blocks.
A few notes:
- You must use rednet.open() before you can use the network, with the side that the modem is connected to inside the parenthesis. Possible values are: Top, Bottom, Left, Right, Front, Back.
- rednet.receive() will stop after one message. To make the program listen indefinitely, you need to make it into a loop, such as a while loop.
- rednet.send() uses two variables, the first of which is the computer ID of the computer to get the signal, and is a number. This should not be in quotations ( " " ), but instead a plain number. For Example: rednet.send(3, "Hello computer three!"). This sends the computer with the ID of three the message.
- rednet.send returns a value of true or false, saying as to whether or not the message was sent. Having a message sent does NO mean that it was received. Possible errors that could make messages not received are that the receiving computer is not listening for messages, or it is not in range, or the modem is not open.