samedicorp / dualuniverse-feedback

Dual Universe Suggestions and Bugs
0 stars 0 forks source link

Event Listeners #48

Open samdeane opened 3 years ago

samdeane commented 3 years ago

In general listening for events is more efficient than polling for status. Currently though, to listen for events a script author has to explicitly set up filters for each slot.

This does not really support general purpose scripts. It would be much better if scripts could register to listen for events using an API:

system.listenFor("statusChanged", industry, function(status) -- do something with new status end)

For example, I have a script which monitors industry units. The keyboard controller needs to be connected to the core, a databank, and up to 8 industry units. The script does not care about the order of connection of all of these items - it checks the type of all of them and configures itself dynamically when it starts.

In order to achieve this flexibility, I cannot use event listening. Instead, I have to periodically poll the status of each industry unit. This works fine, but is neither as responsive or as efficient as it would be if it could instead listen for events.

samdeane commented 3 years ago

https://upvote.dualuniverse.game/suggestions/131681/event-listeners