Methods


Game:addFlag(flag: string, amount: number?)

Adds amount to a numeric flag named flag (or defines it if it does not exist)

@param flag — The name of the flag to add to

@param amount — (Defaults to 1)

Arguments:

flag: string

The name of the flag to add to

amount: number?

(Defaults to 1)

Returns:

new_value: number


Game:addFollower(chara: string|Follower, index: integer?)

Arguments:

chara: string|Follower

Followers are a type of Overworld character that follow the player's movements.

index: integer?


Game:addPartyMember(chara: string|PartyMember, index: any)

Arguments:

chara: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

index: any

Returns:

1: any


Game:checkPartyEquipped(item_id: string)

Arguments:

item_id: string

Returns:

1: boolean
2: integer










Game:encounter(encounter: string|Encounter, transition: (boolean|string)?, enemy: (table|Character)?, context: ChaserEnemy?)

Starts a battle using the specified encounter file.

@param encounter — The encounter id or instance to use for this battle.

@param transition — Whether to start in the transition state (Defaults to true). As a string, represents the state to start the battle in.

@param enemy — An enemy instance or list of enemies as Characters in the world that will transition into the battle.

Arguments:

encounter: string|Encounter

The encounter id or instance to use for this battle.

transition: (boolean|string)?

Whether to start in the transition state (Defaults to true). As a string, represents the state to start the battle in.

enemy: (table|Character)?

An enemy instance or list of enemies as Characters in the world that will transition into the battle.

context: ChaserEnemy?

An enemy found in the Overworld that can chase the player and start encounters.
ChaserEnemy is an Event* - naming an object enemy on an objects layer in a map creates this object. *(Does not inherit the Event class, inherits Character)
See this object's Fields for the configurable properties on this object.



Game:enter(previous_state: string, save_id: number?, save_name: string?, fade: boolean?)

Arguments:

previous_state: string
save_id: number?
save_name: string?
fade: boolean?


Game:enterShop(shop: string|Shop, options: table?)

Enters a shop

@param shop — The shop to enter

@param options — An optional table of leave_options for exiting the shop

Arguments:

shop: string|Shop

The shop to enter

options: table?

An optional table of leave_options for exiting the shop



Game:fadeIntoLegend(cutscene: string, legend_options: table?, fade_options: table?)

Arguments:

cutscene: string
legend_options: table?
fade_options: table?


Game:gameOver(x: number?, y: number?)

Arguments:

x: number?
y: number?






Game:getBorder()

Returns:

1: Border


Game:getConfig(key: string, merge: boolean?, deep_merge: boolean?)

Arguments:

key: string
merge: boolean?
deep_merge: boolean?

Returns:

1: any


Game:getFlag(flag: string, default: any)

Gets the value of the flag named flag, returning default if the flag does not exist

Arguments:

flag: string
default: any

Returns:

1: any




Game:getPartyIndex(chara: string|PartyMember)

Arguments:

chara: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

Returns:

1: integer


Game:getPartyMember(id: string)

Arguments:

id: string

Returns:

1: PartyMember?


Game:getRecruit(id: string)

Arguments:

id: string

Returns:

1: Recruit?


Game:getRecruits(include_incomplete: boolean?, include_hidden: boolean?)

Arguments:

include_incomplete: boolean?
include_hidden: boolean?

Returns:

1: Recruit[]








Game:getTension()

Returns:

1: number


Game:giveTension(amount: number)

Arguments:

amount: number

Returns:

change: number


Game:hasPartyMember(chara: string|PartyMember)

Arguments:

chara: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

Returns:

1: boolean?


Game:hasRecruit(recruit: string)

Arguments:

recruit: string

Returns:

1: boolean






Game:isLight()

Returns:

1: boolean




Game:load(data: SaveData?, index: number?, fade: boolean?)

Arguments:

data: SaveData?

All the data that gets saved by Kristal when the player saves their game

index: number?
fade: boolean?


Game:loadQuick(fade: boolean?)

