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

deadpangod3

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by deadpangod3

  1. Hi! My program seems to think that any print statements that come after my code to receive modem signals, despite being correct, still result in  syntax errors, while any that come before are completely fine. It doesn't matter if it's a variable, a number, or a string. It affects term.write(), and io.write() too.

    The goal of this program is to be a hub of sorts where I can remotely send commands to robots to do assigned tasks, but that obviously requires being able to send signals to them. So I was experimenting with it to learn, however, I have not been able to solve this issue. I have experimented with this a ton and narrowed it down to the code that receives the signal, as soon as that is removed, the print statements work fine. I'm hoping someone can tell me how and why this is happening.

    The Error:

    2019-07-03_17_13_15.thumb.png.41d8c380906e016bcc46bf17ed480662.png

     

    The Hub program:

    local os = require("os")
    local component = require("component")
    local event = require("event")
    local computer = require("computer")
    local term = require("term")
    
    local modem = component.modem
    local Robots = 1
    local Openport = 2
    local modemaddress = component.get("d25")
    local shutdown = false
    local message
    
    modem.open(1)
    modem.setStrength(20)
    print("port is opened:" .. tostring(modem.isOpen(1)))
    
    
    local function Recieve()
      local _, localNetworkCard, remoteAddress, port, distance, payload = event.pull("modem_message")
      print("Received data '" .. tostring(payload) .. "' from address " .. remoteAddress .. " on network card " .. localNetworkCard .. " on port " .. port .. ".")
      print(payload)
      message = tostring(payload)
    end
    
    event.listen("modem_message", Recieve)
    
    while(shutdown == false) do
      if(message == "Signal Test.") then
        broadcast(1, "Signal Test Reply.")
      end
      term.clear
      print(computer.uptime())
    end

    It's far from finished so some variables are unused at the moment, sorry if it grinds your gears.

    The other computer which is acting as a test broadcaster has this program running to broadcast to the main computer, this has been working so far:

    local width = 4
    local height = 13
    local length
    local posx
    local posy
    local posz
    local os = require("os")
    local component = require("component")
    local modem = component.modem
    local modemaddress = component.get("68e")
    local event = require("event")
    
    modem.open(1)
    modem.setStrength(20)
    modem.broadcast(1, "Signal Test.")
    modem.send(modemaddress, 1, "Signal Test.")
    local _, localNetworkCard, remoteAddress, port, distance, payload = event.pull("modem_message")
    print("Received data '" .. tostring(payload) .. "' from address " .. remoteAddress .. " on network card " .. localNetworkCard .. " on port " .. port .. ".")

    I am also using the addon Computronics, though no parts from it are in either computer.

×
×
  • Create New...

Important Information

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