I've added a bunch of new sensors to my mod and amongst other things it seems the remote.call api is somewhat laggy. Would it be better to allow sensor updates to be sent via events?
Mockup of code in a sensor mod:
local evoEvents = remote.call( 'EvoGUI', 'events' )
local sensor_update = evoEvents.update
local function updateMySensors()
local someVals = something()
game.raise_event( sensor_update,
{ mySensorID, val1, val2, ... }
)
end
On receiving end (in EvoGUI) the handler does something like:
local function updateHandler( update )
local sensor = update[1]
local display = localeCache[sensor]
for i = 2, #update do
display[i] = update[i]
end
-- then set caption of label for sensor to display
end
Obviously very crap code in samples above, but hopefully enough to show general idea. Instead of sending table it might be easier to just pass multiple params to the raise_event(), first being sensor id, second being locale string, any others being params to locale?
If my understanding of how events work is correct, it will also allow the game to hold the event until a later frame in order to maintain UPS and FPS.
I've added a bunch of new sensors to my mod and amongst other things it seems the remote.call api is somewhat laggy. Would it be better to allow sensor updates to be sent via events?
Mockup of code in a sensor mod:
On receiving end (in EvoGUI) the handler does something like:
Obviously very crap code in samples above, but hopefully enough to show general idea. Instead of sending table it might be easier to just pass multiple params to the raise_event(), first being sensor id, second being locale string, any others being params to locale?
If my understanding of how events work is correct, it will also allow the game to hold the event until a later frame in order to maintain UPS and FPS.