Jump to content

Computercraft scripting help (Wireless modems)


Recommended Posts

So, I got bored n decided to try n create a wireless signal through computercraft that would activate a redstone signal at the second location.

I'd appreciate any input that someone knowledgeable on this topic could contribute.

My current script has no error, but doesn't work as hoped (just btw, modem is on the left of the computer)

___________________________________________

pass = "zsakul"

rednet.open("left")

rednet.receive(999999999999999)

input = read()

if input == pass then

exit() -------- (where i suspect problem occurs)

redstone.output("back", true)

else

os.reboot()

end

____________________________________________

The script on the sending computer works fine, so i don't need to post it.

Link to comment
Share on other sites

yeah, exit() completely stops your program and just quits. why not try using a loop?


pass="zsakul"

renet.open("left")

while true do

 input = read()

 if input == pass then

 redstone.output("back", true)

 end

end

basically what this does is loop forever waiting for a a rednet message, then set the redstone output to true when it finally gets the password. it's obviously barebones and doesn't turn it off, but there you go.

Link to comment
Share on other sites

If I'm right this should work:

rednet.open("left")

while true do

senderID, input = rednet.receive()

if input == "zsakul" then

redstone.output("back", true)

end

end




rednet.receive() doesn't have a required timeout setting, if you don't set it it doesn't have a timeout

And I suggest you put something in your code to turn the redstone off again like:


rednet.open("left")

while true do

senderID, input = rednet.receive()

if input == "zsakul" then

redstone.setOutput("back", true)

sleep(1) --wait one second

redstone.setOutput("back", false)

end

end

Link to comment
Share on other sites

That is beautiful, tyvm, if you have some time to kill

then something else that would be useful would be instead of a timed delay, sending another command to disable the redstone.

Also a nice touch would be a script to send the command from the first computer without having to type

lua

rednet.broadcast("x")

exit()

EDIT: I edited the script to have the on off feature, but i still havn't designed a system of just typing in the word on the first computer without entering lua

Link to comment
Share on other sites

You could always make a new program with a convenient name that does this:

rednet.open("yoursidehere")

rednet.broadcast("yourmessagehere")

rednet.close("yoursidehere")




if you want it send on redstone this will help:


rednet.open("yoursidehere")

while !(event=="char" and p1=="q") do

 event,p1=os.pullEvent()

 if event=="redstone" then

 if redstone.getInput("yoursidehere") then

  rednet.broadcast("onmessage")

 else

  rednet.broadcast("offmessage")

 end

 end

end

rednet.close("yoursidehere")

and if you press Q in the bottom program, it'll terminate the program and turn off the modem

Link to comment
Share on other sites

thanks man, you're help is much appreciated, in the end this is what my script ended up looking like.

_______________________________________________________________

Sending computer.

rednet.open("left")

while true do

input = read()

if input == "zsakul" then

rednet.broadcast("zsakul")

print("Z sent")

sleep(5)

else

if inpiut == "shutdown" then

rednet.broadcast("shutdown")

print("S sent")

sleep(5)

os.reboot()

else

print("Null")

sleep(5)

os.reboot()

end

end

end

__________________________________________________

Receiving computer.

rednet.open("left")

while true do

senderID, input = rednet.receive()

if input == "zsakul" then

redstone.setOutput("back", true )

else

if input == "shutdown" then

redstone.setOutput("back", false )

os.reboot()

end

end

end

_________________________________________

I used to know this but I forgot, whats the command to clear the monitor?

Link to comment
Share on other sites

Might as well ask this here...

I was wondering if it would be possible to create a wireless network capable of sending files and chat messages on a Tekkit server. The idea was that each computer could be attached to two wireless transmitters (one for incoming, one for outgoing), which would connect to a central "server" which would relay the data to the desired computer on the network.

This would be really cool to see on a server where there is no world chat, making long-distance communication impossible. How hard would it be?

Link to comment
Share on other sites

Might as well ask this here...

I was wondering if it would be possible to create a wireless network capable of sending files and chat messages on a Tekkit server. The idea was that each computer could be attached to two wireless transmitters (one for incoming, one for outgoing), which would connect to a central "server" which would relay the data to the desired computer on the network.

This would be really cool to see on a server where there is no world chat, making long-distance communication impossible. How hard would it be?

I'm sorry to say this wouldn't be practical =/ Wireless modems have limited capabilities. The signal only carries for a distance of approx 60 blocks in good weather, and approx 17 in rain. However the using the same script I've used you'd just need to input a print("X") command after the signal is received, I've seen people do it before.

