API reference
Events
Subscribe with events.on(name, handler). A mod's own events are named freely and scoped to the mod; other mods' events are "their.mod-id:name".
Modding events
| Event | Sides | When | Payload |
|---|---|---|---|
map.loaded | client, server | A map finished loading. The payload says which one and whether a mod made it. | { id = string, mod = string? } |
map.unloading | client, server | The current map is about to be left. | { id = string } |
player.joined | client, server | A player joined the session. | Player |
player.left | client, server | A player left the session. The Player is no longer valid. | Player |
ui.screen.closed | client | One of the game's screens closed. | { id = string } |
ui.screen.opened | client | One of the game's screens opened, so a mod can change it again. | { id = string } |
Game events
Events the game itself raises, read-only. The payload holds the event's fields.
| Event | Sides | When | Payload |
|---|---|---|---|
game.AfterSceneLoadEvent | client, server | The game's AfterSceneLoadEvent event, read-only. | { sceneName } |
game.BeforeSceneLoadEvent | client, server | The game's BeforeSceneLoadEvent event, read-only. | { sceneName } |
game.BlockAddedEvent | client, server | The game's BlockAddedEvent event, read-only. Travels between peers, so positions in it are absolute. | { structureId, blockId, position } |
game.BlockInteractRequest | client, server | The game's BlockInteractRequest event, read-only. Travels between peers, so positions in it are absolute. | { blockUuid } |
game.BlockRemovedEvent | client, server | The game's BlockRemovedEvent event, read-only. Travels between peers, so positions in it are absolute. | { structureId, blockId, position } |
game.BuildingStructureEvents.Initialization.RequestSpawn | client, server | The game's BuildingStructureEvents.Initialization.RequestSpawn event, read-only. Travels between peers, so positions in it are absolute. | { ownerUuid, forceNew } |
game.BuildingStructureEvents.Initialization.SpawnResponse | client, server | The game's BuildingStructureEvents.Initialization.SpawnResponse event, read-only. Travels between peers, so positions in it are absolute. | { isSuccess, structureUuid, reason } |
game.BuildingStructureEvents.Ownership.OnOwnershipChanged | client, server | The game's BuildingStructureEvents.Ownership.OnOwnershipChanged event, read-only. Travels between peers, so positions in it are absolute. | { structure, prevOwner, newOwner } |
game.BuildingStructureEvents.Ownership.OnOwnershipRecalled | client, server | The game's BuildingStructureEvents.Ownership.OnOwnershipRecalled event, read-only. Travels between peers, so positions in it are absolute. | { structure, prevOwner } |
game.BuildingStructureEvents.Ownership.RequestTransfer | client, server | The game's BuildingStructureEvents.Ownership.RequestTransfer event, read-only. Travels between peers, so positions in it are absolute. | { toPlayer } |
game.BuildingStructureEvents.Ownership.TransferResponse | client, server | The game's BuildingStructureEvents.Ownership.TransferResponse event, read-only. Travels between peers, so positions in it are absolute. | { isSuccess, newOwner } |
game.BuildingStructureEvents.Placement.RequestMoveBesidePlayer | client, server | The game's BuildingStructureEvents.Placement.RequestMoveBesidePlayer event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid } |
game.BuildingStructureEvents.Placement.RequestMoveStructure | client, server | The game's BuildingStructureEvents.Placement.RequestMoveStructure event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid, position, rotation } |
game.BuildingStructureEvents.Retrieve.RequestDeleteStructure | client, server | The game's BuildingStructureEvents.Retrieve.RequestDeleteStructure event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid } |
game.BuildingStructureEvents.Retrieve.RequestOwnedStructures | client, server | The game's BuildingStructureEvents.Retrieve.RequestOwnedStructures event, read-only. Travels between peers, so positions in it are absolute. | { ownerUuid } |
game.BuildingStructureEvents.Retrieve.RequestStructureBlocks | client, server | The game's BuildingStructureEvents.Retrieve.RequestStructureBlocks event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid } |
game.BuildingStructureEvents.Retrieve.ReturnOwnedStructures | client, server | The game's BuildingStructureEvents.Retrieve.ReturnOwnedStructures event, read-only. Travels between peers, so positions in it are absolute. | { structureUuids, summaries } |
game.BuildingStructureEvents.Retrieve.ReturnStructureBlocks | client, server | The game's BuildingStructureEvents.Retrieve.ReturnStructureBlocks event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid, results } |
game.BuildingStructureEvents.Retrieve.StructureRemoved | client, server | The game's BuildingStructureEvents.Retrieve.StructureRemoved event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid } |
game.ChangeBuildingMode.Approved | client, server | The game's ChangeBuildingMode.Approved event, read-only. | { open } |
game.ChangeBuildingMode.Complete | client, server | The game's ChangeBuildingMode.Complete event, read-only. Travels between peers, so positions in it are absolute. | { open, isSuccess } |
game.ChangeBuildingMode.Request | client, server | The game's ChangeBuildingMode.Request event, read-only. Travels between peers, so positions in it are absolute. | { open } |
game.ChangeBuildingMode.Response | client, server | The game's ChangeBuildingMode.Response event, read-only. Travels between peers, so positions in it are absolute. | { open, isSuccess } |
game.ClientCameraViewSyncEvent | client, server | The game's ClientCameraViewSyncEvent event, read-only. Travels between peers, so positions in it are absolute. | { playerUuid, cameraUuid } |
game.ClientVehicleInputSyncEvent | client, server | The game's ClientVehicleInputSyncEvent event, read-only. Travels between peers, so positions in it are absolute. | { playerUuid, pressedKeys, yaw, pitch, hasAim } |
game.PlayerPlacementEvent | client, server | The game's PlayerPlacementEvent event, read-only. Travels between peers, so positions in it are absolute. | { playerNetId, position, reason } |
game.SeatHopRequest | client, server | The game's SeatHopRequest event, read-only. Travels between peers, so positions in it are absolute. | { backwards } |
game.SeatInteractionRequest | client, server | The game's SeatInteractionRequest event, read-only. Travels between peers, so positions in it are absolute. | { playerUuid, blockUuid } |
game.SeatOccupancyChangedEvent | client, server | The game's SeatOccupancyChangedEvent event, read-only. Travels between peers, so positions in it are absolute. | { blockUuid, playerNetId, occupied, exitPosition, hasExit } |
game.StructureBuiltEvent | client, server | The game's StructureBuiltEvent event, read-only. Travels between peers, so positions in it are absolute. | { structureId, position } |
game.StructureDesignPoseSyncEvent | client, server | The game's StructureDesignPoseSyncEvent event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid, position, rotation, subGroups } |
game.StructureTransformSyncEvent | client, server | The game's StructureTransformSyncEvent event, read-only. Travels between peers, so positions in it are absolute. | { structureUuid, position, rotation } |
game.WeaponFiredEvent | client, server | The game's WeaponFiredEvent event, read-only. Travels between peers, so positions in it are absolute. | { blockUuid, origin, hit, kind, didHit, effectVariant, blockDataId, isOffline } |