vlayer control

Control Module - vlayer - Adds a virtual layer to store power to save space.

Dependencies

utils.global
utils.event
config.vlayer

Functions

get_items() Get all items in storage, do not modify
get_interface_counts() Get interface counts
allocate_item(item_name, count) Internal, Allocate items in the vlayer, this will increase the property values of the vlayer such as production and capacity Does not increment item storage, so should not be called before insert_item unless during init Does not validate area requirements, so checks must be performed before calling this function Accepts negative count for deallocating items
insert_item(item_name, count) Insert an item into the vlayer, this will increment its count in storage and allocate it if possible
remove_item(item_name, count) Remove an item from the vlayer, this will decrement its count in storage and prioritise unallocated items over deallocation Can not always fulfil the remove request for items which provide surface area, therefore returns the amount actually removed
create_input_interface(surface, position[, player]) Create a new storage input interface
create_output_interface(surface, position[, player]) Create a new storage output interface
get_statistics() Get the statistics for the vlayer
energy_changed(power) add or reduce vlayer power
get_circuits() Circuit signals used for the statistics
create_circuit_interface(surface, position[, player]) Create a new circuit interface
create_energy_interface(surface, position[, player]) Create a new energy interface
remove_closest_interface(surface, position, radius) Remove the closest entity interface to the given position

Dependencies

# utils.global
# utils.event
# config.vlayer

Functions

# get_items()

Get all items in storage, do not modify

Returns:
  • (table) a dictionary of all items stored in the vlayer
# get_interface_counts()

Get interface counts

Returns:
  • (table) a dictionary of the vlayer interface counts
# allocate_item(item_name, count)

Internal, Allocate items in the vlayer, this will increase the property values of the vlayer such as production and capacity Does not increment item storage, so should not be called before insert_item unless during init Does not validate area requirements, so checks must be performed before calling this function Accepts negative count for deallocating items

Parameters:
  • item_name : (string) The name of the item to allocate
  • count : (number) The count of the item to allocate
# insert_item(item_name, count)

Insert an item into the vlayer, this will increment its count in storage and allocate it if possible

Parameters:
  • item_name : (string) The name of the item to insert
  • count : (number) The count of the item to insert
# remove_item(item_name, count)

Remove an item from the vlayer, this will decrement its count in storage and prioritise unallocated items over deallocation Can not always fulfil the remove request for items which provide surface area, therefore returns the amount actually removed

Parameters:
  • item_name : (string) The name of the item to remove
  • count : (number) The count of the item to remove
Returns:
  • (number) The count of the item actually removed
# create_input_interface(surface, position[, player])

Create a new storage input interface

Parameters:
  • surface : (LuaSurface) The surface to place the interface onto
  • position : (MapPosition) The position on the surface to place the interface at
  • player : (LuaPlayer) The player to show as the last user of the interface (optional)
Returns:
  • (LuaEntity) The entity that was created for the interface
# create_output_interface(surface, position[, player])

Create a new storage output interface

Parameters:
  • surface : (LuaSurface) The surface to place the interface onto
  • position : (MapPosition) The position on the surface to place the interface at
  • player : (LuaPlayer) The player to show as the last user of the interface (optional)
Returns:
  • (LuaEntity) The entity that was created for the interface
# get_statistics()

Get the statistics for the vlayer

# energy_changed(power)

add or reduce vlayer power

Parameters:
  • power
# get_circuits()

Circuit signals used for the statistics

# create_circuit_interface(surface, position[, player])

Create a new circuit interface

Parameters:
  • surface : (LuaSurface) The surface to place the interface onto
  • position : (MapPosition) The position on the surface to place the interface at
  • player : (LuaPlayer) The player to show as the last user of the interface (optional)
Returns:
  • (LuaEntity) The entity that was created for the interface
# create_energy_interface(surface, position[, player])

Create a new energy interface

Parameters:
  • surface : (LuaSurface) The surface to place the interface onto
  • position : (MapPosition) The position on the surface to place the interface at
  • player : (LuaPlayer) The player to show as the last user of the interface (optional)
Returns:
  • (LuaEntity) The entity that was created for the interface, or nil if it could not be created
# remove_closest_interface(surface, position, radius)

Remove the closest entity interface to the given position

Parameters:
  • surface : (LuaSurface) The surface to search for an interface on
  • position : (MapPosition) The position to start the search from
  • radius : (number) The radius to search for an interface within
Returns:
  • (string) The type of interface that was removed, or nil if no interface was found
  • (MapPosition) The position the interface was at, or nil if no interface was found