Skip to content

CraftSchoolInstance ​

Inherits: RefCounted

Runtime instance of a craft school for a specific entity Contains learned recipes, skill progress, and active crafting state

Variables ​

CraftSchoolDefinitiondefinitionnull
intcurrent_skill_level1
intcurrent_experience0
inttotal_experience0
Arraylearned_recipe_ids[]
boolis_unlockedfalse
intcurrent_tier0
Array[int]chosen_specializations[]
VariantrngRandomNumberGenerator.new()
CraftingJobactive_craft_jobnull
Array[CraftingJob]craft_queue[]
intoriginal_craft_total0
ChronoManagerchrono_manager
Arraypending_outputs[]

Methods ​

SkillTierget_tier_definition()
intget_level_cap()
boolis_at_tier_cap()
boolset_tier( tier_index: int )
boolhas_specialization( spec_id: int )
Stringget_specialization_blocker( spec_id: int )
boolchoose_specialization( spec_id: int )
boolremove_specialization( spec_id: int, force: bool = false )
Array[SkillSpecialization]get_chosen_specializations()
floatget_craft_speed_factor()
Dictionaryget_extra_output()
floatget_material_save_chance()
floatget_skill_gain_bonus()
boollearn_school()
boolforget_school()
boolis_recipe_known( recipe_id: int )
boollearn_recipe( recipe_id: int )
boolunlearn_recipe( recipe_id: int )
Array[CraftingRecipeDefinition]get_known_recipes()
Array[CraftingRecipeDefinition]get_available_recipes()
voidadd_experience( amount: int )
intchange_skill_level( delta: int )
intget_skill_points_to_next_level()
floatget_skill_progress_percentage()
Array[CraftingJob]start_craft( recipe: CraftingRecipeDefinition, crafter: Entity, quantity: int = 1 )
boolcancel_craft()
boolcancel_current_craft()
boolclear_queue()
intget_total_craft_count()
floatget_total_remaining_time()
Dictionaryget_queue_info()
Array[CraftingJob]get_all_craft_jobs()
voidgain_skill( factor: float, base_points: int )
Dictionaryto_dict()
voidfrom_dict( data: Dictionary, craft_school_def: CraftSchoolDefinition, crafter: Entity = null )

Signals ​

queue_updated( queue_size: int ) ​

Emitted when the queue of jobs changes: the new size.

skill_up( new_level: int ) ​

A skill-up happened (a craft gave one level)

tier_changed( new_tier: int, old_tier: int ) ​

A tier or a specialization changed

specialization_changed( specialization_id: int, chosen: bool ) ​

Emitted when a specialization is chosen or dropped.

learned_changed( learned: bool ) ​

The profession was learned or forgotten

skill_level_changed( old_level: int, new_level: int ) ​

Emitted when the skill level changes: the old and the new level.

experience_gained( amount: int ) ​

Emitted when the school gains experience.

Variable descriptions ​

CraftSchoolDefinition definition = null ​

Reference to the static definition

int current_skill_level = 1 ​

Current skill level in this school

int current_experience = 0 ​

Current experience points towards next level

int total_experience = 0 ​

Total experience ever gained in this school

Array learned_recipe_ids = [] ​

Recipe IDs that have been learned (beyond starting recipes)

bool is_unlocked = false ​

Whether this school has been unlocked/learned

int current_tier = 0 ​

The tier the crafter is in (a number from 0, the first tier)

Array[int] chosen_specializations = [] ​

The ids of the specializations the crafter has chosen

rng = RandomNumberGenerator.new() ​

The chance rolls of a craft (skill-ups, extra output, getting the materials back). A test can seed it

CraftingJob active_craft_job = null ​

Currently active crafting job (if any)

Array[CraftingJob] craft_queue = [] ​

Queue of pending crafts (for systems that support queuing)

int original_craft_total = 0 ​

Total number of crafts originally started (for progress display)

ChronoManager chrono_manager ​

ChronoManager system ref

