This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ebernerd's profile picture

Could someone help me with RedNet?

Started by ebernerd, 10 January 2013 - 10:37 AM
ebernerd #1
Posted 10 January 2013 - 11:37 AM
So I have done what the wiki has told me… but it is soooo slow and too much programming for the simple user. I want to put a constantly updating rednet script in my operating system… maybe like instant messaging! Could someone please help their fellow newbie?
crazyguymgd #2
Posted 10 January 2013 - 11:40 AM
Are you asking someone to write the code for you because it's too much programming for the simple user?
ebernerd #3
Posted 10 January 2013 - 11:45 AM
Are you asking someone to write the code for you because it's too much programming for the simple user?
No no no… I mean like in the LUA prompt. It is too much work to just be like HEY I AM ONLINE! No.. I want just a simple base line where I can then edit it to my liking.
crazyguymgd #4
Posted 10 January 2013 - 11:50 AM

while true do
  message = rednet.receive()
  print(message)
  response = read()
  rednet.broadcast(response)
end

Is a simple get message, send message loop.
ebernerd #5
Posted 10 January 2013 - 12:03 PM

while true do
  message = rednet.receive()
  print(message)
  response = read()
  rednet.broadcast(response)
end

Is a simple get message, send message loop.
I tried… and I cant type anything
ebernerd #6
Posted 10 January 2013 - 12:06 PM
This is what I have, but I cant run it. Could somebody help?
 textutils.slowPrint("What side is your modem on?")
input = read()
rednet.open(input)
while true do
print("Message (to stop type /stop)")
input = read()
if input == "/stop" then
shell.run("cd disk")
end
else
rednet.broadcast(input)
end
end
crazyguymgd #7
Posted 10 January 2013 - 12:08 PM
Well you have to open the rednet modem first, and also have another computer running the same program to send the first message.
ebernerd #8
Posted 10 January 2013 - 12:16 PM
Well you have to open the rednet modem first, and also have another computer running the same program to send the first message.

I have one working… but it is in its beta…
When I ran a stop program… it crashed my minecraft……
This was the stop command:

if input == "/stop" then
break
end
ebernerd #9
Posted 10 January 2013 - 12:20 PM
Fixed the crash bug, but now I get a "PUT AN END ON LINE 12 TO CLOSE WHILE" on this code:



textutils.slowPrint("What side is your modem on?")
input = read()
rednet.open(input)
textutils.slowPrint("Sadly, this program cannot automagically update")
textutils.slowPrint("To see if you have a new message, type /refresh")
print("Message (to stop type /stop)")
while true do
input = read()
if input == "/stop" then
break
end
elseif input == "/refresh" then
g = rednet.receive()
print(g)
break
end
else
rednet.broadcast(input)
end
end

remiX #10
Posted 10 January 2013 - 12:29 PM

while true do
  message = rednet.receive()
  print(message)
  response = read()
  rednet.broadcast(response)
end

Is a simple get message, send message loop.

In this case, message is a number and is the ID of the computer from which the message is received from.

Fixed the crash bug, but now I get a "PUT AN END ON LINE 12 TO CLOSE WHILE" on this code:



textutils.slowPrint("What side is your modem on?")
input = read()
rednet.open(input)
textutils.slowPrint("Sadly, this program cannot automagically update")
textutils.slowPrint("To see if you have a new message, type /refresh")
print("Message (to stop type /stop)")
while true do
input = read()
if input == "/stop" then
break
-- Whole if block needs only one end
-- Not sure what you're trying to do with the /refresh part here..
else
rednet.broadcast(input)
end
end


Btw, the arguments for rednet.receive() are as follows:


senderID, message, distance = rednet.receive()
-- senderID is the ID of which the message is received from
-- message is the message recieved
-- distance the distance between the two computers
crazyguymgd #11
Posted 10 January 2013 - 12:30 PM
One end not 3 ends
crazyguymgd #12
Posted 10 January 2013 - 12:32 PM

