Factorissimo 2 - notnotmelon fork 🍴


A fork of Factorissimo 2 focused on improving performance by implementing several 1.1 features. Can improve performance by 10X or higher. Also fixes several bugs from the original version.

Content
1 year, 3 months ago
1.1
53.2K
Logistics

FAQ

This fork comes with an extensible API
You can read/write to Factorissimo's global table, access several functions related to factory buildings, and add new tiers of factory building
Call any of these functions using the following syntax

remote.call('factorissimo', '{function name}', {args})

This API is a work in progress. If there is a feature you need added, create a thread in the discussions tab or contact me on Discord.

Factory object

factory = {
    +id = *,
    (+)inactive = *,

    +outside_surface = *,
    +outside_x = *,
    +outside_y = *,
    +outside_door_x = *,
    +outside_door_y = *,

    +inside_surface = *,
    +inside_x = *,
    +inside_y = *,
    +inside_door_x = *,
    +inside_door_y = *,

    +force = *,
    +layout = *,
    +building = *,
    +outside_energy_receiver = *,
    +outside_overlay_displays = {*},
    +outside_port_markers = {*},

    +inside_overlay_controller = *,
    +inside_power_poles = {*},
    (+)outside_power_pole = *,

    (+)middleman_id = *,
    (+)direct_connection = *,

    +stored_pollution = *,

    +connections = {*},
    +connection_settings = {{*}*},
    +connection_indicators = {*},

    +upgrades = {},
}

Global table

-- List of all factories
global.factories = global.factories or {}
-- Map: Id from item-with-tags -> Factory
global.saved_factories = global.saved_factories or {}
-- Map: Player or robot -> Save name to give him on the next relevant event
global.pending_saves = global.pending_saves or {}
-- Map: Entity unit number -> Factory it is a part of
global.factories_by_entity = global.factories_by_entity or {}
-- Map: Surface name -> list of factories on it
global.surface_factories = global.surface_factories or {}
-- Map: Surface name -> number of used factory spots on it
global.surface_factory_counters = global.surface_factory_counters or {}
-- Scalar
global.next_factory_surface = global.next_factory_surface or 0
-- Map: Player index -> Last teleport time
global.last_player_teleport = global.last_player_teleport or {}
-- Map: Player index -> Whether preview is activated
global.player_preview_active = global.player_preview_active or {}
-- List of all factory power pole middlemen
global.middleman_power_poles = global.middleman_power_poles or {}

make_connection and add_layout

These two functions allow you to add new tiers of factory building.
See the example on how to implement this

has_layout(name)

Returns true if an entity name has a factory layout
name - Name of an entity prototype

create_layout(name)

Returns the layout object for the given entity name
name - Name of an entity prototype

get_global(path)

Returns Factorissimo's global table. Read only.

path (optional) - table of indexes leading to the desired table

Example:

local force = remote.call('factorissimo', 'get_global', {'factories', 1}).force

set_global(path, v)

Sets a value in Factorissimo's global table.

path - table of indexes leading to the value to be updated
v - The value to be set

Example:

remote.call('factorissimo', 'set_global', {'factories', 1, 'force'}, 'enemy')

get_factory_by_entity(entity)

Returns a factory object from a factory building entity. nil if the factory is not found

get_factory_by_building(entity)

Returns a factory object from a factory building entity. Throws an error if the factory object isn't found.

find_surrounding_factory(surface, position)

Returns a factory object based on a surface and a position. nil if the factory is not found

find_factory_by_building(surface, position)

Searches for any factory buildings in an area

power_middleman_surface()

Returns the surface used for power middleman poles and circuit middleman poles