Skip to main content

LuaItemCommon

Struct LuaItemCommon 

Source
pub struct LuaItemCommon;
Expand description

Common methods related to usage of item with data. It is useful when LuaItemStack contains item with data or in general with LuaItem as it can only point at an item with data.

Implementations§

Source§

impl LuaItemCommon

Source

pub fn active_index(&self) -> u32

The active blueprint index for this blueprint book. nil if this blueprint book is empty.

Source

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.

Source

pub fn ammo(&self) -> u32

Number of bullets left in the magazine.

Source

pub fn blueprint_absolute_snapping(&self) -> bool

If absolute snapping is enabled on this blueprint item.

Source

pub fn blueprint_description(&self) -> &str

The description for this blueprint or blueprint book

Source

pub fn blueprint_position_relative_to_grid(&self) -> TilePosition

The offset from the absolute grid. nil if absolute snapping is not enabled.

Source

pub fn blueprint_snap_to_grid(&self) -> TilePosition

The snapping grid size in this blueprint item. nil if snapping is not enabled.

Source

pub fn cost_to_build(&self) -> Vec<ItemWithQualityCount>

List of raw materials required to build this blueprint.

Source

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.

Source

pub fn default_icons(&self) -> Vec<BlueprintSignalIcon>

The default icons for a blueprint item.

Source

pub fn durability(&self) -> f64

Durability of the contained item. Automatically capped at the item’s maximum durability.

Source

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.

Source

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.

Source

pub fn entity_color(&self) -> Color

If this is an item with entity data, get the stored entity color.

Source

pub fn entity_driver_is_gunner(&self) -> bool

If this is an item with entity data, get the stored driver is gunner state.

Source

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.

Source

pub fn entity_filter_count(&self) -> u32

The number of entity filters this deconstruction item has.

Source

pub fn entity_filter_mode(&self) -> &str

The blacklist/whitelist entity filter mode for this deconstruction item.

Source

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.

Source

pub fn entity_label(&self) -> &str

If this is an item with entity data, get the stored entity label.

Source

pub fn entity_logistic_sections(&self) -> LogisticSections

If this is an item with entity data, get the stored logistic filters.

Source

pub fn entity_logistics_enabled(&self) -> bool

If this is an item with entity data, get the stored vehicle logistics enabled state.

Source

pub fn entity_request_from_buffers(&self) -> bool

If this is an item with entity data, get the stored request from buffer state.

Source

pub fn grid(&self) -> LuaEquipmentGrid

The equipment grid of this item, if any.

Source

pub fn is_ammo(&self) -> bool

If this is an ammo item.

Source

pub fn is_armor(&self) -> bool

If this is an armor item.

Source

pub fn is_blueprint(&self) -> bool

If this is a blueprint item.

Source

pub fn is_blueprint_book(&self) -> bool

If this is a blueprint book item.

Source

pub fn is_deconstruction_item(&self) -> bool

If this is a deconstruction tool item.

Source

pub fn is_item_with_entity_data(&self) -> bool

If this is an item with entity data item.

Source

pub fn is_item_with_inventory(&self) -> bool

If this is an item with inventory item.

Source

pub fn is_item_with_label(&self) -> bool

If this is an item with label item.

Source

pub fn is_item_with_tags(&self) -> bool

If this is an item with tags item.

Source

pub fn is_repair_tool(&self) -> bool

If this is a repair tool item.

Source

pub fn is_selection_tool(&self) -> bool

If this is a selection tool item.

Source

pub fn is_tool(&self) -> bool

If this is a tool item.

Source

pub fn is_upgrade_item(&self) -> bool

If this is a upgrade item.

Source

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.

Source

pub fn label(&self) -> &str

The current label for this item, if any.

Source

pub fn label_color(&self) -> Color

The current label color for this item, if any.

Source

pub fn mapper_count(&self) -> u32

The current count of mappers in the upgrade item.

Source

pub fn owner_location(&self) -> ItemLocationData

The location of this item if it can be found.

Source

pub fn planner_description(&self) -> &str

The description for this deconstruction planner or upgrade planner

Source

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.

Source

pub fn tags(&self) -> LuaAny

Source

