Skip to main content

Round

The round represents the current state of the game. There is only ever one round at a time; you can get the current round in code using the GetRound API.

Types

type VictoryData = {
Victor: Victor,
DidTimeout: boolean,
EndedAt: number,
Music: Sound?,
},

Properties

NameTypeDescription
GamemodeGamemodeDefinitionThe current gamemode. Readonly.
Extras{[any]: any}Extra information about the round.
Highlights{[string]: Highlight}The highlights for the round. The key is the highlight group.
ElapsedPhaseTimenumberThe amount of time that has passed in the current phase. Resets when the phase changes.
PhaseLengthnumberThe max duration of the current phase.
VictoryDataVictoryData?The victory data for the round. Readonly.

Methods

GetItemDefinition

Returns the item definition given the name of the item. When an maps and gamemodes define items with the same name, map item definitions are prioritised over gamemode item definitions.

Parameters

NameTypeDefaultDescription
namestringThe name of the item.

Returns

AnyItemDefinition?

GetAmmoDefinition

Returns the ammo definition given the name of the ammo. When an maps and gamemodes define ammo with the same name, map ammo definitions are prioritised over gamemode ammo definitions.

Parameters

NameTypeDefaultDescription
namestringThe name of the ammo.

Returns

AnyAmmoDefinition?

GetInteractableDefinition

Returns a defined interactable given the name of the interactable. When an maps and gamemodes define interactables with the same name, map interactable definitions are prioritised over gamemode interactable definitions.

Parameters

NameTypeDefaultDescription
namestringThe name of the interactable.

Returns

InteractableDefinition?

LoadMap

Loads a map.

Parameters

NameTypeDefaultDescription
mapMapThe map.

GetMap

Returns the current map. Errors if no map is loaded (which should never happen).

Returns

Map

GetItems

Returns a dictionary of all MapThings to loaded Items.

Returns

{[MapThing]: AnyItem}

GetItem

Returns the Item given the MapThing. Returns nil if the item is not loaded.

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

AnyItem?

LoadItem

Loads an item given a MapThing. If the item is already loaded, returns the existing item.

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

AnyItem

GetAmmoBoxes

Returns a dictionary of all MapThings to loaded AmmoBoxes.

Returns

{[MapThing]: AmmoBox}

GetAmmoBox

Returns the AmmoBox given the MapThing. Returns nil if the ammo box is not loaded.

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

AmmoBox?

GetInteractables

Returns a dictionary of all MapThings to loaded Interactables.

Returns

{[MapThing]: Interactable}

GetInteractable

Returns the Interactable given the MapThing. Returns nil if the interactable is not loaded.

AddInteractable

Loads a defined interactable in the round. Returns the loaded interactable.

Parameters

NameTypeDefaultDescription
definitionInteractableDefinitionThe interactable definition.
mapThingMapThing?The map thing. Can be nil.

Returns

Interactable

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

Interactable?

GetProps

Returns a dictionary of all MapThings to loaded Props.

Returns

{[MapThing]: Prop}

GetProp

Returns the Prop given the MapThing. Returns nil if the prop is not loaded.

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

Prop?

LoadProp

Loads a prop given a MapThing. If the prop is already loaded, returns the existing prop.

Parameters

NameTypeDefaultDescription
mapThingMapThingThe map thing.

Returns

Prop

GetParticipants

Returns a dictionary of usernames to participants.

Returns

{string: Participant}

GetParticipant

Returns the participant given the username, player object, character model, or instance of their character model. Returns nil if the participant is not found.

Parameters

NameTypeDefaultDescription
identifierInstance | stringThe participant's name, player object, character model, or instance of their character model.

Returns

Participant?

AddPlayer

Loads a player to the round, optionally with karma. Returns the participant.

Parameters

NameTypeDefaultDescription
playerPlayerThe player to load.
karmanumber?1000The player's karma.

Returns

Participant

RemoveParticipant

Removes a participant from the round.

Parameters

NameTypeDefaultDescription
participantParticipantThe participant to remove.
isRejoiningbooleanTrue if this participant is going to be re-added after being removed.

Returns

()

AddEvent

Adds an event to the event log. Note this accepts event data, not events.

Parameters

NameTypeDefaultDescription
eventRoundEventDataThe event to add.

Returns

()

GetEventLog

Returns the event log. Note, the event log does not store event data, but rather events.

Returns

{Event}

AddHighlight

Adds a highlight to the round. Highlights are stored by group - if a highlight group already exists, it will be overwritten if the new highlight has a higher priority.

Parameters

NameTypeDefaultDescription
highlightHighlightThe highlight to add.

Returns

()

GetPhase

Returns the current phase of the round.

Returns

Phase

SetPhase

Changes the phase of the round, for a specified duration.

Parameters

NameTypeDefaultDescription
phasePhaseThe phase to change to.
durationnumberThe duration of the phase.

Returns

()

IsPreGame

Returns true if the round is in the waiting or preparing phase.

Returns

boolean

IsInProgress

Returns true if the round is in the playing phase.

Returns

boolean

IsPostGame

Returns true if the round is in the highlights or intermission phase.

Returns

boolean

Pause

Pauses or unpauses the round.

Parameters

NameTypeDefaultDescription
pausedbooleanWhether to pause or unpause the round.

Returns

()

IsPaused

Returns true if the round is paused.

Returns

boolean

Finish

Ends the round with a victory for a certain participant or role. Also specifies if the round ended in a timeout.

Parameters

NameTypeDefaultDescription
victorVictorThe victor of the round.
didTimeoutbooleanTrue if the round ended in a timeout.

Returns

()

GetRoleFromRoleName

Returns the role given the role name. Errors if the role is not found.

Parameters

NameTypeDefaultDescription
roleNamestringThe role name.

Returns

Role

GetParticipantsWithRole

Returns all participants with a certain role.

Parameters

NameTypeDefaultDescription
roleRoleThe role.

Returns

{Participant}

SendMessage

Sends a message (notification or chat message) to a player or group of players.

Parameters

NameTypeDefaultDescription
to{Player} | Player?all playersThe players to send the message to.
messagestringThe message to send.
kindMessageKind?"All"The kind of message to send.

Returns

()