Link to comment
Share on other sites

I'm sorry to say this wouldn't be practical =/ Wireless modems have limited capabilities. The signal only carries for a distance of approx 60 blocks in good weather, and approx 17 in rain. However the using the same script I've used you'd just need to input a print("X") command after the signal is received, I've seen people do it before.

What if I used a wireless redstone transmitter? Or do they not work the same?
Link to comment
Share on other sites

What if I used a wireless redstone transmitter? Or do they not work the same?

The wireless redstone transmitter can only transfer redstone signals (on/off) so you would have to recode your message into binary and transfer it bit by bit. The receiver could then recode your message to characters again. No idea what frequency you could use, but I think it would be rather slow and unreliable.

Link to comment
Share on other sites

The wireless redstone transmitter can only transfer redstone signals (on/off) so you would have to recode your message into binary and transfer it bit by bit. The receiver could then recode your message to characters again. No idea what frequency you could use, but I think it would be rather slow and unreliable.

Ah damnit. In that case, we need proper transmitters.
Link to comment
Share on other sites

There is actually one alternative I just rememered.... Its a bit extreme though, you can connect all your computers using different color power cables to a router computer (with all the colors going into it) then have that computer relay the signal back down the network the the computer you specify the message is for, kinda a buzz kill and sooooo much cable... but it does work...

Link to comment
Share on other sites

There is actually one alternative I just rememered.... Its a bit extreme though, you can connect all your computers using different color power cables to a router computer (with all the colors going into it) then have that computer relay the signal back down the network the the computer you specify the message is for, kinda a buzz kill and sooooo much cable... but it does work...

Do you think you could show me some diagrams or something? Sounds like it'd be good for long-distance communication in combination with chunk loaders.
Link to comment
Share on other sites

Well its pretty straight forward, the maximum amount of computers on the network would be the maximum amount of colors of cable u have, minus one for the computer running your server which has to be connected to all the colors. Also, i don't know if there's a limit to the distance the colored wires can go.

Link to comment
Share on other sites

Well its pretty straight forward, the maximum amount of computers on the network would be the maximum amount of colors of cable u have, minus one for the computer running your server which has to be connected to all the colors. Also, i don't know if there's a limit to the distance the colored wires can go.

The limit of wires is 128 blocks, but they can be refreshed with a repeater or something of the like.

But I was hoping to be able to connect an unlimited number of computers to the network, you know?

Link to comment
Share on other sites

keep in mind, the moment you put in a repeater its a one way signal, the console could receive a signal, but not send. Also, another think to keep in mind is that every computer you add to the network requires more scripting on the main server computer. I don't really see computers being used as a viable form of communication in the near future (of minecraft lol).

Link to comment
Share on other sites

  • 11 months later...

okay, i dont know where else to post this, so here is my problem.

i am making a computer send out a rednet signal to another computer that is looping and when it gets the signal, it runs a program on a monitor, i cant get the code i have written cause it is on a server but basicly, i have a login system and after any user logs in it opens the doors, turns on the lights and sends a signal to run the monitor, everything works except the rednet signal gets lost, the two computers are less then 10 blocks away, and i cant figure out the problem

Link to comment
Share on other sites

i got the codes,, here they are

Main Computer

term.clear()

term.setCursorPos(1,1)

username = {'elrol_arrowsend', 'user'}

password = {'ryvix', 'pass'}

write('Please Enter Your Username: ')

user = read()

write('Please Enter Your TZO Password: ')

pass = read()

for i=1, #username do

if user == username then

if pass == password then

access = true

end

end

end

if access == true then

term.clear()

term.setCursorPos(1,1)

print('Logging in.......')

sleep(2)

term.clear()

term.setCursorPos(1,1)

print('Welcome '..user)

rs.setOutput('top', true)

rs.setOutput('right', true)

rs.setOutput('left', true)

rednet.open('back')

rednet.announce()

sleep(10)

rs.setOutput('right', false)

rs.setOutput('top', false)

else

print('Begone Intruder')

sleep(2)

os.shutdown()

end

Second Computer(runs the monitor)

startup

rednet.open('top')

repeat

local event, p1, p2, p3 = os.pullEvent()

if event=='redset_message' then

shell.run('monitor', 'right', 'rank')

end

until event=='char' and p1=='x'

rank

print('this should work')

FvJ8WrY.jpg

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