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

A weird error with my rednet script.

Started by PyroGodz, 02 October 2012 - 08:57 PM
PyroGodz #1
Posted 02 October 2012 - 10:57 PM
EDIT:

I've finally gotten my wireless lighting worked out, thanks to all of you :(/>/>

Although, now I'm having issues after updating my docking bay hub. The program keeps spamming the very last print, which is Invalid Request. I'm not sure why it is doing this as it should be waiting for a signal to reach it first.

Here's my code: http://pastebin.com/WPvpEb2A

Thanks to all! :D/>/>
faubiguy #2
Posted 02 October 2012 - 11:00 PM
You need to use 2 '=', as in
if message == "LightsOn" then

= is the assignment operator, while == is the comparison operator.

Also, its unrelated, but rednet.receive should be rednet.receive()
PyroGodz #3
Posted 02 October 2012 - 11:02 PM
You need to use 2 '=', as in
if message == "LightsOn" then

= is the assignment operator, while == is the comparison operator.

Also, its unrelated, but rednet.receive should be rednet.receive()

Oh thanks :(/>/> I have a habit of making simple mistakes. Thanks! :D/>/>
PyroGodz #4
Posted 02 October 2012 - 11:20 PM
Ok.. I have another problem, my computer won't receive what it's getting from another computer. The error must be in line 10 (Including the checkprints) because when I run the program, CheckOne, Two, and three, all display, however four, does not. Although I don't see my issue on that line, and I get no errors. Thanks!

My code



term.clear()
term.setCursorPos(1,1)
rednet.open("right")
print("CheckOne")
while true do
print("CheckTwo")
local t = (os.time())
local time = (textutils.formatTime(t, false))
print("CheckThree")
  senderId,message = rednet.receive()
  print("CheckFour")
  if message == "LightsOn" then
    redstone.setOutput("back", true)
    write(time)
    print(": Request received, turning lights on.")
  elseif message == "LightsOff" then
    redstone.setOutput("back", false)
    write(time)
    print(": Request received, turning lights off.")
  end
  sleep(0.1)
end
Cranium #5
Posted 02 October 2012 - 11:27 PM
And you are making sure that the message is being sent AFTER it starts waiting?
PyroGodz #6
Posted 02 October 2012 - 11:34 PM
And you are making sure that the message is being sent AFTER it starts waiting?

Well yes, because the message is sent manually.

EDIT: The issue is that it's not receiving at all, because Check one two and three all go, check 4 doesn't go before, or after, I send the message. And the redstone output is never changed.
Cranium #7
Posted 02 October 2012 - 11:46 PM
Try sending the message multiple times. I don't see any errors with your code, but perhaps sending a few more times will make it work.
Anonomit #8
Posted 03 October 2012 - 02:23 AM
You forgot the quotes on rednet.receive()
line 6
PyroGodz #9
Posted 03 October 2012 - 04:09 AM
I've finally gotten my wireless lighting worked out, thanks to all of you :(/>/>

Although, now I'm having issues after updating my docking bay hub. The program keeps spamming the very last print, which is Invalid Request. I'm not sure why it is doing this as it should be waiting for a signal to reach it first.

Here's my code: http://pastebin.com/WPvpEb2A

Thanks to all! :D/>/>
KaoS #10
Posted 03 October 2012 - 07:28 AM
on line seven you just need () after the receive function so it is called… try adding indentation to your code. I remember back in grd 7 when I was learning HTML I hated it but now I have to admit that it actually helps
PyroGodz #11
Posted 03 October 2012 - 02:22 PM
on line seven you just need () after the receive function so it is called… try adding indentation to your code. I remember back in grd 7 when I was learning HTML I hated it but now I have to admit that it actually helps

I do normally use indentation, except I wrote this script on my iPod, and when I uploaded to pastebin, and used pastebin get on MC, all the spaces were ?'s because obviously apple is shit. So i had to delete it all, and rewrite it. Was too lazy to indent it all. :(/>/>
KaoS #12
Posted 03 October 2012 - 03:12 PM
hahaha, just use a text script to fix it :(/>/> replace all '?' with ' ' and you can tell it to check if there are multiple in case you need the ?s etc etc… the only reason I use it is cos of N++, it is toooo useful
PyroGodz #13
Posted 03 October 2012 - 05:11 PM
hahaha, just use a text script to fix it B)/>/> replace all '?' with ' ' and you can tell it to check if there are multiple in case you need the ?s etc etc… the only reason I use it is cos of N++, it is toooo useful

Yeah, I would have but there was a weird glitch with the text.. like.. I don't know how to explain it.. but you had to delete the real letters, then the question marks would disappear and the letters would stay.. and idk. Lol. And yes, N++ is very nice :(/>/> I used to use it when I used Java to program runescape private servers :D/>/>