crafting_stage
Singleton definitions for fabrication subsystem crafting stages. These define the individual steps for multi-stage crafting of items.
To create a new set of crafting steps, define new crafting stage singleton subtypes. The sequence must include at
least one crafting stage with a begins_with_object_type
set, and at least one craftin stage with a product
set.
Additionally, each crafting stage should be reachable through a previous step's next_stages
list.
Each stage will replace the input object with an instance of /obj/item/crafting_holder
or update the existing
crafting holder instance. In the event where product
is defined, the input object is instead replaced with a new
instance of product
.
Premade subtypes are made for ease of use of specific interactions, such as material stacks or welding tools.
Vars | |
begins_with_object_type | Typepath (types of /obj/item ). If set, objects of this type can be interacted with to start a crafting process and complete this stage, in place of a crafting holder. Only set this for the first step. |
---|---|
completion_trigger_type | Typepath (types of /obj/item ). Desired type of item to be used to reach this stage. |
consume_completion_trigger | Boolean. If set, the item used to reach this stage is consumed. |
item_desc | String. Visible description for the crafting holder while at this stage. |
item_icon | File (.dmi ). Icon file to use for the crafting holder while at this stage. |
item_icon_state | String (icon state). Icon state to use for the crafting holder while at this stage. |
next_stages | List (Paths, types of /singleton/crafting_stage ). Crafting stages this stage can lead into. |
product | Typepath (types of /obj/item ). Crafting result. If set, creates an instance of product instead of a crafting holder. Only set this for the final step. |
progress_message | String. Message displayed to user when this stage is reached. |
stack_consume_amount | Integer. If completion_trigger_type is a stack, this is how much to consume if consume_completion_trigger is TRUE . |
Procs | |
can_begin_with | Whether or not this crafting stage can begin with the provided item. |
consume | Handles consuming an item or part of a stack to reach this stage. |
get_next_stage | Retrieves the next crafting stage using the provided item. |
get_product | Instantiates and returns the crafting stage's product , if set. |
is_appropriate_tool | Checks if the item is the appropriate tool to reach this stage. |
on_insufficient_material | Handles failure feedback for insufficient materials in a stack. Called by consume() . |
on_progress | Handles additional logic to be performed when the crafting stage progresses to this point. |
progress_to | Handles checking if progressing to this crafting stage is possible, then performing the progression. |
Var Details
begins_with_object_type
Typepath (types of /obj/item
). If set, objects of this type can be interacted with to start a crafting process and complete this stage, in place of a crafting holder. Only set this for the first step.
completion_trigger_type
Typepath (types of /obj/item
). Desired type of item to be used to reach this stage.
consume_completion_trigger
Boolean. If set, the item used to reach this stage is consumed.
item_desc
String. Visible description for the crafting holder while at this stage.
item_icon
File (.dmi
). Icon file to use for the crafting holder while at this stage.
item_icon_state
String (icon state). Icon state to use for the crafting holder while at this stage.
next_stages
List (Paths, types of /singleton/crafting_stage
). Crafting stages this stage can lead into.
product
Typepath (types of /obj/item
). Crafting result. If set, creates an instance of product
instead of a crafting holder. Only set this for the final step.
progress_message
String. Message displayed to user when this stage is reached.
stack_consume_amount
Integer. If completion_trigger_type
is a stack, this is how much to consume if consume_completion_trigger
is TRUE
.
Proc Details
can_begin_with
Whether or not this crafting stage can begin with the provided item.
By default, passes through to a type check against begins_with_object_type
.
Parameters:
thing
- Item to check.
Returns boolean.
consume
Handles consuming an item or part of a stack to reach this stage.
Parameters:
user
- Mob performing the interaction.thing
- Item being used.target
- Prior stage's crafting holder (See/obj/item/crafting_holder
), or base object being interacted with (Seebegins_with_object_type
).
Returns boolean. If FALSE
, the item could not be consumed or there was not enough in the stack.
get_next_stage
Retrieves the next crafting stage using the provided item.
By default, checks all stages in next_stages
and compares the item
through the next stage's is_appropriate_tool()
check.
Parameters:
trigger
- Item to check.
Returns path (Types of /singleton/crafting_stage
).
get_product
Instantiates and returns the crafting stage's product
, if set.
Parameters:
work
- Prior stage's crafting holder (See/obj/item/crafting_holder
), or base object being interacted with (Seebegins_with_object_type
).
Returns instance of product
.
is_appropriate_tool
Checks if the item is the appropriate tool to reach this stage.
By default, passes through to a type check against completion_trigger_type
.
Parameters:
thing
- Item to check.user
(Defaultnull
) - Mob performing the interaction.
Returns boolean.
on_insufficient_material
Handles failure feedback for insufficient materials in a stack. Called by consume()
.
Parameters:
user
- Mob performing the interaction.thing
- Stack being used.
Has no return value.
on_progress
Handles additional logic to be performed when the crafting stage progresses to this point.
By default, displays progress_message
to the user.
Parameters:
user
- The mob performing the interaction.
Has no return value.
progress_to
Handles checking if progressing to this crafting stage is possible, then performing the progression.
By default, checks is_appropriate_tool()
and consume()
then, if TRUE
, calls on_progress()
.
Parameters:
thing
- Item being used to progress the stage.user
- User performing the interaction.target
- Prior stage's crafting holder (See/obj/item/crafting_holder
), or base object being interacted with (Seebegins_with_object_type
).
Returns boolean. If TRUE
, the stage was able to progress.