Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Have sensor mods use events for updates? #70

@originalfoo

Description

@originalfoo

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions