Jump to content




A weird error with my rednet script.


12 replies to this topic

#1 PyroGodz

  • New Members
  • 17 posts

Posted 02 October 2012 - 09: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/>

#2 faubiguy

  • Members
  • 213 posts

Posted 02 October 2012 - 10: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()

#3 PyroGodz

  • New Members
  • 17 posts

Posted 02 October 2012 - 10:02 PM

View Postfaubiguy, on 02 October 2012 - 10:00 PM, said:

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/>

#4 PyroGodz

  • New Members
  • 17 posts

Posted 02 October 2012 - 10: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


#5 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 02 October 2012 - 10:27 PM

And you are making sure that the message is being sent AFTER it starts waiting?

#6 PyroGodz

  • New Members
  • 17 posts

Posted 02 October 2012 - 10:34 PM

View PostCranium, on 02 October 2012 - 10:27 PM, said:

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.

#7 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 02 October 2012 - 10: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.

#8 Anonomit

  • Members
  • 67 posts

Posted 03 October 2012 - 01:23 AM

You forgot the quotes on rednet.receive()
line 6

#9 PyroGodz

  • New Members
  • 17 posts

Posted 03 October 2012 - 03: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/>

#10 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 03 October 2012 - 06: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

#11 PyroGodz

  • New Members
  • 17 posts

Posted 03 October 2012 - 01:22 PM

View PostKaoS, on 03 October 2012 - 06:28 AM, said:

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. :(/>

#12 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 03 October 2012 - 02: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

#13 PyroGodz

  • New Members
  • 17 posts

Posted 03 October 2012 - 04:11 PM

View PostKaoS, on 03 October 2012 - 02:12 PM, said:

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/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users