pub struct LuaSurface;Expand description
A “domain” of the world, such as a planet or space platform. Surfaces are uniquely identified by their name. Every game contains at least the surface “nauvis”.
Implementations§
Source§impl LuaSurface
impl LuaSurface
Sourcepub fn always_day(&self) -> bool
pub fn always_day(&self) -> bool
When set to true, the sun will always shine.
Sourcepub fn brightness_visual_weights(&self) -> ColorModifier
pub fn brightness_visual_weights(&self) -> ColorModifier
Defines how surface daytime brightness influences each color channel of the current color lookup table (LUT).
The LUT is multiplied by ((1 - weight) + brightness * weight) and result is clamped to range [0, 1].
Default is {0, 0, 0}, which means no influence.
Sourcepub fn darkness(&self) -> f32
pub fn darkness(&self) -> f32
Amount of darkness at the current time, as a number in range [0, 1].
Sourcepub fn daytime_parameters(&self) -> LuaSurfaceDaytimeParameters
pub fn daytime_parameters(&self) -> LuaSurfaceDaytimeParameters
Sourcepub fn freeze_daytime(&self) -> bool
pub fn freeze_daytime(&self) -> bool
True if daytime is currently frozen.
Sourcepub fn generate_with_lab_tiles(&self) -> bool
pub fn generate_with_lab_tiles(&self) -> bool
When set to true, new chunks will be generated with lab tiles, instead of using the surface’s map generation settings.
Sourcepub fn global_effect(&self) -> ModuleEffects
pub fn global_effect(&self) -> ModuleEffects
Surface-wide effects applied to entities with effect receivers. nil if this surface is not using surface-wide effect source.
Sourcepub fn global_electric_network(&self) -> LuaElectricSubNetwork
pub fn global_electric_network(&self) -> LuaElectricSubNetwork
Global electric network for this surface.
Sourcepub fn global_electric_network_statistics(&self) -> LuaFlowStatistics
pub fn global_electric_network_statistics(&self) -> LuaFlowStatistics
The global electric network statistics for this surface.
If this global network is disabled or this surface is removed, the flow statistics obtained from it will also become invalid. However if the surface index of a deleted surface is reused, the related flow statistics may become valid again.
Sourcepub fn has_global_electric_network(&self) -> bool
pub fn has_global_electric_network(&self) -> bool
Whether this surface currently has a global electric network.
Sourcepub fn ignore_surface_conditions(&self) -> bool
pub fn ignore_surface_conditions(&self) -> bool
If surface condition checks should not be performed on this surface.
Sourcepub fn index(&self) -> u32
pub fn index(&self) -> u32
This surface’s index in LuaGameScript::surfaces (unique ID). It is assigned when a surface is created, and remains so until it is deleted. Indexes of deleted surfaces can be reused.
Sourcepub fn localised_name(&self) -> &str
pub fn localised_name(&self) -> &str
Localised name of this surface. When set, will replace the internal surface name in places where a player sees surface name.
Value may be ignored if a surface has a SpacePlatform or Planet object attached to it, which take the precedence.
Sourcepub fn map_gen_settings(&self) -> MapGenSettings
pub fn map_gen_settings(&self) -> MapGenSettings
The generation settings for this surface. These can be modified after surface generation, but note that this will not retroactively update the surface. To manually regenerate it, LuaSurface::regenerate_entity, LuaSurface::regenerate_decorative, and LuaSurface::delete_chunk can be used.
Sourcepub fn min_brightness(&self) -> f64
pub fn min_brightness(&self) -> f64
The minimal brightness during the night. Defaults to 0.15. This has an effect on both rendering and game mechanics such as biter spawns and solar power.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
The name of this surface. Names are unique among surfaces.
The default surface can’t be renamed.
Sourcepub fn no_enemies_mode(&self) -> bool
pub fn no_enemies_mode(&self) -> bool
Is no-enemies mode enabled on this surface?
Sourcepub fn object_name(&self) -> &str
pub fn object_name(&self) -> &str
The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
Sourcepub fn override_pollution_type(&self) -> Pollutant
pub fn override_pollution_type(&self) -> Pollutant
If set, this pollution type will be used over any other planet or platform values.
If set to an empty table, pollution is disabled. If set to nil, the override is ‘unset’.
Reading will be nil if unset or a table with the current override (nil if overridden to disabled).
Sourcepub fn peaceful_mode(&self) -> bool
pub fn peaceful_mode(&self) -> bool
Is peaceful mode enabled on this surface?
Sourcepub fn planet(&self) -> LuaPlanet
pub fn planet(&self) -> LuaPlanet
The planet associated with this surface, if there is one.
Use LuaPlanet::associate_surface to create a new association with a planet.
pub fn platform(&self) -> LuaSpacePlatform
Sourcepub fn pollutant_type(&self) -> LuaAirbornePollutantPrototype
pub fn pollutant_type(&self) -> LuaAirbornePollutantPrototype
The type of pollutant enabled on the surface, or nil if no pollutant is enabled.
Sourcepub fn pollution_statistics(&self) -> LuaFlowStatistics
pub fn pollution_statistics(&self) -> LuaFlowStatistics
The pollution statistics for this surface.
Sourcepub fn show_clouds(&self) -> bool
pub fn show_clouds(&self) -> bool
If clouds are shown on this surface. If false, clouds are never shown. If true the player must also have clouds enabled in graphics settings for them to be shown.
By default, clouds are shown on all surfaces.
Sourcepub fn solar_power_multiplier(&self) -> f64
pub fn solar_power_multiplier(&self) -> f64
The multiplier of solar power on this surface. Cannot be less than 0.
Sourcepub fn ticks_per_day(&self) -> u32
pub fn ticks_per_day(&self) -> u32
The number of ticks per day for this surface.
Sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
Sourcepub fn wind_orientation(&self) -> LuaAny
pub fn wind_orientation(&self) -> LuaAny
Current wind direction.
Sourcepub fn wind_orientation_change(&self) -> f64
pub fn wind_orientation_change(&self) -> f64
Change in wind orientation per tick.
Sourcepub fn wind_speed(&self) -> f64
pub fn wind_speed(&self) -> f64
Current wind speed in tiles per tick.
Sourcepub fn add_script_area(&self, area: ScriptArea) -> u32
pub fn add_script_area(&self, area: ScriptArea) -> u32
Adds the given script area.
Sourcepub fn add_script_position(&self, position: ScriptPosition) -> u32
pub fn add_script_position(&self, position: ScriptPosition) -> u32
Adds the given script position.
Sourcepub fn build_checkerboard(&self, area: BoundingBox)
pub fn build_checkerboard(&self, area: BoundingBox)
Sets the given area to the checkerboard lab tiles.
Sourcepub fn build_enemy_base(
&self,
force: Option<LuaAny>,
position: MapPosition,
unit_count: u32,
)
pub fn build_enemy_base( &self, force: Option<LuaAny>, position: MapPosition, unit_count: u32, )
Send a group to build a new base.
The specified force must be AI-controlled; i.e. force.ai_controllable must be true.
Sourcepub fn calculate_tile_properties(
&self,
positions: Vec<MapPosition>,
property_names: Vec<&str>,
) -> HashMap<String, Vec<f64>>
pub fn calculate_tile_properties( &self, positions: Vec<MapPosition>, property_names: Vec<&str>, ) -> HashMap<String, Vec<f64>>
Calculate values for a list of tile properties at a list of positions. Requests for unrecognized properties will be ignored, so this can also be used to test whether those properties exist.
Sourcepub fn can_fast_replace(&self, params: LuaSurfaceCanFastReplaceParams) -> bool
pub fn can_fast_replace(&self, params: LuaSurfaceCanFastReplaceParams) -> bool
If there exists an entity at the given location that can be fast-replaced with the given entity parameters.
Sourcepub fn can_place_entity(&self, params: LuaSurfaceCanPlaceEntityParams) -> bool
pub fn can_place_entity(&self, params: LuaSurfaceCanPlaceEntityParams) -> bool
Check for collisions with terrain or other entities.
Sourcepub fn cancel_deconstruct_area(
&self,
params: LuaSurfaceCancelDeconstructAreaParams,
)
pub fn cancel_deconstruct_area( &self, params: LuaSurfaceCancelDeconstructAreaParams, )
Cancel a deconstruction order.
Sourcepub fn cancel_upgrade_area(&self, params: LuaSurfaceCancelUpgradeAreaParams)
pub fn cancel_upgrade_area(&self, params: LuaSurfaceCancelUpgradeAreaParams)
Cancel a upgrade order.
Sourcepub fn clear(&self, ignore_characters: Option<bool>)
pub fn clear(&self, ignore_characters: Option<bool>)
Clears this surface deleting all entities and chunks on it.
Completely removes hidden and double hidden tiles data on this surface.
Sourcepub fn clear_pollution(&self)
pub fn clear_pollution(&self)
Clears all pollution on this surface.
Sourcepub fn clear_territory_for_chunks(&self, chunk_positions: Vec<ChunkPosition>)
pub fn clear_territory_for_chunks(&self, chunk_positions: Vec<ChunkPosition>)
Removes the chunk from the territory it is associated with (if any) and allows the map generator to potentially generate a new territory for the chunk in the future. To prevent the game from generating a new territory for the chunk, use LuaSurface::set_chunk_territory to set the chunk’s territory to nil.
Territories that do not contain at least one generated chunk as a result of calling this method will be automatically deleted.
Sourcepub fn clone_area(&self, params: LuaSurfaceCloneAreaParams)
pub fn clone_area(&self, params: LuaSurfaceCloneAreaParams)
Clones the given area.
Entities are cloned in an order such that they can always be created, eg rails before trains.
Sourcepub fn clone_brush(&self, params: LuaSurfaceCloneBrushParams)
pub fn clone_brush(&self, params: LuaSurfaceCloneBrushParams)
Clones the given area.
defines.events.on_entity_cloned is raised for each entity, and then defines.events.on_area_cloned is raised.
Entities are cloned in an order such that they can always be created, eg rails before trains.
Sourcepub fn clone_entities(&self, params: LuaSurfaceCloneEntitiesParams)
pub fn clone_entities(&self, params: LuaSurfaceCloneEntitiesParams)
Clones the given entities.
Entities are cloned in an order such that they can always be created, eg rails before trains.
Sourcepub fn count_entities_filtered(&self, filter: EntitySearchFilters) -> u32
pub fn count_entities_filtered(&self, filter: EntitySearchFilters) -> u32
Count entities of given type or name in a given area. Works just like LuaSurface::find_entities_filtered, except this only returns the count. As it doesn’t construct all the wrapper objects, this is more efficient if one is only interested in the number of entities.
-
If no
areaorpositionare given, the entire surface is searched. -
If
positionis given, this returns the entities colliding with that position (i.e the given position is within the entity’s collision box). -
If
positionandradiusare given, this returns entities in the radius of the position. -
If
areais specified, this returns entities colliding with that area.
Sourcepub fn count_tiles_filtered(&self, filter: TileSearchFilters) -> u32
pub fn count_tiles_filtered(&self, filter: TileSearchFilters) -> u32
Count tiles of a given name in a given area. Works just like LuaSurface::find_tiles_filtered, except this only returns the count. As it doesn’t construct all the wrapper objects, this is more efficient if one is only interested in the number of tiles.
If no area or position and radius is given, the entire surface is searched. If position and radius are given, only tiles within the radius of the position are included.
Sourcepub fn create_decoratives(&self, params: LuaSurfaceCreateDecorativesParams)
pub fn create_decoratives(&self, params: LuaSurfaceCreateDecorativesParams)
Adds the given decoratives to the surface.
This will merge decoratives of the same type that already exist effectively increasing the “amount” field.
Sourcepub fn create_entities_from_blueprint_string(
&self,
params: LuaSurfaceCreateEntitiesFromBlueprintStringParams,
) -> Option<i32>
pub fn create_entities_from_blueprint_string( &self, params: LuaSurfaceCreateEntitiesFromBlueprintStringParams, ) -> Option<i32>
This method only works when used in simulations.
Places entities via the given blueprint string. These entities are force-built.
Sourcepub fn create_entity(
&self,
params: LuaSurfaceCreateEntityParams,
) -> Option<LuaEntity>
pub fn create_entity( &self, params: LuaSurfaceCreateEntityParams, ) -> Option<LuaEntity>
Create an entity on this surface.
Sourcepub fn create_global_electric_network(&self)
pub fn create_global_electric_network(&self)
Creates a global electric network for this surface, if one doesn’t exist already.
Sourcepub fn create_particle(&self, params: LuaSurfaceCreateParticleParams)
pub fn create_particle(&self, params: LuaSurfaceCreateParticleParams)
Creates a particle at the given location
Sourcepub fn create_segmented_unit(
&self,
params: LuaSurfaceCreateSegmentedUnitParams,
) -> Option<LuaSegmentedUnit>
pub fn create_segmented_unit( &self, params: LuaSurfaceCreateSegmentedUnitParams, ) -> Option<LuaSegmentedUnit>
Create a segmented unit on the surface. This differs from creating an entity with type "segmented-unit" in that this method can create the entity in non-generated chunks and with any arbitrary body shape and pre-assigned to a territory.
Sourcepub fn create_territory(
&self,
params: LuaSurfaceCreateTerritoryParams,
) -> Option<LuaTerritory>
pub fn create_territory( &self, params: LuaSurfaceCreateTerritoryParams, ) -> Option<LuaTerritory>
Create a territory on the surface.
pub fn create_trivial_smoke(&self, params: LuaSurfaceCreateTrivialSmokeParams)
Sourcepub fn create_unit_group(
&self,
params: LuaSurfaceCreateUnitGroupParams,
) -> LuaCommandable
pub fn create_unit_group( &self, params: LuaSurfaceCreateUnitGroupParams, ) -> LuaCommandable
Create a new unit group at a given position.
Sourcepub fn deconstruct_area(&self, params: LuaSurfaceDeconstructAreaParams)
pub fn deconstruct_area(&self, params: LuaSurfaceDeconstructAreaParams)
Place a deconstruction request.
Sourcepub fn decorative_prototype_collides(
&self,
position: MapPosition,
prototype: LuaAny,
) -> bool
pub fn decorative_prototype_collides( &self, position: MapPosition, prototype: LuaAny, ) -> bool
Whether the given decorative prototype collides at the given position and direction.
pub fn delete_chunk(&self, chunk_position: ChunkPosition)
Sourcepub fn destroy_decoratives(&self, params: LuaSurfaceDestroyDecorativesParams)
pub fn destroy_decoratives(&self, params: LuaSurfaceDestroyDecorativesParams)
Removes all decoratives from the given area. If no area and no position are given, then the entire surface is searched.
Sourcepub fn destroy_global_electric_network(&self)
pub fn destroy_global_electric_network(&self)
Destroys the global electric network for this surface, if it exists.
Sourcepub fn edit_script_area(&self, area: ScriptArea, id: u32)
pub fn edit_script_area(&self, area: ScriptArea, id: u32)
Sets the given script area to the new values.
Sourcepub fn edit_script_position(&self, id: u32, position: ScriptPosition)
pub fn edit_script_position(&self, id: u32, position: ScriptPosition)
Sets the given script position to the new values.
Sourcepub fn entity_prototype_collides(
&self,
direction: Option<&str>,
position: MapPosition,
prototype: LuaAny,
use_map_generation_bounding_box: bool,
) -> bool
pub fn entity_prototype_collides( &self, direction: Option<&str>, position: MapPosition, prototype: LuaAny, use_map_generation_bounding_box: bool, ) -> bool
Whether the given entity prototype collides at the given position and direction.
Sourcepub fn execute_lightning(&self, params: LuaSurfaceExecuteLightningParams)
pub fn execute_lightning(&self, params: LuaSurfaceExecuteLightningParams)
Creates lightning. If other entities which can be lightning targets are nearby, the final position will be adjusted.
Sourcepub fn find_closest_logistic_network_by_position(
&self,
force: LuaAny,
position: MapPosition,
) -> Option<LuaLogisticNetwork>
pub fn find_closest_logistic_network_by_position( &self, force: LuaAny, position: MapPosition, ) -> Option<LuaLogisticNetwork>
Find the logistic network with a cell closest to a given position.
Sourcepub fn find_decoratives_filtered(
&self,
params: LuaSurfaceFindDecorativesFilteredParams,
) -> Vec<DecorativeResult>
pub fn find_decoratives_filtered( &self, params: LuaSurfaceFindDecorativesFilteredParams, ) -> Vec<DecorativeResult>
Find decoratives of a given name in a given area.
If no filters are given, returns all decoratives in the search area. If multiple filters are specified, returns only decoratives matching every given filter. If no area and no position are given, the entire surface is searched.
Sourcepub fn find_enemy_units(
&self,
center: MapPosition,
force: Option<LuaAny>,
radius: f64,
) -> Vec<LuaEntity>
pub fn find_enemy_units( &self, center: MapPosition, force: Option<LuaAny>, radius: f64, ) -> Vec<LuaEntity>
Find enemy units (entities with type “unit”) of a given force within an area.
This is more efficient than LuaSurface::find_entities.
Sourcepub fn find_entities(&self, area: Option<BoundingBox>) -> Vec<LuaEntity>
pub fn find_entities(&self, area: Option<BoundingBox>) -> Vec<LuaEntity>
Find entities in a given area.
If no area is given all entities on the surface are returned.
Sourcepub fn find_entities_filtered(
&self,
filter: EntitySearchFilters,
) -> Vec<LuaEntity>
pub fn find_entities_filtered( &self, filter: EntitySearchFilters, ) -> Vec<LuaEntity>
Find all entities of the given type or name in the given area.
If no filters (name, type, force, etc.) are given, this returns all entities in the search area. If multiple filters are specified, only entities matching all given filters are returned.
-
If no
areaorpositionare given, the entire surface is searched. -
If
positionis given, this returns the entities colliding with that position (i.e the given position is within the entity’s collision box). -
If
positionandradiusare given, this returns the entities within the radius of the position. Looks for the center of entities. -
If
areais specified, this returns the entities colliding with that area.
Sourcepub fn find_entity(
&self,
entity: LuaAny,
position: MapPosition,
) -> Option<LuaEntity>
pub fn find_entity( &self, entity: LuaAny, position: MapPosition, ) -> Option<LuaEntity>
Find an entity of the given name at the given position. This checks both the exact position and the bounding box of the entity.
Sourcepub fn find_logistic_network_by_position(
&self,
force: LuaAny,
position: MapPosition,
) -> Option<LuaLogisticNetwork>
pub fn find_logistic_network_by_position( &self, force: LuaAny, position: MapPosition, ) -> Option<LuaLogisticNetwork>
Find the logistic network that covers a given position.
Sourcepub fn find_logistic_networks_by_construction_area(
&self,
force: LuaAny,
position: MapPosition,
) -> Vec<LuaLogisticNetwork>
pub fn find_logistic_networks_by_construction_area( &self, force: LuaAny, position: MapPosition, ) -> Vec<LuaLogisticNetwork>
Finds all of the logistics networks whose construction area intersects with the given position.
Sourcepub fn find_nearest_enemy(
&self,
params: LuaSurfaceFindNearestEnemyParams,
) -> Option<LuaEntity>
pub fn find_nearest_enemy( &self, params: LuaSurfaceFindNearestEnemyParams, ) -> Option<LuaEntity>
Find the enemy military target (military entity) closest to the given position.
Sourcepub fn find_nearest_enemy_entity_with_owner(
&self,
params: LuaSurfaceFindNearestEnemyEntityWithOwnerParams,
) -> LuaEntity
pub fn find_nearest_enemy_entity_with_owner( &self, params: LuaSurfaceFindNearestEnemyEntityWithOwnerParams, ) -> LuaEntity
Find the enemy entity-with-owner closest to the given position.
Sourcepub fn find_non_colliding_position(
&self,
center: MapPosition,
force_to_tile_center: Option<bool>,
name: LuaAny,
precision: f64,
radius: f64,
) -> Option<MapPosition>
pub fn find_non_colliding_position( &self, center: MapPosition, force_to_tile_center: Option<bool>, name: LuaAny, precision: f64, radius: f64, ) -> Option<MapPosition>
Find a non-colliding position within a given radius.
Special care needs to be taken when using a radius of 0. The game will not stop searching until it finds a suitable position, so it is important to make sure such a position exists. One particular case where it would not be able to find a solution is running it before any chunks have been generated.
Sourcepub fn find_non_colliding_position_in_box(
&self,
force_to_tile_center: Option<bool>,
name: LuaAny,
precision: f64,
search_space: BoundingBox,
) -> Option<MapPosition>
pub fn find_non_colliding_position_in_box( &self, force_to_tile_center: Option<bool>, name: LuaAny, precision: f64, search_space: BoundingBox, ) -> Option<MapPosition>
Find a non-colliding position within a given rectangle.
Sourcepub fn find_tiles_filtered(&self, filter: TileSearchFilters) -> Vec<LuaTile>
pub fn find_tiles_filtered(&self, filter: TileSearchFilters) -> Vec<LuaTile>
Find all tiles of the given name in the given area.
If no filters are given, this returns all tiles in the search area.
If no area or position and radius is given, the entire surface is searched. If position and radius are given, only tiles within the radius of the position are included.
Sourcepub fn find_units(&self, params: LuaSurfaceFindUnitsParams) -> Vec<LuaEntity>
pub fn find_units(&self, params: LuaSurfaceFindUnitsParams) -> Vec<LuaEntity>
Find units (entities with type “unit”) of a given force and force condition within a given area.
This is more efficient than LuaSurface::find_entities.
Sourcepub fn force_generate_chunk_requests(&self)
pub fn force_generate_chunk_requests(&self)
Blocks and generates all chunks that have been requested using all available threads.
Sourcepub fn get_chunks(&self) -> LuaChunkIterator
pub fn get_chunks(&self) -> LuaChunkIterator
Get an iterator going over every chunk on this surface.
Chunks may or may not be generated; use LuaSurface::is_chunk_generated to check a chunk’s state before accessing it.
Sourcepub fn get_closest(
&self,
entities: Vec<LuaEntity>,
position: MapPosition,
) -> Option<LuaEntity>
pub fn get_closest( &self, entities: Vec<LuaEntity>, position: MapPosition, ) -> Option<LuaEntity>
Gets the closest entity in the list to this position.
Sourcepub fn get_connected_tiles(
&self,
area: Option<BoundingBox>,
include_diagonal: Option<bool>,
position: TilePosition,
tiles: Vec<LuaAny>,
) -> Vec<TilePosition>
pub fn get_connected_tiles( &self, area: Option<BoundingBox>, include_diagonal: Option<bool>, position: TilePosition, tiles: Vec<LuaAny>, ) -> Vec<TilePosition>
Gets all tiles of the given types that are connected horizontally or vertically to the given tile position including the given tile position.
This won’t find tiles in non-generated chunks.
Sourcepub fn get_default_cover_tile(
&self,
force: LuaAny,
tile: LuaAny,
) -> Option<LuaTilePrototype>
pub fn get_default_cover_tile( &self, force: LuaAny, tile: LuaAny, ) -> Option<LuaTilePrototype>
Gets the cover tile for the given force and tile on this surface if one is set.
The double hidden tile name or nil if there isn’t one for the given position.
Sourcepub fn get_entities_with_force(
&self,
chunk_position: ChunkPosition,
force: LuaAny,
) -> Vec<LuaEntity>
pub fn get_entities_with_force( &self, chunk_position: ChunkPosition, force: LuaAny, ) -> Vec<LuaEntity>
Returns all the military targets (entities with force) on this chunk for the given force.
The hidden tile name.
Sourcepub fn get_map_exchange_string(&self) -> &str
pub fn get_map_exchange_string(&self) -> &str
Gets the map exchange string for the current map generation settings of this surface.
Sourcepub fn get_pollution(&self, position: MapPosition) -> f64
pub fn get_pollution(&self, position: MapPosition) -> f64
Get the pollution for a given position.
Pollution is stored per chunk, so this will return the same value for all positions in one chunk.
Sourcepub fn get_property(&self, property: LuaAny) -> f64
pub fn get_property(&self, property: LuaAny) -> f64
Gets the value of surface property on this surface.
Sourcepub fn get_random_chunk(&self) -> Option<ChunkPosition>
pub fn get_random_chunk(&self) -> Option<ChunkPosition>
Gets a random generated chunk position or nil if no chunks have been generated on this surface.
Sourcepub fn get_resource_counts(&self) -> HashMap<String, u32>
pub fn get_resource_counts(&self) -> HashMap<String, u32>
Gets the resource amount of all resources on this surface
Sourcepub fn get_script_area(&self, key: Option<LuaAny>) -> Option<ScriptArea>
pub fn get_script_area(&self, key: Option<LuaAny>) -> Option<ScriptArea>
Gets the first script area by name or id.
Sourcepub fn get_script_areas(&self, name: Option<&str>) -> Vec<ScriptArea>
pub fn get_script_areas(&self, name: Option<&str>) -> Vec<ScriptArea>
Gets the script areas that match the given name or if no name is given all areas are returned.
Sourcepub fn get_script_position(&self, key: Option<LuaAny>) -> Option<ScriptPosition>
pub fn get_script_position(&self, key: Option<LuaAny>) -> Option<ScriptPosition>
Gets the first script position by name or id.
Sourcepub fn get_script_positions(&self, name: Option<&str>) -> Vec<ScriptPosition>
pub fn get_script_positions(&self, name: Option<&str>) -> Vec<ScriptPosition>
Gets the script positions that match the given name or if no name is given all positions are returned.
Sourcepub fn get_segmented_units(&self) -> Vec<LuaSegmentedUnit>
pub fn get_segmented_units(&self) -> Vec<LuaSegmentedUnit>
Get all segmented units that exist on the surface.
Sourcepub fn get_starting_area_radius(&self) -> f64
pub fn get_starting_area_radius(&self) -> f64
Gets the starting area radius of this surface.
Sourcepub fn get_territories(&self) -> Vec<LuaTerritory>
pub fn get_territories(&self) -> Vec<LuaTerritory>
Get all territories on the surface.
Sourcepub fn get_territory_for_chunk(
&self,
chunk_position: ChunkPosition,
) -> Option<LuaTerritory>
pub fn get_territory_for_chunk( &self, chunk_position: ChunkPosition, ) -> Option<LuaTerritory>
Get the territory that the given chunk is assigned to. If the chunk is not part of any territory or the territory for the chunk has not yet been generated, then this returns nil.
Sourcepub fn get_tile(&self, x: i32, y: i32) -> LuaTile
pub fn get_tile(&self, x: i32, y: i32) -> LuaTile
Get the tile at a given position. An alternative call signature for this method is passing it a single TilePosition.
Non-integer values will result in them being rounded down.
Sourcepub fn get_total_pollution(&self) -> f64
pub fn get_total_pollution(&self) -> f64
Gets the total amount of pollution on the surface by iterating over all the chunks containing pollution.
Sourcepub fn is_chunk_generated(&self, chunk_position: ChunkPosition) -> bool
pub fn is_chunk_generated(&self, chunk_position: ChunkPosition) -> bool
Is a given chunk generated?
Sourcepub fn play_music(&self, music_specification: PlayMusicSpecification)
pub fn play_music(&self, music_specification: PlayMusicSpecification)
Play a music track for every player on this surface.
Sourcepub fn play_sound(&self, sound_specification: PlaySoundSpecification)
pub fn play_sound(&self, sound_specification: PlaySoundSpecification)
Play a sound for every player on this surface.
The sound is not played if its location is not charted for that player.
Sourcepub fn pollute(
&self,
amount: f64,
prototype: Option<LuaAny>,
source: MapPosition,
)
pub fn pollute( &self, amount: f64, prototype: Option<LuaAny>, source: MapPosition, )
Spawn pollution at the given position.
Sourcepub fn print(&self, message: &str, print_settings: Option<PrintSettings>)
pub fn print(&self, message: &str, print_settings: Option<PrintSettings>)
Print text to the chat console of all players on this surface.
By default, messages that are identical to a message sent in the last 60 ticks are not printed again.
Sourcepub fn regenerate_decorative(
&self,
chunks: Option<Vec<ChunkPosition>>,
decoratives: Option<LuaAny>,
)
pub fn regenerate_decorative( &self, chunks: Option<Vec<ChunkPosition>>, decoratives: Option<LuaAny>, )
Regenerate autoplacement of some decoratives on this surface. This can be used to autoplace newly-added decoratives.
All specified decorative prototypes must be autoplacable. If nothing is given all decoratives are generated on all chunks.
Sourcepub fn regenerate_entity(
&self,
chunks: Option<Vec<ChunkPosition>>,
entities: Option<LuaAny>,
)
pub fn regenerate_entity( &self, chunks: Option<Vec<ChunkPosition>>, entities: Option<LuaAny>, )
Regenerate autoplacement of some entities on this surface. This can be used to autoplace newly-added entities.
All specified entity prototypes must be autoplacable. If nothing is given all entities are generated on all chunks.
Sourcepub fn remove_script_area(&self, id: u32) -> bool
pub fn remove_script_area(&self, id: u32) -> bool
Removes the given script area.
Sourcepub fn remove_script_position(&self, id: u32) -> bool
pub fn remove_script_position(&self, id: u32) -> bool
Removes the given script position.
Sourcepub fn request_path(&self, params: LuaSurfaceRequestPathParams) -> u32
pub fn request_path(&self, params: LuaSurfaceRequestPathParams) -> u32
Generates a path with the specified constraints (as an array of PathfinderWaypoints) using the unit pathfinding algorithm. This path can be used to emulate pathing behavior by script for non-unit entities, such as vehicles. If you want to command actual units (such as biters or spitters) to move, use LuaCommandable::set_command via LuaEntity::commandable instead.
The resulting path is ultimately returned asynchronously via on_script_path_request_finished.
Sourcepub fn request_to_generate_chunks(
&self,
position: MapPosition,
radius: Option<u32>,
)
pub fn request_to_generate_chunks( &self, position: MapPosition, radius: Option<u32>, )
Request that the game’s map generator generate chunks at the given position for the given radius on this surface. If the radius is 0, then only the chunk at the given position is generated.
Sourcepub fn set_chunk_generated_status(
&self,
chunk_position: ChunkPosition,
status: &str,
)
pub fn set_chunk_generated_status( &self, chunk_position: ChunkPosition, status: &str, )
Set generated status of a chunk. Useful when copying chunks.
Sourcepub fn set_default_cover_tile(
&self,
force: LuaAny,
from_tile: LuaAny,
to_tile: Option<LuaAny>,
)
pub fn set_default_cover_tile( &self, force: LuaAny, from_tile: LuaAny, to_tile: Option<LuaAny>, )
Sets the cover tile for the given force and tile on this surface.
Set double hidden tile for the specified position. During normal gameplay, only non-mineable tiles can become double hidden.
Does nothing if hidden tile at specified position does not exist.
Set the hidden tile for the specified position. While during normal gameplay only non-mineable or foundation tiles can become hidden, this method allows any kind of tile to be set as the hidden one.
Sourcepub fn set_multi_command(&self, params: LuaSurfaceSetMultiCommandParams) -> u32
pub fn set_multi_command(&self, params: LuaSurfaceSetMultiCommandParams) -> u32
Give a command to multiple units. This will automatically select suitable units for the task.
Sourcepub fn set_pollution(&self, amount: f64, position: MapPosition)
pub fn set_pollution(&self, amount: f64, position: MapPosition)
Set the pollution for a given position.
Pollution changes by this are not included in pollution statistics and do not affect evolution factors (as opposed to LuaSurface::pollute).
Sourcepub fn set_property(&self, property: LuaAny, value: f64)
pub fn set_property(&self, property: LuaAny, value: f64)
Sets the value of surface property on this surface.
Sourcepub fn set_territory_for_chunks(
&self,
chunk_positions: Vec<ChunkPosition>,
territory: Option<LuaTerritory>,
)
pub fn set_territory_for_chunks( &self, chunk_positions: Vec<ChunkPosition>, territory: Option<LuaTerritory>, )
Removes the given chunks from their current territories and adds them to the given territory if provided.
This does not affect the LuaTerritory::get_patrol_path. It is your responsibility to update the patrol path if needed.
It’s recommended that territory chunks are connected to each other, but this is not required.
Territories that do not contain at least one generated chunk as a result of calling this method will be automatically deleted.
Sourcepub fn set_tiles(
&self,
correct_tiles: Option<bool>,
player: Option<LuaAny>,
raise_event: Option<bool>,
remove_colliding_decoratives: Option<bool>,
remove_colliding_entities: Option<LuaAny>,
tiles: Vec<Tile>,
undo_index: Option<u32>,
)
pub fn set_tiles( &self, correct_tiles: Option<bool>, player: Option<LuaAny>, raise_event: Option<bool>, remove_colliding_decoratives: Option<bool>, remove_colliding_entities: Option<LuaAny>, tiles: Vec<Tile>, undo_index: Option<u32>, )
Set tiles at specified locations. Can automatically correct the edges around modified tiles.
Placing a mineable tile on top of a non-mineable or foundation one will turn the latter into the LuaTile::hidden_tile for that tile. Placing a mineable non-foundation tile on a mineable non-foundation one or a mineable foundation tile on a mineable foundation one will not modify the hidden tile. This restriction can however be circumvented by using LuaSurface::set_hidden_tile. Placing a non-foundation tile on top of a foundation one when there already exists a hidden tile will push hidden tile to double hidden, and foundation tile will turn into hidden. Placing a mineable foundation tile over a mineable non-foundation tile with hidden mineable foundation tile, the hidden tile will be replaced by previously double hidden tile and double hidden tile will be erased. Placing a non-mineable tile will erase hidden and double hidden tiles.
It is recommended to call this method once for all the tiles you want to change rather than calling it individually for every tile. As the tile correction is used after every step, calling it one by one could cause the tile correction logic to redo some of the changes. Also, many small API calls are generally more performance intensive than one big one.
Sourcepub fn spill_inventory(
&self,
params: LuaSurfaceSpillInventoryParams,
) -> Vec<LuaEntity>
pub fn spill_inventory( &self, params: LuaSurfaceSpillInventoryParams, ) -> Vec<LuaEntity>
Spill inventory on the ground centered at a given location.
Sourcepub fn spill_item_stack(
&self,
params: LuaSurfaceSpillItemStackParams,
) -> Vec<LuaEntity>
pub fn spill_item_stack( &self, params: LuaSurfaceSpillItemStackParams, ) -> Vec<LuaEntity>
Spill items on the ground centered at a given location.
Sourcepub fn upgrade_area(&self, params: LuaSurfaceUpgradeAreaParams)
pub fn upgrade_area(&self, params: LuaSurfaceUpgradeAreaParams)
Place an upgrade request.
Trait Implementations§
Source§impl Clone for LuaSurface
impl Clone for LuaSurface
Source§fn clone(&self) -> LuaSurface
fn clone(&self) -> LuaSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more