Skip to main content

event

Attribute Macro event 

Source
#[event]
Expand description

Marks a control-stage function as a Factorio event handler.

The event is inferred from the handler name and first parameter type (OnBuiltEntityEvent). Filters are validated at compile time via a generated const expression.

§Examples

Without filter:

#[factorio_rs::event]
pub fn on_singleplayer_init(event: OnSingleplayerInitEvent) {}

With filter (filter expression is type-checked at compile time):

#[factorio_rs::event(filter = [OnBuiltEntityFilter::type_("inserter")])]
pub fn on_built_entity(event: OnBuiltEntityEvent) {}