Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0

if ("modem_message") == "test" then do computer.beep()


2018-03-03_18_59_34.thumb.png.77a5f8d0c107bf0fcff9cfc7df1875a7.pngI'm trying to setup a system so that when the network server receives a modem_message it does something based on the message and just based on the message not the distance or the address of the sender, however when i run the program,

( All of the code for which is on the left)  and i send a message to the server it spits out this:2018-03-03_19_00_23.thumb.png.00a3e3213d0c6c321a328c647e4294e6.png

if someone could please tell me what i have done wrong i would be very grateful as troubleshooting on my own was pretty much impossible.

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The problem with your code on the left is that you never define the value of the variable 'message', so when you try to print it you get 'nil' which in lua is a value for nothing. When calling the function event.pull you must capture the return values and store them for use at a later point in the program such as printing or whatever. Here's an example.

-- # your code above. this is just in the loop
while true do
  -- # event.pull 'modem_message' return multiple values the fifth being the message data.
  local laddress, saddress, port, dist, message = event.pull("modem_message")
  if message == "test" then

Hope this helps. Feel free to ask anymore questions :) 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.