Hermios Framework

by Hermios

Framework to handle prototypes and entities

6 months ago
1.1
2.01K
Owner:
Hermios
Source:
https://github.com/Hermios/Hermios_Framework
Homepage:
https://github.com/Hermios/Hermios_Framework
License:
MIT
Created:
9 months ago
Latest Version:
1.0.8 (6 months ago)
Factorio version:
1.1
Downloaded by:
2.01K users

Please send any request to Github (See Source URL!)

This framework allows to handle events, entities and prototypes

Handle events

Some events are handle automatically for creation/remove of entity, on_tick etc.
However, it is always possible to execute custom functions when a script is called:
Simply add the function to the table list_events[<name of the evemt>]

extra event: on_removed, and on_built can be used as name of events, and group all events which respectively create/destroy entites

Define Prototype

A custom_prototype is a table or boolean true that defines custom properties of an entity or train.
It is defined as following:
custom_prototypes[<identifier>]=<custom_prototype>
identifier can be the name of type of the entity for which prototype shall apply.
for train, it is the word "train"
Finally, it is possible to use it for all entities, by using the keyword "any"

Create entity/train

When an entity is built, if there is a matching prototype, a custom_entity is created with properties of the prototype.
custom_entity has at least one property mandatory, entity which is either an entity or a train, and need to exist and to be valid.
custom_entity can be created per default or through the method "new" (new is eypected to send back the custom_entity)
custom_entity is then stored automatically in the table global.custom_entities
and indexed through entity.unit_number (if this is an entity) or entity.id (if this is a train)
Then, - custom_entity:on_built is called if it exists

Remove entity/train

If the entity has a custom_entity, this one is automatically removed from the table global.custom_entities
Additionally, the method custom_entity:on_removed can be called, if it exists