/tg/ Station 13 - Modules - TypesVar Details - Proc Details

preference

Represents an individual preference.

Vars

abstract_typeDo not instantiate if type matches this.
can_randomizeIf set, will be available to randomize, but only if the preference is for PREFERENCE_CHARACTER.
categoryThe category of preference, for use by the PreferencesMenu. This isn't used for anything other than as a key for UI data. It is up to the PreferencesMenu UI itself to interpret it.
priorityThe priority of when to apply this preference. Used for when you need to rely on another preference.
randomize_by_defaultIf randomizable (PREFERENCE_CHARACTER and can_randomize), whether or not to enable randomization by default. This doesn't mean it'll always be random, but rather if a player DOES have random body on, will this already be randomized?
relevant_external_organIf the selected species has this in its /datum/species/var/external_organs, will show the feature as selectable.
relevant_head_flagIf the selected species has this head_flag by default, will show the feature as selectable.
relevant_inherent_traitIf the selected species has this in its /datum/species/inherent_traits, will show the feature as selectable.
relevant_mutant_bodypartIf the selected species has this in its /datum/species/mutant_bodyparts, will show the feature as selectable.
savefile_identifierWhat savefile should this preference be read from? Valid values are PREFERENCE_CHARACTER and PREFERENCE_PLAYER. See the documentation in code/__DEFINES/preferences.dm.
savefile_keyThe key inside the savefile to use. This is also sent to the UI. Once you pick this, don't change it.

Procs

apply_to_clientApply this preference onto the given client. Called when the savefile_identifier == PREFERENCE_PLAYER.
apply_to_client_updatedFired when the preference is updated. Calls apply_to_client by default, but can be overridden.
apply_to_humanApply this preference onto the given human. Must be overriden by subtypes. Called when the savefile_identifier == PREFERENCE_CHARACTER.
compile_constant_dataReturns data compiled into the preferences JSON asset
compile_ui_dataReturns data to be sent to users in the menu
create_default_valueProduce a default, potentially random value for when no value for this preference is found in the savefile. Either this or create_informed_default_value must be overriden by subtypes.
create_informed_default_valueProduce a default, potentially random value for when no value for this preference is found in the savefile. Unlike create_default_value(), will provide the preferences object if you need to use it. If not overriden, will call create_default_value() instead.
create_random_valueProduce a random value for the purposes of character randomization. Will just create a default value by default.
deserializeCalled on the saved input when retrieving. Also called by the value sent from the user through UI. Do not trust it. Input is the value inside the savefile, output is to tell other code what the value is. This is useful either for more optimal data saving or for migrating older data. Must be overridden by subtypes. Can return null if no value was found.
get_spritesheet_keyReturns the key that will be used in the spritesheet for a given value.
included_in_randomization_flagsGiven randomization flags, will return whether or not this preference should be randomized.
is_accessibleReturns whether or not this preference is accessible. If FALSE, will not show in the UI and will not be editable (by update_preference).
is_randomizableReturns whether or not a preference can be randomized.
is_validChecks that a given value is valid. Must be overriden by subtypes. Any type can be passed through.
readGiven a savefile, return either the saved data or an acceptable default. This will write to the savefile if a value was not found with the new value.
serializeCalled on the input while saving. Input is the current value, output is what to save in the savefile.
should_show_on_pageReturns whether or not, given the PREFERENCE_TAB_*, this preference should appear.
writeGiven a savefile, writes the inputted value. Returns TRUE for a successful application. Return FALSE if it is invalid.

Var Details

abstract_type

Do not instantiate if type matches this.

can_randomize

If set, will be available to randomize, but only if the preference is for PREFERENCE_CHARACTER.

category

The category of preference, for use by the PreferencesMenu. This isn't used for anything other than as a key for UI data. It is up to the PreferencesMenu UI itself to interpret it.

priority

The priority of when to apply this preference. Used for when you need to rely on another preference.

randomize_by_default

If randomizable (PREFERENCE_CHARACTER and can_randomize), whether or not to enable randomization by default. This doesn't mean it'll always be random, but rather if a player DOES have random body on, will this already be randomized?

relevant_external_organ

If the selected species has this in its /datum/species/var/external_organs, will show the feature as selectable.

relevant_head_flag

If the selected species has this head_flag by default, will show the feature as selectable.

relevant_inherent_trait

If the selected species has this in its /datum/species/inherent_traits, will show the feature as selectable.

relevant_mutant_bodypart

If the selected species has this in its /datum/species/mutant_bodyparts, will show the feature as selectable.

savefile_identifier

What savefile should this preference be read from? Valid values are PREFERENCE_CHARACTER and PREFERENCE_PLAYER. See the documentation in code/__DEFINES/preferences.dm.

savefile_key

The key inside the savefile to use. This is also sent to the UI. Once you pick this, don't change it.

Proc Details

apply_to_client

Apply this preference onto the given client. Called when the savefile_identifier == PREFERENCE_PLAYER.

apply_to_client_updated

Fired when the preference is updated. Calls apply_to_client by default, but can be overridden.

apply_to_human

Apply this preference onto the given human. Must be overriden by subtypes. Called when the savefile_identifier == PREFERENCE_CHARACTER.

compile_constant_data

Returns data compiled into the preferences JSON asset

compile_ui_data

Returns data to be sent to users in the menu

create_default_value

Produce a default, potentially random value for when no value for this preference is found in the savefile. Either this or create_informed_default_value must be overriden by subtypes.

create_informed_default_value

Produce a default, potentially random value for when no value for this preference is found in the savefile. Unlike create_default_value(), will provide the preferences object if you need to use it. If not overriden, will call create_default_value() instead.

create_random_value

Produce a random value for the purposes of character randomization. Will just create a default value by default.

deserialize

Called on the saved input when retrieving. Also called by the value sent from the user through UI. Do not trust it. Input is the value inside the savefile, output is to tell other code what the value is. This is useful either for more optimal data saving or for migrating older data. Must be overridden by subtypes. Can return null if no value was found.

get_spritesheet_key

Returns the key that will be used in the spritesheet for a given value.

included_in_randomization_flags

Given randomization flags, will return whether or not this preference should be randomized.

is_accessible

Returns whether or not this preference is accessible. If FALSE, will not show in the UI and will not be editable (by update_preference).

is_randomizable

Returns whether or not a preference can be randomized.

is_valid

Checks that a given value is valid. Must be overriden by subtypes. Any type can be passed through.

read

Given a savefile, return either the saved data or an acceptable default. This will write to the savefile if a value was not found with the new value.

serialize

Called on the input while saving. Input is the current value, output is what to save in the savefile.

should_show_on_page

Returns whether or not, given the PREFERENCE_TAB_*, this preference should appear.

write

Given a savefile, writes the inputted value. Returns TRUE for a successful application. Return FALSE if it is invalid.