Module Entity

[Control Stage] LuaEntity manipulation.

Module Status: Work in progress. Compatibility: Factorio Runtime.

Usage:

    local Entity = require('__eradicators-library__/erlib/factorio/Entity')()
    

Methods

find_unit_number(unit_number) Brute force searches through all surfaces to find an entity.

Simple Methods

is_vehicle(entity) car or spider-vehicle.
get_vehicle_driver_player(vehicle)
is_real_car(entity) Filter out fake cars.
destroy([entity]) Destroys an entity or does nothing.

Inventory

get_item_contents(entity) Scans all inventories.

Draft

is_blueprintable(prototype)


Methods

find_unit_number(unit_number)
Brute force searches through all surfaces to find an entity.
The holy grail of de-optimizing your mods performance.

Parameters:

  • unit_number uint The LuaEntity.unit_number of the target entity.

Returns:

    LuaEntity or nil

Simple Methods

Should be self-explanatory.
is_vehicle(entity)
car or spider-vehicle.

Parameters:

Returns:

    boolean
get_vehicle_driver_player(vehicle)

Parameters:

Returns:

    LuaPlayer or nil
is_real_car(entity)
Filter out fake cars.
"Car" type entities are often used as mod hacks, such as frame stepped animations or letting the player enter buildings. This checks if a car is actually movable and rotatable by the player.

Parameters:

Returns:

    boolean
destroy([entity])
Destroys an entity or does nothing.

Parameters:

Inventory

get_item_contents(entity)
Scans all inventories. Like LuaEntity.get_fluid_contents but for items.

Parameters:

Returns:

    dictionary[string → number]

Draft

is_blueprintable(prototype)

Parameters:

Returns:

    boolean
generated by LDoc 1.4.6 Last updated 2021-09-10 19:51:19