13 posts
Posted 14 August 2013 - 03:29 AM
This post will help you to make a relay and extend your rednet distance!
Place down two computers and put a wireless modem on the top of both of them save both files as startup
Computer #1: replace <id of="" relay=""> with the id of the second computer
rednet.open("top")
function main()
print("Enter id:")
id = read()
print("Enter Message:")
msg = read()
rednet.send(<id of="" relay="">, textutils.serialize({msg,id}))
end
while true do
main()
end
Now on the second computer type:
rednet.open("top ")
function main()
id, msg = rednet.receive()
print("recived message from: "..tostring(id))
msg2, id2 = unpack(textutils.unserialize(msg))
end
while true do
main()
end
Done now you can relay messages
331 posts
Posted 14 August 2013 - 03:40 AM
all I can see from this is a stack error do w while true loop instead of recalling the function within a function, and you don't call your main loop in second program
13 posts
Posted 14 August 2013 - 04:27 AM
Fixed and thx for the info I must of miss read it
331 posts
Posted 14 August 2013 - 07:35 AM
um I simple realy message could also be done by, I don't see the overcomplication necessary this just boosts a message
receive()
while true do
id, message distance = rednet.receive()
rednet.broadcast(message)
end
end
receive()
edit: this is a way to keep original computer id
Spoiler
if you want it to use origrinal computer id i would do it like,
computer1
id = os.getComputerId()
mes = id.."|"..mes
rednet.broadcast(mes)
computer boosting signal
receive()
while true do
id, message distance = rednet.receive()
rednet.broadcast(message)
end
end
receive()
computer recieving
while true do
id, mes, distance = rednet.receive()
if mes:find("|") then -- if it finds '|' where it splits id and user
a,b = mes:find("|")
id = mes:split(1, a-1) -- split from start to last id number, numbers before '|'
mes = mes:split(b+1, #mes) -- from everywhere after '|'
end
end
if you really wanted to you could even overwrite rednet.receive() to do it but i wont do that unless you want it
13 posts
Posted 14 August 2013 - 11:35 AM
um I simple realy message could also be done by, I don't see the overcomplication necessary this just boosts a message
receive()
while true do
id, message distance = rednet.receive()
rednet.broadcast(message)
end
end
receive()
edit: this is a way to keep original computer id
Spoiler
if you want it to use origrinal computer id i would do it like,
computer1
id = os.getComputerId()
mes = id.."|"..mes
rednet.broadcast(mes)
computer boosting signal
receive()
while true do
id, message distance = rednet.receive()
rednet.broadcast(message)
end
end
receive()
computer recieving
while true do
id, mes, distance = rednet.receive()
if mes:find("|") then -- if it finds '|' where it splits id and user
a,b = mes:find("|")
id = mes:split(1, a-1) -- split from start to last id number, numbers before '|'
mes = mes:split(b+1, #mes) -- from everywhere after '|'
end
end
if you really wanted to you could even overwrite rednet.receive() to do it but i wont do that unless you want it
true however that will:
a) mean that every computer will be able to see that message, (you used broadcast)
B)/> if your sending a message on a server say 500 odd blocks away the default distance for rednet is 64 blocks so you would have to use a relay
c) your separating the two messages took 4-5 lines of code, mine took 1:
msg2, id2 = unpack(textutils.unserialize(msg))