Jump to content




Wireless Modem Fun


  • You cannot reply to this topic
13 replies to this topic

#1 applesauce10189

  • Members
  • 162 posts

Posted 09 January 2014 - 12:20 PM

I'm new to coding and I felt like playing around with wireless modems and I think I messed up, I'm wondering what I'm doing wrong it says on line 4 there's a "then" expected but it's already there,


rednet.open("right")
id, message = rednet.recieve()
while true do
  if message = 1 then
    rs.setOutput("down", true)
  elseif message = 2 then
    rs.setOutput("down", false)
  end
end


#2 wieselkatze

  • Members
  • 221 posts
  • LocationGermany

Posted 09 January 2014 - 12:26 PM

Should be:

rednet.open("right")
id, message = rednet.recieve()
while true do
  if message == 1 then
	rs.setOutput("bottom", true)
  elseif message == 2 then
	rs.setOutput("bottom", false)
  end
end

Same mistake: if you want to check if something matches something, use ==

Edited by wieselkatze, 17 June 2014 - 10:29 PM.


#3 applesauce10189

  • Members
  • 162 posts

Posted 09 January 2014 - 12:26 PM

Thanks, guess I forgot,
edit, now it says on line 2 attempt to call nil.
another edit, I misspelled receive, fixed it.

Edited by applesauce10189, 09 January 2014 - 12:28 PM.


#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 January 2014 - 12:29 PM

This is covered under the Common Errors section of the sticky post titled Read This Post Before Asking Questions. You should try using the resources available to you rather than immediately running off to post a question. We have that sticky for exactly this sort of easy to solve, common error.

#5 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 09 January 2014 - 01:16 PM

Also, I'm not sure if "down" is a valid side. Use "bottom".

#6 applesauce10189

  • Members
  • 162 posts

Posted 09 January 2014 - 02:00 PM

View PostLBPHacker, on 09 January 2014 - 01:16 PM, said:

Also, I'm not sure if "down" is a valid side. Use "bottom".
Tried bottom. Didn't seem to work either so I moved the computer and put redstone in the back and using "back" didn't work either.

#7 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 09 January 2014 - 02:41 PM

Oh so there's another bug. Yeah, I see. receive will never be a number, since you can't send numbers over rednet, only strings.

#8 applesauce10189

  • Members
  • 162 posts

Posted 09 January 2014 - 03:20 PM

View PostLBPHacker, on 09 January 2014 - 02:41 PM, said:

Oh so there's another bug. Yeah, I see. receive will never be a number, since you can't send numbers over rednet, only strings.
Still doesn't work. I changed 1 into "on" and 2 into "off" both with and without quotation marks. What am I doing wrong?

#9 6677

  • Members
  • 197 posts
  • LocationCambridgeshire, England

Posted 09 January 2014 - 03:44 PM

elseif message == 2 then

change the 2 to "2"

#10 applesauce10189

  • Members
  • 162 posts

Posted 09 January 2014 - 04:18 PM

View Post6677, on 09 January 2014 - 03:44 PM, said:

elseif message == 2 then

change the 2 to "2"
Thank you, I feel stupid for making so many mistakes in so little amounts of code,

#11 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 09 January 2014 - 04:32 PM

View PostLBPHacker, on 09 January 2014 - 02:41 PM, said:

Oh so there's another bug. Yeah, I see. receive will never be a number, since you can't send numbers over rednet, only strings.

You can send numbers over rednet. Tables, too.

#12 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 09 January 2014 - 08:14 PM

It seems that the OP put Ignore this :P
id, message = rednet.recieve()
It should be
id, message = rednet.receive()

To print the valid sides do this
for _, side in ipairs( rs.getSides() ) do
	print( side )
end

Edited by Hellkid98, 09 January 2014 - 08:19 PM.


#13 Bomb Bloke

    Hobbyist Coder

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

Posted 10 January 2014 - 02:35 AM

View PostLyqyd, on 09 January 2014 - 04:32 PM, said:

You can send numbers over rednet. Tables, too.
... depending on the version of ComputerCraft installed.

#14 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 January 2014 - 11:16 AM

True, though for unqualified statements of what one can or cannot do, the current version is the one to base things off of. :P





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users