Custom Events

by Zinal

Adds an interface that handles custom events and adds two new events: on_entity_opened and on_entity_closed

Utilities
7 years ago
0.13
5
Owner:
Zinal
Source:
https://github.com/Zinal001/Custom_Events
Homepage:
N/A
License:
MIT
Created:
7 years ago
Latest Version:
0.1.0 (7 years ago)
Factorio version:
0.13
Downloaded by:
5 users

Adds an interface that handles custom events and adds two new events: on_entity_opened and on_entity_closed.

Interface

Name: custom events

Interface Functions

events

Returns a list of defined custom event names
Return Type: string[]

get

Returns the id of a defined event
Parameters:
+ name :: The name of the event
Return Type: uint or nil if not found

has

Returns true if there is an event with the specified name, false otherwise
Parameters:
+ name :: The name of the event
Return Type: bool

set

Set a custom event to a specific id
Parameters:
+ name :: The name of the event
+ id :: The new id of the event
Return Type: uint

generate

Generate a new id to a specified event (uses script.generate_event_name() internally)
Parameters:
+ name :: The name of the event
Return Type: uint

New Events

on_entity_opened

Called when an entity is opened
This only works with entities that has an inventory or a type of network (Such as transport belts)
Contains:
+ player_index :: The index of the player who opened the entity
+ entity_name :: The name of the entity that has been opened or "opened_self" if the player opened his/her own inventory.

on_entity_closed

Called when an entity is closed
Contains:
+ player_index :: The index of the player who closed the entity
+ entity_name :: The name of the entity that has been closed or "opened_self" if the player closed his/her own inventory.