I think the first one will work but what is the difference between rednet_message and modem_message? how would i then convert the rednet message into like a print?
if event == "modem_message" then
print(event)
end
Would that work or not?
A modem message is a message sent directly from the modem api.
A rednet message is a message sent from the rednet api (rednet uses the modem api in the background, but it formats them in a way that the receiving computer knows it is a rednet message).
If you are sending the messages with the rednet api then listen for rednet messages instead of modem messages.
For rednet api (is what I am assuming you are using):
os.pullEvent/os.pullEventRaw will return the arguments of the event in the same order no matter what the variable names before it are, so the first variable is the event name as always, the second is the senderID, the third is the message itself, and the fourth is the protocol, so you would do something like:
if event =="rednet_message" then
print(X) --# X was the third variable that was before the os.pullEventRaw, so it is what the message was set to
end
edit:
I forgot to mention this, but it might be smarter to use a table to catch the event rather than variables, as then you are just referencing the table instead of using variable names
example:
while true do
local event = {os.pullEventRaw()}
if event[1] == "mouse_click" then
--# mouse was clicked
--# event[2] is what the button was
--# event[3] is x
--# event[4] is y
elseif event[1] == "rednet_message" then
--# rednet message received
--# event[2] is the sender id
--# event[3] is the message
--# event[4] is the protocol
end
end