Jump to content




Rednet Issues

wireless

19 replies to this topic

#1 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 18 February 2014 - 09:46 AM

I'm having issues when trying to use rednet for messaging other computers.

Senders Code:

rednet.open("back")
while true do
write("Positioned? Write yes if you are: ")
answer = read()
  if answer == "Yes" or "yes" then
	rednet.send(24, "order")
   end
end

Receivers Code:

rednet.open("back")
while true do
id, message, bd = os.pullEvent("rednet_message")
if message == "order" then
rs.setOutput("bottom", true)
rs.setOutput("bottom", false)
sleep(10)
rs.setOutput("bottom", true)
rs.setOutput("bottom", false)
end


The problem is: The sender sends the message, but the receiver doesn't collect it. Please Help!

--Lewis

Edited by lewislovesgames, 18 February 2014 - 12:34 PM.


#2 Anavrins

  • Members
  • 775 posts

Posted 18 February 2014 - 11:29 AM

Since you are using os.pullEvent() to get the message, you must do the same as you would do with other types of events, that is that the first parameter must be the name of the event.

"event, id, message, bd = os.pullEvent()"

#3 CometWolf

  • Members
  • 1,283 posts

Posted 18 February 2014 - 12:10 PM

Your sender will always send "order" regardless of what you input.
When you compare something, you must specify what to compare everytime. just "yes" will always equate to not nil, and thus the condition will be considered true.
if answer == "Yes" or answer == "yes" then

a simple way of dealing with capitalization, would be to use string.lower(). This will turn whatever string you pass it into lowercase.
if answer:lower == "yes" then -- This is just a syntactic sugar method of calling string.lower on the variable answer

Edited by CometWolf, 18 February 2014 - 12:11 PM.


#4 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 18 February 2014 - 12:42 PM

 Anavrins, on 18 February 2014 - 11:29 AM, said:


Since you are using os.pullEvent() to get the message, you must do the same as you would do with other types of events, that is that the first parameter must be the name of the event.

"event, id, message, bd = os.pullEvent()"

-------------------------------------------------------------------------------------------

 CometWolf, on 18 February 2014 - 12:10 PM, said:

Your sender will always send "order" regardless of what you input.
When you compare something, you must specify what to compare everytime. just "yes" will always equate to not nil, and thus the condition will be considered true.
if answer == "Yes" or answer == "yes" then

a simple way of dealing with capitalization, would be to use string.lower(). This will turn whatever string you pass it into lowercase.
if answer:lower == "yes" then -- This is just a syntactic sugar method of calling string.lower on the variable answer

Both will be put in my code.

Ah snap!

Put in the ideas and on the sender it errors:

bios:399: [string "send"]:5: function augments expected

:angry:/>

#5 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 18 February 2014 - 01:24 PM

Also, you set rs output to true and then immidiately to false. I don't think there will be a rs pulse when you toggle it that fast. If I am correct then a simple sleep for about 0.1 second between the rs functions should be ok.

#6 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 18 February 2014 - 01:43 PM

Download My Code For Receiver:

pastebin get iSza1YxT

Download My Code For Sender:

pastebin get vkT03Lyw

#7 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 February 2014 - 04:44 PM

Sender / receiver

The number "5" in the error indicates the line where it's expecting the function arguments.

I see that for now you've commented that second line Comet gave you out, replacing it with the first - the problem with that commented line is that "answer:lower" is a function (which returns a lower-case version of the answer variable), and Lua's expecting the function to be called, rather then just referred to.

Long story short, it should be:

if answer:lower() == "yes" then


#8 surferpup

  • Members
  • 286 posts
  • LocationUnited States

Posted 18 February 2014 - 04:48 PM

 MKlegoman357, on 18 February 2014 - 01:24 PM, said:

Also, you set rs output to true and then immidiately to false. I don't think there will be a rs pulse when you toggle it that fast. If I am correct then a simple sleep for about 0.1 second between the rs functions should be ok.