Array pending_outputs = [] ​

Items that were made and wait for room in the bag of the crafter

Method descriptions ​

SkillTier get_tier_definition() ​

The tier the crafter is in, as a resource (null when the profession has no tiers)

int get_level_cap() ​

The highest level the crafter can reach now: the cap of the tier, or the maximum skill level

bool is_at_tier_cap() ​

Is the crafter at the cap of the tier, with a higher tier that a trainer can give?

bool set_tier( tier_index: int ) ​

Puts the crafter in a tier. A lower tier brings the level down to its cap. False when nothing changed or the tier does not exist

bool has_specialization( spec_id: int ) ​

========== SPECIALIZATIONS ==========

String get_specialization_blocker( spec_id: int ) ​

Why the crafter cannot choose a specialization now ("" = they can)

bool choose_specialization( spec_id: int ) ​

Chooses a specialization (its rewards are given by whoever gives it: see SpecializationReward). False when it cannot be chosen

bool remove_specialization( spec_id: int, force: bool = false ) ​

Gives a specialization up (only one that can be changed, unless force)

Array[SkillSpecialization] get_chosen_specializations() ​

The chosen specializations, as resources

float get_craft_speed_factor() ​

How much of the craft time is left: 1.0 normally, less with faster crafting (never below a tenth)

Dictionary get_extra_output() ​

The chance (percent, up to 100) of a craft making more than it should, and how many more

float get_material_save_chance() ​

The chance (percent, up to 100) of a finished craft giving the materials back

float get_skill_gain_bonus() ​

The bonus to what a craft teaches, as a factor: 0.25 = a quarter more

bool learn_school() ​

Learn the profession (false when it is learned already)

bool forget_school() ​

Forget the profession: nothing can be crafted with it until it is learned again. Its level and recipes stay (false when it was not learned)

bool is_recipe_known( recipe_id: int ) ​

Check if a specific recipe is known

bool learn_recipe( recipe_id: int ) ​

Learn a new recipe (false if it is already known or does not exist)

bool unlearn_recipe( recipe_id: int ) ​

Forget a learned recipe (a starting recipe is always known)

Array[CraftingRecipeDefinition] get_known_recipes() ​

Get all known recipes for this school

Array[CraftingRecipeDefinition] get_available_recipes() ​

Get recipes available at current skill level

void add_experience( amount: int ) ​

Add experience and handle level ups

int change_skill_level( delta: int ) ​

Change the skill level directly (a reward gives or takes levels): between 1 and the maximum, with the signal

int get_skill_points_to_next_level() ​

Get skill points needed for next level

float get_skill_progress_percentage() ​

Get skill progress as percentage (0.0 to 1.0)

Array[CraftingJob] start_craft( recipe: CraftingRecipeDefinition, crafter: Entity, quantity: int = 1 ) ​

Start crafting a recipe with queue support If quantity > 1, creates multiple individual jobs in the queue Returns array of all jobs created (empty array if failed)

bool cancel_craft() ​

Cancel active craft and clear queue

bool cancel_current_craft() ​

Cancel only the current active job, keep queue

bool clear_queue() ​

Cancel all queued crafts but not the active one

int get_total_craft_count() ​

Get total number of crafts (active + queued)

float get_total_remaining_time() ​

Get remaining time for all crafts (active + queue)

Dictionary get_queue_info() ​

Get information about the current queue state

Array[CraftingJob] get_all_craft_jobs() ​

Get array of all jobs (active + queued) for UI display

void gain_skill( factor: float, base_points: int ) ​

What an activity of the profession (a craft, a gather) does to the skill: factor (0 to 1) says how much it teaches at this level, base_points are its points. Points mode: points towards the next level. Skill-ups mode: a chance of one level at once

Dictionary to_dict() ​

The state of the school for a save: level, recipes, queue.

void from_dict( data: Dictionary, craft_school_def: CraftSchoolDefinition, crafter: Entity = null ) ​

Restores the school from a save.