Skip to content

PlayerCurrencyChangedTrigger ​

Inherits: PlayerEventTrigger < EventTrigger < Resource

Triggers when the player gains or spends an amount of a currency. It counts what comes and goes from the moment it starts listening: 10 Boar Meat gained, 50 Gold spent. As an objective of a quest it shows the tally (3/10). A currency can stand for anything (meat, pelts, tokens): it takes no space in the bag.

Properties ​

intcurrency_id0
DirectiondirectionDirection.GAINED
intamount_required1
boolcount_existingfalse

Variables ​

intcurrent_amount0

Methods ​

Stringget_display_name()
Stringget_function_description()
intget_tally_target()
intget_tally_progress()
voidreset()
voidset_progress( amount: int )
voidsetup_player_connection( player: Player )
voidcleanup_player_connection( player: Player )
voidpoll()
boolis_triggered( event_data: Dictionary )
Stringgenerate_objective_description()

Enumerations ​

enum Direction ​

The options of direction: gained, lost, either.

  • GAINED = 0 - Counts what the player gains
  • LOST = 1 - Counts what the player spends or loses
  • EITHER = 2 - Counts both

Property descriptions ​

int currency_id = 0 ​

The currency to watch

Direction direction = Direction.GAINED ​

Which way the currency moves

int amount_required = 1 ​

How much has to be gained (or lost) before the trigger fires

bool count_existing = false ​

Count what the player already holds when the trigger starts (gained only): "have 10", not "gain 10 more"

Variable descriptions ​

int current_amount = 0 ​

What has been counted so far

Method descriptions ​

String get_display_name() ​

The name of the trigger in the editor.

String get_function_description() ​

The sentence the editor shows for the trigger, with {placeholders} for its values.

int get_tally_target() ​

The number the quest objective counts up to (0 when it does not count).

int get_tally_progress() ​

How far the count of the quest objective is now.

void reset() ​

The count starts again (the objective or event that owns this trigger starts over)

void set_progress( amount: int ) ​

The count from a save

void setup_player_connection( player: Player ) ​

Connects the signal of a player this trigger listens to.

void cleanup_player_connection( player: Player ) ​

Disconnects the signal of a player.

void poll() ​

What a start of the count that already holds enough says (an objective asks once it listens)

bool is_triggered( event_data: Dictionary ) ​

Does this event data satisfy the trigger? Called when the signal the trigger listens to fires.

String generate_objective_description() ​

The line of the quest objective this trigger makes ("Kill 5 wolves").