Constructor
World(map: string?)
@param map
— The optional name of a map to initially load with the world
Arguments:
map: string? | The optional name of a map to initially load with the world |
Methods
World:afterMenuClosed()
Runs whenever the menu is closed
World:attachFollowers(return_speed: number?)
Enables following for all of the player's current followers and causes them to walk to their positions
@param return_speed
— The walking speed of the followers while they return to the player
Arguments:
return_speed: number? | The walking speed of the followers while they return to the player |
World:attachFollowersImmediate()
Enables following for all of the player's current followers, and immediately teleports them to their positions
World:checkCollision(collider: Collider, enemy_check: boolean?)
Checks whether the input collider
is colliding with anything in the world
@param collider
— The collider to check collision for
@param enemy_check
— Whether to include the enemy collision map in the check
@return collided
— Whether a collision was found
@return with
— The object that was collided with
Arguments:
collider: Collider | The collider to check collision for |
enemy_check: boolean? | Whether to include the enemy collision map in the check |
Returns:
collided: boolean | Whether a collision was found |
with: Object? | The object that was collided with |
World:closeMenu()
Closes the menu
World:createMenu()
Creates the main overworld menu if it does not exist
The event createMenu
is called by this function, which can return a custom menu to use instead of the default Light/Dark menu
Returns:
1: DarkMenu|LightMenu |
World:detachFollowers()
Disables following for all of the player's current followers
World:fadeInto(callback: fun())
Fades the world out and into another piece of content
@param callback
— The callback that is run in the middle of the fade (fully faded out) to load the next piece of content
Arguments:
callback: fun() | The callback that is run in the middle of the fade (fully faded out) to load the next piece of content |
World:getActionBox(party_member: string|PartyMember)
Gets the action box instance for a member of the party
Arguments:
party_member: string|PartyMember | The PartyMember class is a type of data class that stores information about a member of the party. |
Returns:
1: OverworldActionBox? |
World:getCameraTarget()
Gets the object that the camera is currently targetting
Returns:
1: Object|nil |
World:getCellFlag(name: string, default: integer?)
Gets the value of a cell flag (a special flag which normally starts at -1 and increments by 1 at the start of every call, named after the call cutscene)
Arguments:
name: string | |
default: integer? |
Returns:
1: integer |
World:getCharacter(id: string, index: number?)
Gets a specific character currently present in the world
@param id
— The actor id of the character to search for
@param index
— The character's index, if they have multiple instances in the world. (Defaults to 1
)
@return chara
— The character instance, or nil
if it was not found
Arguments:
id: string | The actor id of the character to search for |
index: number? | The character's index, if they have multiple instances in the world. (Defaults to |
Returns:
chara: Character|nil | The character instance, or |
World:getCollision(enemy_check: boolean?)
Gets the collision map for the world
@param enemy_check
— Whether to include the enemy collision map (defaults to false
)
Arguments:
enemy_check: boolean? | Whether to include the enemy collision map (defaults to |
Returns:
1: Collider[] |
World:getEvent(id: string|number)
Gets a specific event present in the current map
@param id
— The unique numerical id of an event OR the text id of an event type to get the first instance of
@return event
— The event instnace, or nil
if it was not found
Arguments:
id: string|number | The unique numerical id of an event OR the text id of an event type to get the first instance of |
Returns:
event: Event | The event instnace, or |
World:getEvents(name: string?)
Gets a list of all instances of one type of event in the current maps
@param name
— The text id of the event to search for, fetches every event if nil
@return events
— A table containing every instance of the event in the current map
Arguments:
name: string? | The text id of the event to search for, fetches every event if |
Returns:
events: Event[] | A table containing every instance of the event in the current map |
World:getPartyCharacter(party: string|PartyMember)
Gets the Character
in the world of a party member
@param party
— The party member to get the character for
Arguments:
party: string|PartyMember | The party member to get the character for |
Returns:
1: Character? |
World:getPartyCharacterInParty(party: string|PartyMember)
Gets the Follower
or Player
of a character currently in the party
@param party
— The party member to get the character for
Arguments:
party: string|PartyMember | The party member to get the character for |
Returns:
1: (Follower|Player)? |
World:heal(target: string|PartyMember, amount: number, text: string?)
Heals a member of the party
@param target
— The party member to heal
@param amount
— The amount of HP to restore
@param text
— An optional text to display when HP is resotred in the Light World, before the HP restoration message
Arguments:
target: string|PartyMember | The party member to heal |
amount: number | The amount of HP to restore |
text: string? | An optional text to display when HP is resotred in the Light World, before the HP restoration message |
World:hideHealthBars()
Hides party member health bars
World:hurtParty(battler: string|Character, amount: number)
Hurts the party member battler
by amount
, or hurts the whole party for amount
@param battler
— The Character to hurt
@param amount
— The amount of damage to deal
@return killed
— Whether all targetted characters were knocked out by this damage
Arguments:
battler: string|Character | The Character to hurt |
amount: number | The amount of damage to deal |
Returns:
killed: boolean | Whether all targetted characters were knocked out by this damage |
World:loadMap(: unknown)
Loads into a new map file.
@param map
— The name of the map file to load
@param x
— The x-coordinate the player will spawn at in the new map
@param y
— The y-coordinate the player will spawn at in the new map
@param marker
— The name of the marker the player will spawn at in the new map (Defaults to "spawn"
)
@param facing
— The direction the party should be facing when they spawn in the new map
@param callback
— A callback to run once the map has finished loading (Post Map:onEnter())
@param ...
— Additional arguments that will be passed forward into Map:onEnter()
Arguments:
: unknown | Additional arguments that will be passed forward into Map:onEnter() |
World:mapTransition(: any)
Loads a new map and starts the transition effects for world music, borders, and the screen as a whole
@param ...
— Additional arguments that will be passed into World:loadMap()
See: World - World:loadMap()
Arguments:
: any | Additional arguments that will be passed into World:loadMap() |
World:onRemove(parent: Object)
Arguments:
parent: Object | The base class of all objects in Kristal. |
World:onStateChange(old: string, new: string)
Called whenever the state of the world changes
Arguments:
old: string | |
new: string |
World:openMenu(menu: (DarkMenu|LightMenu)?, layer: number?)
Opens the main overworld menu
@param menu
— An optional menu instance to open
@param layer
— The layer to create the menu on (defaults to WORLD_LAYERS["ui"]
or 600
)
Arguments:
menu: (DarkMenu|LightMenu)? | An optional menu instance to open |
layer: number? | The layer to create the menu on (defaults to |
Returns:
1: (DarkMenu|LightMenu)? |
World:parseLayer(layer: (string|number)?)
Parses a variable-type layer specification into a recognised layer
Arguments:
layer: (string|number)? |
Returns:
1: number |
World:partyReact(party_member: string|PartyMember, text: string, display_time: number?)
Creates a reaction text on a party member's healthbar (usually used for equipment and items)
@param party_member
— The party member who will react
@param text
— The text to display for the reaction
@param display_time
— The display time, in seconds, of the reaction (defaults to 5/3 seconds)
Arguments:
party_member: string|PartyMember | The party member who will react |
text: string | The text to display for the reaction |
display_time: number? | The display time, in seconds, of the reaction (defaults to 5/3 seconds) |
World:registerCall(name: string, scene: string)
Registers a phone call in the Light World CELL menu
@param name
— The name of the call as it will show in the CELL menu
@param scene
— The cutscene to play when the call is selected
Arguments:
name: string | The name of the call as it will show in the CELL menu |
scene: string | The cutscene to play when the call is selected |
World:removeFollower(chara: string|Follower)
Removes a follower
@param chara
— The Follower
or the follower's actor id to remove
@return follower
— The follower that was removed
Arguments:
chara: string|Follower | The |
Returns:
follower: Follower | The follower that was removed |
World:replaceCall(name: string, index: integer, scene: string)
Replaces a phone call in the Light World CELL menu with another
@param name
— The name of the call as it will show in the CELL menu
@param index
— The index of the call to replace
@param scene
— The cutscene to play when the call is selected
Arguments:
name: string | The name of the call as it will show in the CELL menu |
index: integer | The index of the call to replace |
scene: string | The cutscene to play when the call is selected |
World:setBattle(value: boolean)
Sets whether the player is currently in battle - cannot override being inside a battle area
Arguments:
value: boolean |
World:setCameraAttached(attached_x: boolean?, attached_y: boolean?)
Sets whether the camera should be attached to its target for each axis
@param attached_x
— Whether the camera's x-axis position should follow its target
@param attached_y
— Whether the camera's y-axis position should follow its target
Arguments:
attached_x: boolean? | Whether the camera's x-axis position should follow its target |
attached_y: boolean? | Whether the camera's y-axis position should follow its target |
World:setCameraAttachedX(attached: boolean?)
Sets whether the camera should follow its target on the x-axis
Arguments:
attached: boolean? |
World:setCameraAttachedY(attached: boolean?)
Sets whether the camera should follow its target on the y-axis
Arguments:
attached: boolean? |
World:setCameraTarget(target: Object?)
Sets the object the camera should target
Arguments:
target: Object? | The base class of all objects in Kristal. |
World:setCellFlag(name: string, value: integer)
Sets the value of a cell flag (a special flag which normally starts at -1 and increments by 1 at the start of every call, named after the call cutscene)
@param name
— The name of the flag to set
@param value
— The value to set the flag to
Arguments:
name: string | The name of the flag to set |
value: integer | The value to set the flag to |
World:setupMap(map: (string|table|Map)?, : unknown)
Sets up several variables for a new map
@param map
— The Map object, name, or data to load
@param ...
— Additional arguments that will be passed forward into Map:onEnter()
Arguments:
map: (string|table|Map)? | The Map object, name, or data to load |
: unknown | Additional arguments that will be passed forward into Map:onEnter() |
World:shakeCamera(x: number?, y: number?, friction: number?)
Arguments:
x: number? | |
y: number? | |
friction: number? |
World:shopTransition(shop: string|Shop, options: table?)
Transitions from the world into 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 |
World:showHealthBars()
Shows party member health bars
World:showText(text: string|string[], after: fun( WorldCutscene)?)
Shows a textbox with the input text
@param after
— A callback to run when the textbox is closed, receiving the cutscene instance used to display the text
Arguments:
text: string|string[] | |
after: fun( WorldCutscene)? | A callback to run when the textbox is closed, receiving the cutscene instance used to display the text |
World:spawnBullet(bullet: string?, : any)
Spawns a new WorldBullet
to the world
@param bullet
— The bullet to add to the world, if left unspecified, spawns the basic WorldBullet
@param ...
— Additional arguments to pass to the bullet's init() function
@return bullet
— The newly created bullet
Arguments:
bullet: string? | The bullet to add to the world, if left unspecified, spawns the basic |
: any | Additional arguments to pass to the bullet's init() function |
Returns:
bullet: WorldBullet | The newly created bullet |
World:spawnFollower(chara: string|Actor|Follower, options: (table|"index"|"party"|"temp"|"x"...(+1))?)
Spawns a follower into the world
@param chara
— The character to spawn as a follower
@param options
— A table defining additional properties to control the new follower
options:
| "x" -- The position of the follower
| "y" -- The position of the follower
| "index" -- The index of the follower in the list of followers
| "temp" -- Whether the follower is temporary and disappears when the current map is exited (defaults to `true`)
| "party" -- The id of the party member associated with this follower
Arguments:
chara: string|Actor|Follower | The character to spawn as a follower |
options: (table|"index"|"party"|"temp"|"x"...(+1))? | A table defining additional properties to control the new follower |
Returns:
1: Follower |
World:spawnNPC(actor: string|Actor, x: number, y: number, properties: table?)
Spawns a new NPC object in the world
@param actor
— The actor to use for the new NPC, either an id string or an actor object
@param x
— The x-coordinate to place the NPC at
@param y
— The y-coordinate to place the NPC at
@param properties
— A table of additional properties for the new NPC. Supports all the same values as an npc
map event
@return npc
— The newly created npc.
Arguments:
actor: string|Actor | The actor to use for the new NPC, either an id string or an actor object |
x: number | The x-coordinate to place the NPC at |
y: number | The y-coordinate to place the NPC at |
properties: table? | A table of additional properties for the new NPC. Supports all the same values as an |
Returns:
npc: NPC | The newly created npc. |
World:spawnObject(obj: Object, layer: (string|number)?)
Spawns an object to the world
@param obj
— The object to add to the world
@param layer
— The layer to place the object on
Arguments:
obj: Object | The object to add to the world |
layer: (string|number)? | The layer to place the object on |
Returns:
1: Object |
World:spawnParty(marker: (string| number, y)?, party: (string|PartyMember)[]?, extra: (string|Actor|Follower|[string|Actor|Follower, integer])[]?, facing: ("down"|"left"|"right"|"up")?)
Spawns characters in the world for the current party
@param marker
— The marker or co-ordinates to spawn the player at
@param party
— A table of party members to spawn (Defaults to Game.party
)
@param extra
— Additional followers to add that are not in the party (defaults to Game.temp_followers
)
@param facing
— The direction the party should be facing when they spawn
facing:
| "up"
| "down"
| "left"
| "right"
Arguments:
marker: (string| number, y)? | The marker or co-ordinates to spawn the player at |
party: (string|PartyMember)[]? | A table of party members to spawn (Defaults to |
extra: (string|Actor|Follower|[string|Actor|Follower, integer])[]? | Additional followers to add that are not in the party (defaults to |
facing: ("down"|"left"|"right"|"up")? | The direction the party should be facing when they spawn |
World:spawnPlayer(: "marker, chara"|"x, y, chara"|unknown)
Spawns the player into the world
@param ...
— Arguments detailing how the player spawns
@param party
— The party member ID associated with the player
...(param):
| "x, y, chara" -- The co-ordinates of the player spawn and the Actor (instance or id) to use for the player
| "marker, chara" -- The marker name to spawn the player at and the Actor (instance or id) to use for the player
Arguments:
: "marker, chara"|"x, y, chara"|unknown | Arguments detailing how the player spawns |
World:startCutscene(group: string, id: string, : any)
Starts a cutscene in the world
@param group
— The name of the group the cutscene is a part of
@param id
— The id of the cutscene
@param ...
— Additional arguments that will be passed to the cutscene function
@return The
— cutscene object that was created
Arguments:
group: string | The name of the group the cutscene is a part of |
id: string | The id of the cutscene |
: any | Additional arguments that will be passed to the cutscene function |
Returns:
The: WorldCutscene? | cutscene object that was created |
World:stopCutscene()
Stops the current cutscene
An error will be thrown when trying to stop a cutscene if none are active
World:transitionMusic(next: string, volume, fade_out: boolean?)
Transitions the music from the current track to the next
@param music
— The name of the file to play next
@param next
— The filename, volume, and pitch of the next track
@param fade_out
— Whether to fade out the currently playing track before playing the next track
Arguments:
next: string, volume | The filename, volume, and pitch of the next track |
fade_out: boolean? | Whether to fade out the currently playing track before playing the next track |
Fields
World.battle_alpha: number
The current alpha value of world battle content
World.battle_borders: table
(unused? See Map.battle_borders
)
World.bullets: WorldBullet[]
A table of currently active bullets
World.calls: table<[string, string]>
A list of calls available on the cell phone in the Light World CELL menu
World.camera: Camera
The camera object used to display the world
World.conroller_parent: Object
The object that all controllers are parented to
World.cutscene: WorldCutscene?
The WorldCutscene
object of the currently active cutscene, if present
World.door_delay: number
(Used internally) Timer variable for door transition sounds
World.followers: Follower[]
A table of all followers currently present in the world
World.in_battle: boolean
Whether the player is currently in a world battle set through `World:setBattle() (affects the visibility of world battle content)
World.in_battle_area: boolean
Whether the player is currently standing inside a battlearea of the map (affects the visibility of world battle content)
World.music: Music
The Music
instance that controls audio playback for this World
World.player: Player
The player character
World.soul: OverworldSoul
The soul of the player
World.state: string
The current state that this World
is in - should never be set manually, see World:setState()
instead
World.state_manager: StateManager
An object that manages the state of this World
World.transition_fade: number
(unused?)