Resource utilities.
local Resource = require('__stdlib__/stdlib/entity/resource')
get_resources_at(surface, position) | Gets all resource entities at the specified position and surface. |
get_resource_patches_at(surface, position) | From the resources at the given surface and position, return all connected (horizontally, vertically and diagonally) resource entities. |
get_resource_patch_at(surface, position, type) | From the resources at the given surface and position, return all connected (horizontally, vertically and diagonally) resource entities of specified type. |
get_resource_types(resources) | Given an array of resource entities, get an array containing their names. |
filter_resources(resources, resource_names) | Given an array of resource entities, return the ones that have the given resource names. |
get_resource_patch_bounds(resource_patch) | Given a resource patch, return its area. |
Gets all resource entities at the specified position and surface.
Adapted from YARM/resmon.lua → find_resource_at
Parameters:From the resources at the given surface and position, return all connected (horizontally, vertically and diagonally) resource entities.
When the resource patches are found, the returned object will be an associative array where the key is the resource-type string and the value is an array of entities that correspond to the resource-type.
For now, this function gets just the ore patches, since problems arise when a single resource entity spans multiple tiles.
Parameters:This implementation is unstable; if a resource entity reference changes during the search, both the old and the new version of the entity might be included.
From the resources at the given surface and position, return all connected (horizontally, vertically and diagonally) resource entities of specified type.
For now, this function gets just the ore patches, since problems arise when a single resource entity spans multiple tiles.
Parameters:This implementation is unstable; if a resource entity reference changes during the search, both the old and the new version of the entity might be included.
Given an array of resource entities, get an array containing their names.
Every element within the new array is unique and is the name of a resource entity.
Parameters:Given an array of resource entities, return the ones that have the given resource names.
Parameters:
Given a resource patch, return its area.
Parameters: