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
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Wireless Modem Fun
Started by applesauce10189, 09 January 2014 - 11:20 AMPosted 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,
Posted 09 January 2014 - 12:26 PM
Should be:
Same mistake: if you want to check if something matches something, use ==
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 on 17 June 2014 - 09:29 PM
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.
edit, now it says on line 2 attempt to call nil.
another edit, I misspelled receive, fixed it.
Edited on 09 January 2014 - 11:28 AM
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.
Posted 09 January 2014 - 01:16 PM
Also, I'm not sure if "down" is a valid side. Use "bottom".
Posted 09 January 2014 - 02:00 PM
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.Also, I'm not sure if "down" is a valid side. Use "bottom".
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.
Posted 09 January 2014 - 03:20 PM
Still doesn't work. I changed 1 into "on" and 2 into "off" both with and without quotation marks. What am I doing wrong?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.
Posted 09 January 2014 - 03:44 PM
elseif message == 2 then
change the 2 to "2"
change the 2 to "2"
Posted 09 January 2014 - 04:18 PM
Thank you, I feel stupid for making so many mistakes in so little amounts of code,elseif message == 2 then
change the 2 to "2"
Posted 09 January 2014 - 04:32 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.
You can send numbers over rednet. Tables, too.
Posted 09 January 2014 - 08:14 PM
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 on 09 January 2014 - 07:19 PM
Posted 10 January 2014 - 02:35 AM
… depending on the version of ComputerCraft installed.You can send numbers over rednet. Tables, too.
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/>