Jump to content

Recommended Posts

Posted

i dont realy know... i tried al LOT of things but i cant get it to work.

What did you try writing?

"A lot of things" is useless to a forum.

Write out specifically some examples of what you tried.

Posted

i put a modum RIGHT to a computer and typed: rednet.open ("right") i did the same w/ the other computer.

than i tried: rednet.send ("redstone.setOutput ("back", true") i also tried it wich the other computer's ID: (16, "redstone.setOutput ("back", true)")

but it doesnt work...

Posted

You want one computer to typ the password in and let it send a message to another computer to open the door right?

Well, if the password is right, let the password computer send a message through rednet like "PasswordCorrect". Then the second computer, the one which opens the door, receives the message and compares it to "PasswordCorrect". If it is true, then you can run your little program to then open the door for a few seconds and then close it again. That's what I ment.

Posted

Was that so hard? Thanks, multiple problems are obvious here:

1) You can't just type stuff in. If you want to run lua commands directly yourself, you have to type >>lua first to get into the program that lets you run commands from the shell. Otherwise things like rednet.send() MUST be run from within a saved program.

2) I'm pretty sure you can't include quotation marks inside of a string, like send("hello "world""), because it will simply interpret the quotes right before 'world' as the end of the string and get all confused and give you errors. This means that even if you knew what you were doing, you couldn't send a full command to another computer that includes quotes, at least not in one message.

3) Messages that you send in rednet.send() do not get executed on the other computer as commands. They simply get sent as messages. the receiving computer will receive it, and save the set of characters to the "message" variable. That's all it does! Nothing else. If you want it to do anything with the message, you have to explicitly tell it to, like:

Computer 1 (from within a program):

rednet.send(16,"Open Sesame!")

Computer 2:

id, message = rednet.receive() <-----including the id, message at the beginning is crucial.

if message == "Open Sesame!" then

rs.setOutput("back",true)

end

Posted

Was that so hard? Thanks, multiple problems are obvious here:

1) You can't just type stuff in. If you want to run lua commands directly yourself, you have to type >>lua first to get into the program that lets you run commands from the shell. Otherwise things like rednet.send() MUST be run from within a saved program.

2) I'm pretty sure you can't include quotation marks inside of a string, like send("hello "world""), because it will simply interpret the quotes right before 'world' as the end of the string and get all confused and give you errors. This means that even if you knew what you were doing, you couldn't send a full command to another computer that includes quotes, at least not in one message.

3) Messages that you send in rednet.send() do not get executed on the other computer as commands. They simply get sent as messages. the receiving computer will receive it, and save the set of characters to the "message" variable. That's all it does! Nothing else. If you want it to do anything with the message, you have to explicitly tell it to, like:

Computer 1 (from within a program):

rednet.send(16,"Open Sesame!")

Computer 2:

id, message = rednet.receive() <-----including the id, message at the beginning is crucial.

if message == "Open Sesame!" then

rs.setOutput("back",true)

end

lua or program for computer 2? and does it stay on forever?

Posted

Oh sorry, program as well for computer 2. the "lua" program basically lets you test stuff out conveniently. it won't do anything forever (at least not efficiently). More of a sandbox to let you act like a program. All serious things you will want to build into permanent programs that you then run.

The program will NOT stay on forever. The computer will actually reboot whenever the server restarts or possibly sometimes even when its chunks get unloaded, I'm not sure. However, whenever the computer reboots, it will always immediately run the program called "startup" in its memory. So if you want something to constantly be running on a computer, code it in a program labeled "startup" and it will always be running unless somebody stops it. Just be aware that it may occasionally start over from the top of the program unexpectedly (server restarts, etc.), so code with that in mind.

Posted

Oh sorry, program as well for computer 2. the "lua" program basically lets you test stuff out conveniently. it won't do anything forever (at least not efficiently). More of a sandbox to let you act like a program. All serious things you will want to build into permanent programs that you then run.

The program will NOT stay on forever. The computer will actually reboot whenever the server restarts or possibly sometimes even when its chunks get unloaded, I'm not sure. However, whenever the computer reboots, it will always immediately run the program called "startup" in its memory. So if you want something to constantly be running on a computer, code it in a program labeled "startup" and it will always be running unless somebody stops it. Just be aware that it may occasionally start over from the top of the program unexpectedly (server restarts, etc.), so code with that in mind.

oh thank you so much for this all. yet... i still have 1 question: how do i edit the startup? when i do ''edit startup'' it remakes the program startup. so how do i do that?

Posted

oh thank you so much for this all. yet... i still have 1 question: how do i edit the startup? when i do ''edit startup'' it remakes the program startup. so how do i do that?

Huh? You're probably not saving your work. Do >>edit startup, then write your code, then hit Ctrl and select "save" on the bottom with arrow keys. Then Ctrl aagain and hit "exit." If you don't save your work then it just goes poof when you log off or exit the editor.

Posted

Huh? You're probably not saving your work. Do >>edit startup, then write your code, then hit Ctrl and select "save" on the bottom with arrow keys. Then Ctrl aagain and hit "exit." If you don't save your work then it just goes poof when you log off or exit the editor.

i do save, i just thought i rewright the whole command wicht edit.

Posted

Now what if they send the opening message to computer 2?

I was not giving him an example of an ACTUALLY secure password program. I was only answering his questions about how rednet messages work.

If you want a secure password system, then you wouldn't code in the exact message into computer 1. You would ask for user input for the code, with:

print("Password: ")

password = read("*")

rednet.send(16,password)

So the actual password wouldn't be written on the external computer anywhere. Thus, people wouldn't KNOW what to send to computer 2.

Note: Even the above setup is not actually fully secure. Somebody else, if they can access the root on your login computer (which they almost certainly can), can install a keylogger program that saves every keystroke. Then they wait until you log in once, then look up the letters you typed. Keyloggers are really easy in lua and unless you're VERY observant and paranoid, you probably wouldn't notice one was on your computer. There are much better and more secure password systems than using computercraft. Notably, an ender chest system with item detectors works as a much more secure password.

The only way I can think of to prevent people from installing a keylogger would be to surround the computer on 5 sides with personal safes (so they cant boot the computer from disk), and write in code that prevents terminating the startup program. And I might be wrong about even that (it's possible that you can hold down ctrl-R and in the split second before it actually reboots, hit ESC and then place a disk drive and disk in front of the computer. You might need an autoclicker to do it fast enough, but I assume it is possible OR program a turtle to move in front, reboot the computer and then instantly blockbreak itself and deploy a drive and disk within a tick or two...?)

Posted

Now what if they send the opening message to computer 2?

i do: edit startup

and this code:

print ("Enter Password")

and than: edit "password name"

and this code:

print ("Acces Granted! You Have 5 Second To Proceed. Press ESC To Exit. ")

redstone.setOutput ("back", true)

sleep (5)

redstone.setOutput ("back", false)

os.reboot ()

and now i use that rednet thing :D

Posted

i found a way to let computer 2 always recieve it:

edit startup

and this code:

id, message = rednet.receive()

if message == "password" then

rs.setOutput("back",true)

reboot.os ()

end

made the program in the startup and make it roboot when finished, end must be placed, once done and restarted the computer you cant do anything... like edit a program.

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...