Closed Mad-Mushroom closed 1 year ago
local , , dns_from, dnsport, , dns_message = event.pull("modem_message")
This code is for OpenOS event library, not MineOS
Here's suitable for UI example:
local GUI = require("GUI")
--------------------------------------------------------------------------------
local workspace = GUI.workspace()
-- Add any widget to workspace, let it be the background colored panel
local backgroundPanel = workspace:addChild(GUI.panel(1, 1, workspace.width, workspace.height, 0x2D2D2D))
-- Attach an event handler to it
backgroundPanel.eventHandler = function(workspace, backgroundPanel, eventType, dns_to, dns_from, dns_port, dns_distance, dns_message)
if eventType== "modem_message" then
GUI.alert("Message received", dns_message)
end
end
--------------------------------------------------------------------------------
workspace:draw()
workspace:start()
Thread-locking, more suitable for daemon scripts, not for UI:
local event = require("Event")
--------------------------------------------------------------------------------
while true do
local eventType, dns_to, dns_from, dns_port, dns_distance, dns_message = event.pull()
if eventType = "modem_message" then
-- Do your stuff
end
end
Thank you :)
I'm trying to do communication via modem, but I cannot pull a modem message:
local _, _, dns_from, dns_port, _, dns_message = event.pull("modem_message")
will give me a error saying I cannot put a String for event.pull.Now I read through the Wiki https://github.com/IgorTimofeev/MineOS/wiki/Event-API but I still don't know how to pull a event from the modem. I just get
key_up, *component id*, 13.0, 28.0
And I have no idea what to do with this.So I just wanna know how to receive a message from a modem just like in the OpenOS example https://ocdoc.cil.li/component:modem :)
Thank you for your Help :D