while true do
  message = rednet.receive()
  print(message)
  response = read()
  rednet.broadcast(response)
end

Is a simple get message, send message loop.

In this case, message is a number and is the ID of the computer from which the message is received from.

Fixed the crash bug, but now I get a "PUT AN END ON LINE 12 TO CLOSE WHILE" on this code:



textutils.slowPrint("What side is your modem on?")
input = read()
rednet.open(input)
textutils.slowPrint("Sadly, this program cannot automagically update")
textutils.slowPrint("To see if you have a new message, type /refresh")
print("Message (to stop type /stop)")
while true do
input = read()
if input == "/stop" then
break
-- Whole if block needs only one end
-- Not sure what you're trying to do with the /refresh part here..
else
rednet.broadcast(input)
end
end


Btw, the arguments for rednet.receive() are as follows:


senderID, message, distance = rednet.receive()
-- senderID is the ID of which the message is received from
-- message is the message recieved
-- distance the distance between the two computers

Thanks for the catch.
ebernerd #13
Posted 10 January 2013 - 12:37 PM

while true do
  message = rednet.receive()
  print(message)
  response = read()
  rednet.broadcast(response)
end

Is a simple get message, send message loop.

In this case, message is a number and is the ID of the computer from which the message is received from.

Fixed the crash bug, but now I get a "PUT AN END ON LINE 12 TO CLOSE WHILE" on this code:



textutils.slowPrint("What side is your modem on?")
input = read()
rednet.open(input)
textutils.slowPrint("Sadly, this program cannot automagically update")
textutils.slowPrint("To see if you have a new message, type /refresh")
print("Message (to stop type /stop)")
while true do
input = read()
if input == "/stop" then
break
-- Whole if block needs only one end
-- Not sure what you're trying to do with the /refresh part here..
else
rednet.broadcast(input)
end
end


Btw, the arguments for rednet.receive() are as follows:


senderID, message, distance = rednet.receive()
-- senderID is the ID of which the message is received from
-- message is the message recieved
-- distance the distance between the two computers

Can I have it just receive a broadcast message?

And I was trying to make it so that it would autoupdate
but it wouldnt work in three different coding situations (program ran, just got stuck)
*btw.. dont have that code anymore…*

so typing /refresh would update the screen.
remiX #14
Posted 10 January 2013 - 12:41 PM
– snip

Can I have it just receive a broadcast message?

And I was trying to make it so that it would autoupdate
but it wouldnt work in three different coding situations (program ran, just got stuck)
*btw.. dont have that code anymore…*

so typing /refresh would update the screen.

Well, you will need to save the message into a table and then re-print them onto the screen.

This involves a lot of rednet stuff and is advanced if you're a beginner. I'd suggest looking through the programs sections, there are quite a few email programs.
ebernerd #15
Posted 10 January 2013 - 12:50 PM
– snip

Can I have it just receive a broadcast message?

And I was trying to make it so that it would autoupdate
but it wouldnt work in three different coding situations (program ran, just got stuck)
*btw.. dont have that code anymore…*

so typing /refresh would update the screen.

Well, you will need to save the message into a table and then re-print them onto the screen.

This involves a lot of rednet stuff and is advanced if you're a beginner. I'd suggest looking through the programs sections, there are quite a few email programs.
Thanks… I will work on it more when I am more advanced..
crazyguymgd #16
Posted 10 January 2013 - 12:54 PM
Haha well you're on track if you just want a simple instant messenger type system. Yes a full email system is more complicated but i'm sure you can figure this IM stuff out. However, you do need to read up on rednet a bit more. Have you made progress on it? (You said you don't have that code anymore) I'd like to see how you're coming.
remiX #17
Posted 10 January 2013 - 12:55 PM
–snip
Thanks… I will work on it more when I am more advanced..

I'm not saying you can't do it. I'm sure anyone can if they practice/learn and code over and over. Eventually you will know a lot.

Here's an email program: TCMail - Fully Functional Email

I've never used/tried it but check out the code and see if you can learn from it :)/>