I think you have to have the sleep be at the very least 0.08 seconds for a pulse. If anyone knows better, please advise.

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 18 February 2014 - 05:09 PM

It's usually best to leave it on for a full redstone tick (0.1s). Shorter durations can be unreliable.

#10 CometWolf

  • Members
  • 1,283 posts

Posted 18 February 2014 - 05:11 PM

 Bomb Bloke, on 18 February 2014 - 04:44 PM, said:

Sender / receiver

The number "5" in the error indicates the line where it's expecting the function arguments.

I see that for now you've commented that second line Comet gave you out, replacing it with the first - the problem with that commented line is that "answer:lower" is a function (which returns a lower-case version of the answer variable), and Lua's expecting the function to be called, rather then just referred to.

Long story short, it should be:

if answer:lower() == "yes" then
Whops, my bad.

#11 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 19 February 2014 - 04:19 AM

I set my redstone to:

sleep(1)

to make sure that it would pulse.

EDIT: I fixed up all the code with the sender but still, no receive. :(

Edited by lewislovesgames, 19 February 2014 - 04:32 AM.


#12 CometWolf

  • Members
  • 1,283 posts

Posted 19 February 2014 - 05:37 AM

Im guessing the pastebin is still up to date, so... The ID of the receiver is 24, right? Or did you just chose a random number?

#13 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 21 February 2014 - 11:11 AM

 CometWolf, on 19 February 2014 - 05:37 AM, said:

Im guessing the pastebin is still up to date, so... The ID of the receiver is 24, right? Or did you just chose a random number?

Need to paste a new program. the things outdated.

 CometWolf, on 19 February 2014 - 05:37 AM, said:

Im guessing the pastebin is still up to date, so... The ID of the receiver is 24, right? Or did you just chose a random number?

yes

#14 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 06 March 2014 - 04:25 PM

New Codes:
Send:
pastebin get ULy8v6Hn
Receive:
pastebin get neAqHfcb

#15 CometWolf

  • Members
  • 1,283 posts

Posted 06 March 2014 - 05:09 PM

I see nothing wrong with your code, so how far apart are these computers located? Also, try opening the lua console on the receiver and write the following
rednet.open"back" while true do print(os.pullEvent"rednet_message") end
Then go to the sender and write this into the console
rednet.open"back" rednet.send(24,"test")
If nothing appears on the receiver, they're not able to reach eachother.

#16 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 06 March 2014 - 11:31 PM

I'd stick some "print" statements into both scripts - on the sender, to make sure it's not somehow misinterpreting your text input, and on the receiver, to see what messages it's actually receiving.

Also, silly question, but what sort of modems are you using? You haven't accidentally hooked up some wired modems instead of wireless ones, or somesuch? It's getting to the stage where screenshots may be helpful.

#17 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 07 March 2014 - 03:53 PM

 Bomb Bloke, on 06 March 2014 - 11:31 PM, said:

I'd stick some "print" statements into both scripts - on the sender, to make sure it's not somehow misinterpreting your text input, and on the receiver, to see what messages it's actually receiving.

Also, silly question, but what sort of modems are you using? You haven't accidentally hooked up some wired modems instead of wireless ones, or somesuch? It's getting to the stage where screenshots may be helpful.
Wireless Modems are the modems i'm using.

#18 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 14 April 2014 - 03:08 PM

Is anyone there? I'm using wireless modems Bomb Bloke.

#19 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 April 2014 - 10:43 PM

How'd you go with those "print" statements?

#20 LewisTehMinerz

  • Members
  • 174 posts
  • LocationMinecraft in Minecraft in Minecraft in ComputerCraft... in Minecraft

Posted 25 April 2014 - 12:40 PM

 Bomb Bloke, on 14 April 2014 - 10:43 PM, said:

How'd you go with those "print" statements?
I think i'll go with print statements, I'll do some editing of my code





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users