Arguments:

fade: boolean?


Game:movePartyMember(chara: string|PartyMember, index: integer)

Arguments:

chara: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

index: integer

Returns:

1: string|PartyMember


Game:onKeyPressed(key: string, is_repeat: boolean)

Arguments:

key: string
is_repeat: boolean


Game:onKeyReleased(key: string)

Arguments:

key: string




Game:removeFollower(chara: string|Follower)

Arguments:

chara: string|Follower

Followers are a type of Overworld character that follow the player's movements.



Game:removePartyMember(chara: string|PartyMember)

Arguments:

chara: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().

Returns:

1: PartyMember?


Game:removeTension(amount: number)

Arguments:

amount: number

Returns:

change: number




Game:save(x: number, y: number)

Arguments:

x: number
y: number

Returns:

1: SaveData




Game:setBorder(border: (string|Border)?, time: number?)

Arguments:

border: (string|Border)?
time: number?


Game:setFlag(flag: string, value: any)

Sets the value of the flag named flag to value

Arguments:

flag: string
value: any


Game:setLight(light: boolean?)

Arguments:

light: boolean?


Game:setMaxTension(amount: number)

Arguments:

amount: number


Game:setPartyMembers(: string|PartyMember)

Arguments:

: string|PartyMember

The PartyMember class is a type of data class that stores information about a member of the party.
PartyMembers are stored in scripts/data/party, and extend this class. Their filepath starting from here becomes their id, unless an id is specified as an argument to Class().



Game:setTension(amount: number, dont_clamp: boolean?)

Arguments:

amount: number
dont_clamp: boolean?


Game:setTensionPreview(amount: number)

Arguments:

amount: number


Game:setupShop(shop: string|Shop)

Arguments:

shop: string|Shop

The class which all Shops in Kristal use.
Shop files should be located in scripts/shops, and will use their filepath relative to this location as an id by default.
Either World:shopTransition() or a Transition event with the property shop defined can be used to enter shops.



Game:startLegend(cutscene: string, options: table?)

Arguments:

cutscene: string
options: table?





Fields


Game.battle: Battle

The Battle Object manages everything related to battles in Kristal.
A globally available reference to the in-use Battle instance is stored in Game.battle.




Game.dark_inventory: DarkInventory

A type of inventory used to store items in the Dark World.




Game.gameover: GameOver

An object that is created whenever the player reaches a Game Over, responsible for managing the GameOver sequence.
The type of GameOver that plays (Chapter 1, Chapter 2, or Undertale) is dependent on the mod configuration and whether the death occurred in the Light World or not.


Game.inventory: DarkInventory|LightInventory

A type of inventory used to store items in the Dark World.




Game.legend: Legend

The handler object for Legend-style cutscenes.
For the object that is received by legend cutscene scripts, see LegendCutscene.




Game.light_inventory: LightInventory

A type of inventory used to store items in the Light World.












Game.quick_save: SaveData

All the data that gets saved by Kristal when the player saves their game






Game.shop: Shop

The class which all Shops in Kristal use.
Shop files should be located in scripts/shops, and will use their filepath relative to this location as an id by default.
Either World:shopTransition() or a Transition event with the property shop defined can be used to enter shops.


Game.stage: Stage

The Stage object in Kristal is designed to be the highest parent object at all times.
All throughout gameplay, the active stage is Game.stage, while when in the Kristal menu, Kristal.Stage is the stage instead.






Game.world: World

The World Object manages everything relating to the overworld in Kristal.
A globally available instance of World is stored in Game.world.




Undocumented







Game.encounter_enemies: table|Character

All types of character in the overworld inherit from the Character class.
This class is not to be confused with the psuedo-event NPC that is used for characters placed in the overworld.



Game.encounter_enemies: Character

All types of character in the overworld inherit from the Character class.
This class is not to be confused with the psuedo-event NPC that is used for characters placed in the overworld.







Game.old_soul_inv_timer: integer

Used to carry the soul invulnerability frames between waves