Stats
Stats are variables that store data associated with a house. They can be global or player-specific. Global stats are shared across all players, while player stats are specific to each player. Stats are defined using the global
or player
keyword followed by the stat type and name. Stat definitions must be placed before event handlers. For example:
house MyHouse {
global counter: int;
player score: int;
}
After compilation these stats will have the same names for ease of use. You can access them manually in the plot using the %stat.global/counter%
or %stat.player/score%
placeholders.
Note: Each house can have up to 20 global and 20 player stats.
Global Stats
Global stats are shared across all players in the plot. They are useful for storing data that needs to be accessed by all players. For example, you can use global stats to keep track of some global state of the plot, such as the number of players who have visited the plot.
Global stats are defined using the global
keyword followed by the stat type and name. The initial value of a global stat is 0
by rules of the Housing. For example:
house MyHouse {
global counter: int;
}
In this example, a global stat named counter
of type int
is defined.
Player Stats
Player stats are specific to each player in the plot. They are useful for storing data that needs to be accessed by individual players. For example, you can use player stats to keep track of a player's score, balance or any other player-specific data.
Player stats are defined using the player
keyword followed by the stat type and name. The initial value of a player stat is 0
by rules of the Housing. For example:
house MyHouse {
player score: int;
}
In this example, a player stat named score
of type int
is defined.
Stat Types
Stats use all the types that are available in the language. Read more about Types.