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:
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 =1local Openport =2local modemaddress = component.get("d25")local shutdown =falselocal message
modem.open(1)
modem.setStrength(20)
print("port is opened:".. tostring(modem.isOpen(1)))localfunction 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)doif(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 =4local height =13local 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.
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.
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:
The Hub program:
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:
I am also using the addon Computronics, though no parts from it are in either computer.
Link to post
Share on other sites