pub struct LuaItemStack;Expand description
A reference to an item and count owned by some external entity.
In most instances this is a simple reference as in: it points at a specific slot in an inventory and not the item in the slot.
In the instance this references an item on a LuaTransportLine the reference is only guaranteed to stay valid (and refer to the same item) as long as nothing changes the transport line.
Implementations§
Source§impl LuaItemStack
impl LuaItemStack
Sourcepub fn active_index(&self) -> u32
pub fn active_index(&self) -> u32
The active blueprint index for this blueprint book. nil if this blueprint book is empty.
Sourcepub fn allow_manual_label_change(&self) -> bool
pub fn allow_manual_label_change(&self) -> bool
Whether the label for this item can be manually changed. When false the label can only be changed through the API.
Sourcepub fn blueprint_absolute_snapping(&self) -> bool
pub fn blueprint_absolute_snapping(&self) -> bool
If absolute snapping is enabled on this blueprint item.
Sourcepub fn blueprint_description(&self) -> &str
pub fn blueprint_description(&self) -> &str
The description for this blueprint or blueprint book
Sourcepub fn blueprint_position_relative_to_grid(&self) -> TilePosition
pub fn blueprint_position_relative_to_grid(&self) -> TilePosition
The offset from the absolute grid. nil if absolute snapping is not enabled.
Sourcepub fn blueprint_snap_to_grid(&self) -> TilePosition
pub fn blueprint_snap_to_grid(&self) -> TilePosition
The snapping grid size in this blueprint item. nil if snapping is not enabled.
Sourcepub fn cost_to_build(&self) -> Vec<ItemWithQualityCount>
pub fn cost_to_build(&self) -> Vec<ItemWithQualityCount>
List of raw materials required to build this blueprint.
Sourcepub fn custom_description(&self) -> &str
pub fn custom_description(&self) -> &str
The custom description this item-with-tags. This is shown over the normal item description if this is set to a non-empty value.
Sourcepub fn default_icons(&self) -> Vec<BlueprintSignalIcon>
pub fn default_icons(&self) -> Vec<BlueprintSignalIcon>
The default icons for a blueprint item.
Sourcepub fn durability(&self) -> f64
pub fn durability(&self) -> f64
Durability of the contained item. Automatically capped at the item’s maximum durability.
Sourcepub fn entity_auto_target_with_gunner(&self) -> bool
pub fn entity_auto_target_with_gunner(&self) -> bool
If this is an item with entity data, get the stored auto target with gunner state.
Sourcepub fn entity_auto_target_without_gunner(&self) -> bool
pub fn entity_auto_target_without_gunner(&self) -> bool
If this is an item with entity data, get the stored auto target without gunner state.
Sourcepub fn entity_color(&self) -> Color
pub fn entity_color(&self) -> Color
If this is an item with entity data, get the stored entity color.
Sourcepub fn entity_driver_is_gunner(&self) -> bool
pub fn entity_driver_is_gunner(&self) -> bool
If this is an item with entity data, get the stored driver is gunner state.
Sourcepub fn entity_enable_logistics_while_moving(&self) -> bool
pub fn entity_enable_logistics_while_moving(&self) -> bool
If this is an item with entity data, get the stored enable logistics while moving state.
Sourcepub fn entity_filter_count(&self) -> u32
pub fn entity_filter_count(&self) -> u32
The number of entity filters this deconstruction item has.
Sourcepub fn entity_filter_mode(&self) -> &str
pub fn entity_filter_mode(&self) -> &str
The blacklist/whitelist entity filter mode for this deconstruction item.
Sourcepub fn entity_filters(&self) -> Vec<ItemFilter>
pub fn entity_filters(&self) -> Vec<ItemFilter>
The entity filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. All prototypes in this array must not have the "not-deconstructable" flag set and are either a cliff or marked as minable.
Sourcepub fn entity_label(&self) -> &str
pub fn entity_label(&self) -> &str
If this is an item with entity data, get the stored entity label.
Sourcepub fn entity_logistic_sections(&self) -> LogisticSections
pub fn entity_logistic_sections(&self) -> LogisticSections
If this is an item with entity data, get the stored logistic filters.
Sourcepub fn entity_logistics_enabled(&self) -> bool
pub fn entity_logistics_enabled(&self) -> bool
If this is an item with entity data, get the stored vehicle logistics enabled state.
Sourcepub fn entity_request_from_buffers(&self) -> bool
pub fn entity_request_from_buffers(&self) -> bool
If this is an item with entity data, get the stored request from buffer state.
Sourcepub fn grid(&self) -> LuaEquipmentGrid
pub fn grid(&self) -> LuaEquipmentGrid
The equipment grid of this item, if any.
Sourcepub fn is_blueprint(&self) -> bool
pub fn is_blueprint(&self) -> bool
If this is a blueprint item.
Sourcepub fn is_blueprint_book(&self) -> bool
pub fn is_blueprint_book(&self) -> bool
If this is a blueprint book item.
Sourcepub fn is_deconstruction_item(&self) -> bool
pub fn is_deconstruction_item(&self) -> bool
If this is a deconstruction tool item.
Sourcepub fn is_item_with_entity_data(&self) -> bool
pub fn is_item_with_entity_data(&self) -> bool
If this is an item with entity data item.
Sourcepub fn is_item_with_inventory(&self) -> bool
pub fn is_item_with_inventory(&self) -> bool
If this is an item with inventory item.
Sourcepub fn is_item_with_label(&self) -> bool
pub fn is_item_with_label(&self) -> bool
If this is an item with label item.
If this is an item with tags item.
Sourcepub fn is_repair_tool(&self) -> bool
pub fn is_repair_tool(&self) -> bool
If this is a repair tool item.
Sourcepub fn is_selection_tool(&self) -> bool
pub fn is_selection_tool(&self) -> bool
If this is a selection tool item.
Sourcepub fn is_upgrade_item(&self) -> bool
pub fn is_upgrade_item(&self) -> bool
If this is a upgrade item.
Sourcepub fn item_number(&self) -> u64
pub fn item_number(&self) -> u64
The unique identifier for this item, if any. Note that this ID stays the same no matter where the item is moved to.
Sourcepub fn label_color(&self) -> Color
pub fn label_color(&self) -> Color
The current label color for this item, if any.
Sourcepub fn mapper_count(&self) -> u32
pub fn mapper_count(&self) -> u32
The current count of mappers in the upgrade item.
Sourcepub fn owner_location(&self) -> ItemLocationData
pub fn owner_location(&self) -> ItemLocationData
The location of this item if it can be found.
Sourcepub fn planner_description(&self) -> &str
pub fn planner_description(&self) -> &str
The description for this deconstruction planner or upgrade planner
Sourcepub fn preview_icons(&self) -> Vec<BlueprintSignalIcon>
pub fn preview_icons(&self) -> Vec<BlueprintSignalIcon>
Icons of this blueprint item, blueprint book, deconstruction item or upgrade planner. An item that doesn’t have icons returns nil on read and throws error on write.
Sourcepub fn tile_filter_count(&self) -> u32
pub fn tile_filter_count(&self) -> u32
The number of tile filters this deconstruction item has.
Sourcepub fn tile_filter_mode(&self) -> &str
pub fn tile_filter_mode(&self) -> &str
The blacklist/whitelist tile filter mode for this deconstruction item.
Sourcepub fn tile_filters(&self) -> Vec<LuaAny>
pub fn tile_filters(&self) -> Vec<LuaAny>
The tile filters for this deconstruction item. The attribute is a sparse array with the keys representing the index of the filter. Reading filters always returns an array of strings which are the tile prototype names.
Sourcepub fn tile_selection_mode(&self) -> &str
pub fn tile_selection_mode(&self) -> &str
The tile selection mode for this deconstruction item.
Sourcepub fn trees_and_rocks_only(&self) -> bool
pub fn trees_and_rocks_only(&self) -> bool
If this deconstruction item is set to allow trees and rocks only.
Sourcepub fn item(&self) -> LuaItem
pub fn item(&self) -> LuaItem
If the item has additional data, returns LuaItem pointing at the extra data, otherwise returns nil.
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 prototype(&self) -> LuaItemPrototype
pub fn prototype(&self) -> LuaItemPrototype
Prototype of the item held in this stack.
Sourcepub fn quality(&self) -> LuaQualityPrototype
pub fn quality(&self) -> LuaQualityPrototype
The quality of this item.
Sourcepub fn spoil_percent(&self) -> f64
pub fn spoil_percent(&self) -> f64
The percent spoiled this item is if it spoils. 0 in the case of the item not spoiling.
Sourcepub fn spoil_tick(&self) -> u32
pub fn spoil_tick(&self) -> u32
The tick this item spoils, or 0 if it does not spoil. When writing, setting to anything < the current game tick will spoil the item instantly.
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 valid_for_read(&self) -> bool
pub fn valid_for_read(&self) -> bool
Is this valid for reading? Differs from the usual valid in that valid will be true even if the item stack is blank but the entity that holds it is still valid.
Sourcepub fn build_blueprint(
&self,
params: LuaItemCommonBuildBlueprintParams,
) -> Vec<LuaEntity>
pub fn build_blueprint( &self, params: LuaItemCommonBuildBlueprintParams, ) -> Vec<LuaEntity>
Build this blueprint at the given location.
Built entities can be come invalid between the building of the blueprint and the function returning if by_player or raise_built is used and one of those events invalidates the entity.
Sourcepub fn cancel_deconstruct_area(
&self,
params: LuaItemCommonCancelDeconstructAreaParams,
)
pub fn cancel_deconstruct_area( &self, params: LuaItemCommonCancelDeconstructAreaParams, )
Cancel deconstruct the given area with this deconstruction item.
Sourcepub fn clear_blueprint(&self)
pub fn clear_blueprint(&self)
Clears this blueprint item.
Sourcepub fn clear_deconstruction_item(&self)
pub fn clear_deconstruction_item(&self)
Clears all settings/filters on this deconstruction item resetting it to default values.
Sourcepub fn clear_upgrade_item(&self)
pub fn clear_upgrade_item(&self)
Clears all settings/filters on this upgrade item resetting it to default values.
Sourcepub fn create_blueprint(
&self,
params: LuaItemCommonCreateBlueprintParams,
) -> LuaAny
pub fn create_blueprint( &self, params: LuaItemCommonCreateBlueprintParams, ) -> LuaAny
Sets up this blueprint using the found blueprintable entities/tiles on the surface.
Sourcepub fn deconstruct_area(&self, params: LuaItemCommonDeconstructAreaParams)
pub fn deconstruct_area(&self, params: LuaItemCommonDeconstructAreaParams)
Deconstruct the given area with this deconstruction item.
Sourcepub fn get_blueprint_entities(&self) -> Option<Vec<BlueprintEntity>>
pub fn get_blueprint_entities(&self) -> Option<Vec<BlueprintEntity>>
The entities in this blueprint.
Sourcepub fn get_blueprint_entity_count(&self) -> u32
pub fn get_blueprint_entity_count(&self) -> u32
Gets the number of entities in this blueprint item.
Sourcepub fn get_blueprint_entity_tag(&self, index: u32, tag: &str) -> Option<LuaAny>
pub fn get_blueprint_entity_tag(&self, index: u32, tag: &str) -> Option<LuaAny>
Gets the given tag on the given blueprint entity index in this blueprint item.
Gets the tags for the given blueprint entity index in this blueprint item.
Sourcepub fn get_blueprint_tiles(&self) -> Option<Vec<Tile>>
pub fn get_blueprint_tiles(&self) -> Option<Vec<Tile>>
A list of the tiles in this blueprint.
Sourcepub fn get_entity_filter(&self, index: u32) -> Option<ItemFilter>
pub fn get_entity_filter(&self, index: u32) -> Option<ItemFilter>
Gets the entity filter at the given index for this deconstruction item.
Sourcepub fn get_inventory(&self, inventory: &str) -> Option<LuaInventory>
pub fn get_inventory(&self, inventory: &str) -> Option<LuaInventory>
Access the inner inventory of an item.
Sourcepub fn get_mapper(&self, index: u32, type: LuaItemCommonType) -> Option<LuaAny>
pub fn get_mapper(&self, index: u32, type: LuaItemCommonType) -> Option<LuaAny>
Gets the filter at the given index for this upgrade item. Note that sources ("from" type) that are undefined will read as {type = "item"}, while destinations ("to" type) that are undefined will read as nil.
In contrast to LuaItemCommon::set_mapper, indices past the upgrade item’s current size are considered to be out of bounds.
Sourcepub fn get_tag(&self, tag_name: &str) -> Option<LuaAny>
pub fn get_tag(&self, tag_name: &str) -> Option<LuaAny>
Gets the tag with the given name or returns nil if it doesn’t exist.
Sourcepub fn get_tag_names(&self) -> Vec<&str>
pub fn get_tag_names(&self) -> Vec<&str>
Gets the names of all tags on this item.
Sourcepub fn get_tile_filter(&self, index: u32) -> Option<&str>
pub fn get_tile_filter(&self, index: u32) -> Option<&str>
Gets the tile filter at the given index for this deconstruction item.
Sourcepub fn is_blueprint_setup(&self) -> bool
pub fn is_blueprint_setup(&self) -> bool
Is this blueprint item setup? I.e. is it a non-empty blueprint?
Sourcepub fn remove_tag(&self, tag: &str) -> bool
pub fn remove_tag(&self, tag: &str) -> bool
Removes a tag with the given name.
Sourcepub fn set_blueprint_entities(&self, entities: Vec<BlueprintEntity>)
pub fn set_blueprint_entities(&self, entities: Vec<BlueprintEntity>)
Set new entities to be a part of this blueprint.
Sourcepub fn set_blueprint_entity_tag(&self, index: u32, tag: &str, value: LuaAny)
pub fn set_blueprint_entity_tag(&self, index: u32, tag: &str, value: LuaAny)
Sets the given tag on the given blueprint entity index in this blueprint item.
Sets the tags on the given blueprint entity index in this blueprint item.
Sourcepub fn set_blueprint_tiles(&self, tiles: Vec<Tile>)
pub fn set_blueprint_tiles(&self, tiles: Vec<Tile>)
Set specific tiles in this blueprint.
Sourcepub fn set_entity_filter(&self, filter: Option<ItemFilter>, index: u32) -> bool
pub fn set_entity_filter(&self, filter: Option<ItemFilter>, index: u32) -> bool
Sets the entity filter at the given index for this deconstruction item.
Sourcepub fn set_mapper(&self, index: u32, mapper: LuaAny, type: LuaItemCommonType)
pub fn set_mapper(&self, index: u32, mapper: LuaAny, type: LuaItemCommonType)
Sets the module filter at the given index for this upgrade item.
In contrast to LuaItemCommon::get_mapper, indices past the upgrade item’s current size are valid and expand the list of mappings accordingly, if within reasonable bounds.
Sourcepub fn set_tile_filter(&self, filter: LuaAny, index: u32) -> bool
pub fn set_tile_filter(&self, filter: LuaAny, index: u32) -> bool
Sets the tile filter at the given index for this deconstruction item.
Sourcepub fn add_durability(&self, amount: f64)
pub fn add_durability(&self, amount: f64)
Add durability to this tool item.
Sourcepub fn can_set_stack(&self, stack: Option<LuaAny>) -> bool
pub fn can_set_stack(&self, stack: Option<LuaAny>) -> bool
Would a call to LuaItemStack::set_stack succeed?
Sourcepub fn create_grid(&self) -> LuaEquipmentGrid
pub fn create_grid(&self) -> LuaEquipmentGrid
Creates the equipment grid for this item if it doesn’t exist and this is an item-with-entity-data that supports equipment grids.
Sourcepub fn drain_ammo(&self, amount: f32)
pub fn drain_ammo(&self, amount: f32)
Remove ammo from this ammo item.
Sourcepub fn drain_durability(&self, amount: f64)
pub fn drain_durability(&self, amount: f64)
Remove durability from this tool item.
Sourcepub fn export_stack(&self) -> &str
pub fn export_stack(&self) -> &str
Export a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) to a string.
Sourcepub fn import_stack(&self, data: &str) -> i32
pub fn import_stack(&self, data: &str) -> i32
Import a supported item (blueprint, blueprint-book, deconstruction-planner, upgrade-planner, item-with-tags) from a string.
Sourcepub fn set_stack(&self, stack: Option<LuaAny>) -> bool
pub fn set_stack(&self, stack: Option<LuaAny>) -> bool
Set this item stack to another item stack.
Sourcepub fn swap_stack(&self, stack: LuaItemStack) -> bool
pub fn swap_stack(&self, stack: LuaItemStack) -> bool
Swaps this item stack with the given item stack if allowed.
Sourcepub fn transfer_stack(&self, amount: Option<u32>, stack: LuaAny) -> bool
pub fn transfer_stack(&self, amount: Option<u32>, stack: LuaAny) -> bool
Transfers the given item stack into this item stack.
Sourcepub fn use_capsule(
&self,
entity: LuaEntity,
target_position: MapPosition,
) -> Vec<LuaEntity>
pub fn use_capsule( &self, entity: LuaEntity, target_position: MapPosition, ) -> Vec<LuaEntity>
Use the capsule item with the entity as the source, targeting the given position.
Trait Implementations§
Source§impl Clone for LuaItemStack
impl Clone for LuaItemStack
Source§fn clone(&self) -> LuaItemStack
fn clone(&self) -> LuaItemStack
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more