Module m_salvageable
Documentation for the modules-m_salvageable module in /std/modules/m_salvageable.c.
Module Information
Module for salvageable items handling breaking them down into “realistic” components so you don’t get metal out of a wooden shields.
Initial version by Tsath@PLEXUS, 2020.
Functions
-
int query_salvage_level()
int query_salvage_level() Returns the salvage level determining how much material an object will drop when salvaged. This function returns sane values for weapons, armour and pelts.
-
void set_direct_salvage(mapping salv)
Sets the direct materials retrieved from salvaging this item. The argument is a mapping containing the material gained and the number of them.
“plastic bag”:2 etc
-
mapping query_direct_salvage()
Returns the mapping containing the direct salvageable items.
-
void set_damaged()
void set_damaged() Sets the object as DAMAGED_EQ_NAME meaning reduced durability, and gives it a new adjective.
-
int is_damaged()
int is_damaged() Returns true is the object is damaged, else 0.
-
string primary_salvage()
- Returns the material that is the most prevalent in the item.
- example:
set_salvageable(([“wood”:15, “metal”:85, ])); would return: primary_salvage() -> “metal”
-
int set_salvageable(mapping s)
int set_salvageable(mapping s) Sets the salvage mapping for object. Salvage mappings contains valid categories are defined by being part of:
CRAFTING_D->query_salvage_categories();
- example:
set_salvageable(([“chemical”:5, “metal”:85, “mineral”:10, ]));
The numbers must sum to 100, or the salvage mapping will be rejected.
-
int is_salvageable()
int is_salvageable() Returns 1 if the object is salvageable, otherwise 0. If the object doesn’t have a valid salvage mapping (see set_salvageable()) it always returns 0.
-
mapping query_salvageable()
mapping query_salvageable() Returns the salvage mapping set by set_salvageable().
File generated by Lima 1.1a4 reStructured Text daemon.