Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Ruuqo

Linked Card Recieve Message TO Modem Message :<

Question

Okay, so first let me explain.

 

I would like to be able to send a message from a computer with a linked card, to the other computer with a linked card, and have the receiving computer then forward that message as a broadcast to other computers on the other network its connected to, these two networks are in different dimensions.

 

My ability to code LUA is pretty much "hello world", and someone in IRC coded this for me...

 

http://pastebin.com/qmTAUpsB

 

The recieving computer gets the message, but it does not go through its own network to other computers, can someone help?

 

thanks

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

local component=require"component"
local event=require"event"
 
local link=component.tunnel
local modem=component.modem
local port=100
 
local function forward(event,rec_addr,from,port,distance,message)
modem.broadcast(port,message)
end

event.listen("modem_message",forward)

This forwards all message received by the tunnel (and any other message as well but it does not receive messages if you don't open a port, tunnel is an exception of course) to all computers listening on port 100 in this case. Once started it will run in the background until you restart the pc. you won't see this program working. if you want to see it, add a "print(message)" to the function forward, then you get an output each time you receive a message from the tunnel.

I've not tested this code but i'm confident it should work.

 

 

Link to post
Share on other sites
  • 0
local component=require"component"
local event=require"event"
 
local link=component.tunnel
local modem=component.modem
local port=100
 
local function forward(event,rec_addr,from,port,distance,message)
modem.broadcast(port,message)
end

event.listen("modem_message",forward)

This forwards all message received by the tunnel (and any other message as well but it does not receive messages if you don't open a port, tunnel is an exception of course) to all computers listening on port 100 in this case. Once started it will run in the background until you restart the pc. you won't see this program working. if you want to see it, add a "print(message)" to the function forward, then you get an output each time you receive a message from the tunnel.

I've not tested this code but i'm confident it should work.

 

 

 

 

I'll give this a quick shot, thanks

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.