pub fn tile_filter_count(&self) -> u32

The number of tile filters this deconstruction item has.

Source

pub fn tile_filter_mode(&self) -> &str

The blacklist/whitelist tile filter mode for this deconstruction item.

Source

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.

Source

pub fn tile_selection_mode(&self) -> &str

The tile selection mode for this deconstruction item.

Source

pub fn trees_and_rocks_only(&self) -> bool

If this deconstruction item is set to allow trees and rocks only.

Source

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.

Source

pub fn cancel_deconstruct_area( &self, params: LuaItemCommonCancelDeconstructAreaParams, )

Cancel deconstruct the given area with this deconstruction item.

Source

pub fn clear_blueprint(&self)

Clears this blueprint item.

Source

pub fn clear_deconstruction_item(&self)

Clears all settings/filters on this deconstruction item resetting it to default values.

Source

pub fn clear_upgrade_item(&self)

Clears all settings/filters on this upgrade item resetting it to default values.

Source

pub fn create_blueprint( &self, params: LuaItemCommonCreateBlueprintParams, ) -> LuaAny

Sets up this blueprint using the found blueprintable entities/tiles on the surface.

Source

pub fn deconstruct_area(&self, params: LuaItemCommonDeconstructAreaParams)

Deconstruct the given area with this deconstruction item.

Source

pub fn get_blueprint_entities(&self) -> Option<Vec<BlueprintEntity>>

The entities in this blueprint.

Source

pub fn get_blueprint_entity_count(&self) -> u32

Gets the number of entities in this blueprint item.

Source

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.

Source

pub fn get_blueprint_entity_tags(&self, index: u32) -> LuaAny

Gets the tags for the given blueprint entity index in this blueprint item.

Source

pub fn get_blueprint_tiles(&self) -> Option<Vec<Tile>>

A list of the tiles in this blueprint.

Source

pub fn get_entity_filter(&self, index: u32) -> Option<ItemFilter>

Gets the entity filter at the given index for this deconstruction item.

Source

pub fn get_inventory(&self, inventory: &str) -> Option<LuaInventory>

Access the inner inventory of an item.

Source

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.

Source

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.

Source

pub fn get_tag_names(&self) -> Vec<&str>

Gets the names of all tags on this item.

Source

pub fn get_tile_filter(&self, index: u32) -> Option<&str>

Gets the tile filter at the given index for this deconstruction item.

Source

pub fn is_blueprint_setup(&self) -> bool

Is this blueprint item setup? I.e. is it a non-empty blueprint?

Source

pub fn remove_tag(&self, tag: &str) -> bool

Removes a tag with the given name.

Source

pub fn set_blueprint_entities(&self, entities: Vec<BlueprintEntity>)

Set new entities to be a part of this blueprint.

Source

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.

Source

pub fn set_blueprint_entity_tags(&self, index: u32, tags: LuaAny)

Sets the tags on the given blueprint entity index in this blueprint item.

Source

pub fn set_blueprint_tiles(&self, tiles: Vec<Tile>)

Set specific tiles in this blueprint.

Source

pub fn set_entity_filter(&self, filter: Option<ItemFilter>, index: u32) -> bool

Sets the entity filter at the given index for this deconstruction item.

Source

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.

Source

pub fn set_tag(&self, tag: LuaAny, tag_name: &str)

Sets the tag with the given name and value.

Source

pub fn set_tile_filter(&self, filter: LuaAny, index: u32) -> bool

Sets the tile filter at the given index for this deconstruction item.

Trait Implementations§

Source§

impl Clone for LuaItemCommon

Source§

fn clone(&self) -> LuaItemCommon

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LuaItemCommon

Source§

impl Debug for LuaItemCommon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LuaItemCommon

Source§

fn default() -> LuaItemCommon

Returns the “default value” for a type. Read more
Source§

impl Eq for LuaItemCommon

Source§

impl From<LuaItemCommon> for LuaAny

Source§

fn from(_: LuaItemCommon) -> Self

Converts to this type from the input type.
Source§

impl LuaObject for LuaItemCommon

Source§

impl PartialEq for LuaItemCommon

Source§

fn eq(&self, other: &LuaItemCommon) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LuaItemCommon

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.