Networkclientrpc
Based on game build 718694 | Last updated: 2026-04-04
Overview
The networkclientrpc component is the central networking layer for Don't Starve Together's Remote Procedure Call (RPC) system. It manages all communication between clients, servers, and shards by defining handler tables, input validation utilities, and queue processing logic. This component ensures secure and validated transmission of player actions including movement, combat, inventory management, crafting, and skill tree updates. It provides separate handler registries for server-bound RPCs (player actions), client-bound RPCs (server notifications), and shard-bound RPCs (multi-shard synchronization). The system includes rate limiting, timeline validation, and mod RPC extension capabilities. Input validation functions guard against malformed data, while the queue processor handles pending RPCs each simulation tick. This component is critical for maintaining game state consistency across the network and preventing cheating through server-side validation of all client-initiated actions.
Usage example
-- Register a custom mod RPC handler on the server
AddModRPCHandler("mymod", "CustomAction", function(player, data)
if player and player.components.inventory then
player.components.talker:Say("Action received!")
end
end)
-- Send the mod RPC from client to server
local rpc_info = GetModRPC("mymod", "CustomAction")
if rpc_info then
SendModRPCToServer(rpc_info, { action_type = "greet" })
end
-- Validate incoming parameters using built-in helpers
if checknumber(data.value) and checkstring(data.name) then
-- Process valid data
end
Dependencies & tags
External dependencies:
util-- Required module for utility functions (providesorderedPairs,distsq,VecUtil_Length,RunInSandboxSafe)worldsettings_overrides-- Required module for syncing world settingsTheWorld-- Used to push invalidrpc eventVector3-- Used to create position vectors for coordinatesBRANCH-- Global variable checked for dev branch assertionsTheNet-- Used to send RPCs to server, client, and shardsThePlayer-- Used to access components and push events in client handlersTheSim-- Used to ReskinEntity in ReskinWorldMigratorTheSkillTree-- Used to get skill names from IDsTheGenericKV-- Used to store accomplishment dataTheScrapbookPartitions-- Used to teach scrapbook dataShardPortals-- Iterated to find worldmigrator entitiesChatHistory-- Used to send and receive chat historyAllRecipes-- Iterated to find recipe data by RPC IDPREFAB_SKINS-- Used to resolve skin indices for recipesGetPopupFromPopupCode-- Utility function to resolve popup handlersGetString-- Localization function to get announcement stringsShard_SyncWorldSettings-- Global function to sync world settingsShard_SyncBossDefeated-- Global function to sync boss stateShard_SyncMermKingExists-- Global function to sync Merm King stateShard_SyncMermKingTrident-- Global function to sync Merm King Trident stateShard_SyncMermKingCrown-- Global function to sync Merm King Crown stateShard_SyncMermKingPauldron-- Global function to sync Merm King Pauldron stateGetWorldStateTagObjectFromNamespace-- Global function to get world state tag objectTheShard-- Used to retrieve shard ID for shard RPC validationShard_IsWorldAvailable-- Used to validate shard availability in HandleShardRPC
Internal tables:
RPC_HANDLERS-- Table referenced to generate RPC codes and handle incoming RPCsCLIENT_RPC_HANDLERS-- Table defined and used for client-side RPC handlingSHARD_RPC_HANDLERS-- Table defined and used for shard-side RPC handlingUSERID_RPCS-- Table used to check RPC sender permissionsMOD_RPC/MOD_RPC_HANDLERS-- Tables for mod RPC registrationCLIENT_MOD_RPC/CLIENT_MOD_RPC_HANDLERS-- Tables for client mod RPC registrationSHARD_MOD_RPC/SHARD_MOD_RPC_HANDLERS-- Tables for shard mod RPC registration
Components used:
playercontroller-- Accessed on player entity to handle remote input actionsinventory-- Accessed on player entity to manage item slots and equipmentlocomotor-- Accessed on player entity to handle strafe facingsteeringwheeluser-- Accessed on player entity to handle boat steeringcontainer-- Accessed on target entity to manage inventory slotsbuilder-- Accessed via player.components.builder for recipe craftingtalker-- Accessed via player.components.talker for announcementsgiftreceiver-- Accessed via player.components.giftreceiver for gift openingskilltreeupdater-- Accessed via player.components.skilltreeupdater for skill managementwriteable-- Accessed via target.components.writeable for text settingcookbookupdater-- Accessed via ThePlayer.components.cookbookupdater for recipe learningplantregistryupdater-- Accessed via ThePlayer.components.plantregistryupdater for plant datashardtransactionsteps-- Accessed via TheWorld.components.shardtransactionsteps for shard syncworldmigrator-- Accessed via v.components.worldmigrator for ID checking in ReskinWorldMigrator
Tags:
- None
Properties
| Property | Type | Default Value | Description |
|---|
Main functions
checkbool(val)
- Description: Validates if a value is nil or a boolean.
- Parameters:
val-- any type, value to check if nil or boolean
- Returns: boolean
- Error states: None
checknumber(val)
- Description: Validates if a value is a number.
- Parameters:
val-- any type, value to check if number
- Returns: boolean
- Error states: None
checkuint(val)
- Description: Validates if a value is a number and represents an unsigned integer.
- Parameters:
val-- any type, value to check if unsigned integer
- Returns: boolean
- Error states: None
checkstring(val)
- Description: Validates if a value is a string.
- Parameters:
val-- any type, value to check if string
- Returns: boolean
- Error states: None
checkentity(val)
- Description: Validates if a value is a table, typically representing an entity.
- Parameters:
val-- any type, value to check if table (entity)
- Returns: boolean
- Error states: None
optbool(val)
- Description: Alias for checkbool, validates optional boolean.
- Parameters:
val-- any type, value to check if nil or boolean
- Returns: boolean
- Error states: None
optnumber(val)
- Description: Validates if a value is nil or a number.
- Parameters:
val-- any type, value to check if nil or number
- Returns: boolean
- Error states: None
optuint(val)
- Description: Validates if a value is nil or an unsigned integer.
- Parameters:
val-- any type, value to check if nil or unsigned integer
- Returns: boolean
- Error states: None
optstring(val)
- Description: Validates if a value is nil or a string.
- Parameters:
val-- any type, value to check if nil or string
- Returns: boolean
- Error states: None
optentity(val)
- Description: Validates if a value is nil or a table (entity).
- Parameters:
val-- any type, value to check if nil or table
- Returns: boolean
- Error states: None
printinvalid(rpcname, player)
- Description: Logs invalid RPC attempts and pushes an event for mods.
- Parameters:
rpcname-- string, name of the RPCplayer-- Entity, the player entity
- Returns: nil
- Error states: Asserts false in dev branch
printinvalidplatform(rpcname, player, action, relative_x, relative_z, platform, platform_relative)
- Description: Logs debugging info when platform lookup fails in an RPC.
- Parameters:
rpcname-- string, name of the RPCplayer-- Entity, the player entityaction-- any, action contextrelative_x-- number, x offsetrelative_z-- number, z offsetplatform-- Entity, platform entityplatform_relative-- boolean, if position is relative
- Returns: nil
- Error states: None
IsRotationValid(rot)
- Description: Checks if a rotation value is within valid finite bounds.
- Parameters:
rot-- number, rotation value
- Returns: boolean
- Error states: None
IsPointInRange(player, x, z)
- Description: Checks if a point is within 4096 distance squared from the player.
- Parameters:
player-- Entity, the player entityx-- number, target x coordinatez-- number, target z coordinate
- Returns: boolean
- Error states: None
ConvertPlatformRelativePositionToAbsolutePosition(relative_x, relative_z, platform, platform_relative)
- Description: Converts relative platform coordinates to absolute world coordinates.
- Parameters:
relative_x-- number, relative xrelative_z-- number, relative zplatform-- Entity, platform entityplatform_relative-- boolean, if conversion is needed
- Returns: number, number
- Error states: Returns nil if platform is missing when required
LeftClick(player, action, x, z, target, isreleased, controlmods, noforce, mod_name, platform, platform_relative, spellbook, spell_id)
- Description: Handles remote left click actions from the client.
- Parameters:
player-- Entity, the playeraction-- number, action typex-- number, x coordinatez-- number, z coordinatetarget-- Entity (Optional), target entityisreleased-- boolean (Optional), mouse release statecontrolmods-- number (Optional), control modifiersnoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod nameplatform-- Entity (Optional), platformplatform_relative-- boolean, relative position flagspellbook-- Entity (Optional), spellbookspell_id-- number (Optional), spell ID
- Returns: nil
- Error states: Returns early if validation fails or out of range
RightClick(player, action, x, z, target, rotation, isreleased, controlmods, noforce, mod_name, platform, platform_relative)
- Description: Handles remote right click actions from the client.
- Parameters:
player-- Entity, the playeraction-- number, action typex-- number, x coordinatez-- number, z coordinatetarget-- Entity (Optional), target entityrotation-- number (Optional), rotation angleisreleased-- boolean (Optional), mouse release statecontrolmods-- number (Optional), control modifiersnoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod nameplatform-- Entity (Optional), platformplatform_relative-- boolean, relative position flag
- Returns: nil
- Error states: Returns early if validation fails or out of range
ActionButton(player, action, target, isreleased, noforce, mod_name)
- Description: Handles remote action button presses.
- Parameters:
player-- Entity, the playeraction-- number (Optional), action typetarget-- Entity (Optional), target entityisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
AttackButton(player, target, forceattack, noforce, isleftmouse, isreleased)
- Description: Handles remote attack button presses.
- Parameters:
player-- Entity, the playertarget-- Entity (Optional), target entityforceattack-- boolean (Optional), force attack flagnoforce-- boolean (Optional), no force flagisleftmouse-- boolean (Optional), left mouse flagisreleased-- boolean (Optional), release state
- Returns: nil
- Error states: Returns early if validation fails
InspectButton(player, target)
- Description: Handles remote inspect button presses.
- Parameters:
player-- Entity, the playertarget-- Entity, target entity
- Returns: nil
- Error states: Returns early if target is invalid
ResurrectButton(player)
- Description: Handles remote resurrect button presses.
- Parameters:
player-- Entity, the player
- Returns: nil
- Error states: None
CharacterCommandWheelButton(player, target)
- Description: Handles remote character command wheel button presses.
- Parameters:
player-- Entity, the playertarget-- Entity, target entity
- Returns: nil
- Error states: Returns early if target is invalid
ControllerActionButton(player, action, target, isreleased, noforce, mod_name)
- Description: Handles remote controller action button presses.
- Parameters:
player-- Entity, the playeraction-- number, action typetarget-- Entity, target entityisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
ControllerActionButtonPoint(player, action, x, z, isreleased, noforce, mod_name, platform, platform_relative, isspecial, spellbook, spell_id)
- Description: Handles remote controller action button presses at a point.
- Parameters:
player-- Entity, the playeraction-- number, action typex-- number, x coordinatez-- number, z coordinateisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod nameplatform-- Entity (Optional), platformplatform_relative-- boolean, relative flagisspecial-- boolean (Optional), special action flagspellbook-- Entity (Optional), spellbookspell_id-- number (Optional), spell ID
- Returns: nil
- Error states: Returns early if validation fails or out of range
ControllerActionButtonDeploy(player, invobject, x, z, rotation, isreleased, platform, platform_relative)
- Description: Handles remote controller deploy actions.
- Parameters:
player-- Entity, the playerinvobject-- Entity, inventory objectx-- number, x coordinatez-- number, z coordinaterotation-- number (Optional), rotationisreleased-- boolean (Optional), release stateplatform-- Entity (Optional), platformplatform_relative-- boolean, relative flag
- Returns: nil
- Error states: Returns early if validation fails or out of range
ControllerAltActionButton(player, action, target, isreleased, noforce, mod_name)
- Description: Handles remote controller alt action button presses.
- Parameters:
player-- Entity, the playeraction-- number, action typetarget-- Entity, target entityisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flagmod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
ControllerAltActionButtonPoint(player, action, x, z, isreleased, noforce, isspecial, mod_name, platform, platform_relative)
- Description: Handles remote controller alt action button presses at a point.
- Parameters:
player-- Entity, the playeraction-- number, action typex-- number, x coordinatez-- number, z coordinateisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flagisspecial-- boolean (Optional), special flagmod_name-- string (Optional), mod nameplatform-- Entity (Optional), platformplatform_relative-- boolean, relative flag
- Returns: nil
- Error states: Returns early if validation fails or out of range
ControllerAttackButton(player, target, isreleased, noforce)
- Description: Handles remote controller attack button presses.
- Parameters:
player-- Entity, the playertarget-- Entity or boolean, target entity or trueisreleased-- boolean (Optional), release statenoforce-- boolean (Optional), force flag
- Returns: nil
- Error states: Returns early if validation fails
StopControl(player, control)
- Description: Handles remote stop control signals.
- Parameters:
player-- Entity, the playercontrol-- number, control ID
- Returns: nil
- Error states: Returns early if control is invalid
StopAllControls(player)
- Description: Handles remote stop all controls signal.
- Parameters:
player-- Entity, the player
- Returns: nil
- Error states: None
DirectWalking(player, x, z)
- Description: Handles remote direct walking input.
- Parameters:
player-- Entity, the playerx-- number, direction xz-- number, direction z
- Returns: nil
- Error states: Returns early if out of range
DragWalking(player, x, z, platform, platform_relative)
- Description: Handles remote drag walking input.
- Parameters:
player-- Entity, the playerx-- number, x coordinatez-- number, z coordinateplatform-- Entity (Optional), platformplatform_relative-- boolean, relative flag
- Returns: nil
- Error states: Returns early if validation fails or out of range
PredictWalking(player, x, z, isdirectwalking, isstart, platform, platform_relative, overridemovetime)
- Description: Handles remote walking prediction input.
- Parameters:
player-- Entity, the playerx-- number, x coordinatez-- number, z coordinateisdirectwalking-- boolean, direct walk flagisstart-- boolean, start flagplatform-- Entity (Optional), platformplatform_relative-- boolean, relative flagoverridemovetime-- number (Optional), move time override
- Returns: nil
- Error states: Returns early if validation fails or out of range
PredictOverrideLocomote(player, dir)
- Description: Handles remote locomotion override prediction.
- Parameters:
player-- Entity, the playerdir-- number, direction
- Returns: nil
- Error states: Returns early if dir is invalid
StrafeFacing(player, dir)
- Description: Handles remote strafe facing changes.
- Parameters:
player-- Entity, the playerdir-- number, direction
- Returns: nil
- Error states: Returns early if dir is invalid or player is busy
StartHop(player, x, z, platform, has_platform)
- Description: Handles remote hop start actions.
- Parameters:
player-- Entity, the playerx-- number, x coordinatez-- number, z coordinateplatform-- Entity (Optional), platformhas_platform-- boolean, platform existence flag
- Returns: nil
- Error states: Returns early if validation fails or platform mismatch
SteerBoat(player, dir_x, dir_z)
- Description: Handles remote boat steering input.
- Parameters:
player-- Entity, the playerdir_x-- number, steer xdir_z-- number, steer z
- Returns: nil
- Error states: Returns early if validation fails
StopWalking(player)
- Description: Handles remote stop walking signal.
- Parameters:
player-- Entity, the player
- Returns: nil
- Error states: None
DoWidgetButtonAction(player, action, target, mod_name)
- Description: Handles remote widget button actions.
- Parameters:
player-- Entity, the playeraction-- any, deprecated actiontarget-- Entity (Optional), target entitymod_name-- string, deprecated mod name
- Returns: nil
- Error states: Returns early if target invalid or container not opened by player
ReturnActiveItem(player)
- Description: Handles returning active item to inventory.
- Parameters:
player-- Entity, the player
- Returns: nil
- Error states: None
PutOneOfActiveItemInSlot(player, slot, container)
- Description: Handles putting one of active item into a slot.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
PutAllOfActiveItemInSlot(player, slot, container)
- Description: Handles putting all of active item into a slot.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
TakeActiveItemFromHalfOfSlot(player, slot, container)
- Description: Handles taking half of item from slot to active.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
TakeActiveItemFromCountOfSlot(player, slot, container, count)
- Description: Handles taking specific count of item from slot to active.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entitycount-- number, item count
- Returns: nil
- Error states: Returns early if validation fails
TakeActiveItemFromAllOfSlot(player, slot, container)
- Description: Handles taking all items from slot to active.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
AddOneOfActiveItemToSlot(player, slot, container)
- Description: Handles adding one of active item to slot.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
AddAllOfActiveItemToSlot(player, slot, container)
- Description: Handles adding all of active item to slot.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
SwapActiveItemWithSlot(player, slot, container)
- Description: Handles swapping active item with slot contents.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
SwapOneOfActiveItemWithSlot(player, slot, container)
- Description: Handles swapping one of active item with slot contents. Note: Only works when container is provided; direct inventory swap (container=nil) is not implemented.
- Parameters:
player-- Entity, the playerslot-- number, slot indexcontainer-- Entity (Optional), container entity
- Returns: nil
- Error states: Returns early if validation fails
UseItemFromInvTile(player, action, item, controlmods, mod_name)
- Description: Handles using an item from inventory tile.
- Parameters:
player-- Entity, the playeraction-- number, action typeitem-- Entity, item entitycontrolmods-- number (Optional), control modifiersmod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
ControllerUseItemOnItemFromInvTile(player, action, item, active_item, mod_name)
- Description: Handles controller use item on item from inventory tile.
- Parameters:
player-- Entity, the playeraction-- number, action typeitem-- Entity, target itemactive_item-- Entity, active itemmod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
ControllerUseItemOnSelfFromInvTile(player, action, item, mod_name)
- Description: Handles controller use item on self from inventory tile.
- Parameters:
player-- Entity, the playeraction-- number, action typeitem-- Entity, item entitymod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
ControllerUseItemOnSceneFromInvTile(player, action, item, target, mod_name)
- Description: Handles controller use item on scene from inventory tile.
- Parameters:
player-- Entity, the playeraction-- number, action typeitem-- Entity, item entitytarget-- Entity (Optional), target entitymod_name-- string (Optional), mod name
- Returns: nil
- Error states: Returns early if validation fails
InspectItemFromInvTile(player, item)
- Description: Handles inspecting an item from inventory tile.
- Parameters:
player-- Entity, the playeritem-- Entity, item entity
- Returns: nil
- Error states: Returns early if item is invalid
DropItemFromInvTile(player, item, single)
- Description: Handles dropping an item from inventory tile.
- Parameters:
player-- Entity, the playeritem-- Entity, item entitysingle-- boolean (Optional), drop single flag
- Returns: nil
- Error states: Returns early if validation fails
CastSpellBookFromInv(player, item, spell_id)
- Description: Handles casting a spell from inventory.
- Parameters:
player-- Entity, the playeritem-- Entity, spellbook itemspell_id-- number, spell ID
- Returns: nil
- Error states: Returns early if validation fails
EquipActiveItem(player)
- Description: Handles equipping the active item.
- Parameters:
player-- Entity, the player
- Returns: nil
- Error states: None
EquipActionItem(player, item)
- Description: Handles equipping an action item.
- Parameters:
player-- Entity, the playeritem-- Entity (Optional), item entity
- Returns: nil
- Error states: Returns early if item is provided but invalid
SwapEquipWithActiveItem(player)
- Description: Swaps the player's equipped item with their active held item via the inventory component.
- Parameters:
player-- Entity: The player entity performing the swap
- Returns: nil
- Error states: Returns early if inventory component is missing
TakeActiveItemFromEquipSlot(player, eslot)
- Description: Takes an active item from a specific equipment slot.
- Parameters:
player-- Entity: The player entityeslot-- Number: The equipment slot ID
- Returns: nil
- Error states: Returns early if eslot is not a number or inventory is missing
MoveInvItemFromAllOfSlot(player, slot, destcontainer)
- Description: Moves all items from a specific inventory slot to a destination container.
- Parameters:
player-- Entity: The player entityslot-- Number: The inventory slot indexdestcontainer-- Entity: The destination container entity
- Returns: nil
- Error states: Returns early if slot or destcontainer validation fails
MoveInvItemFromHalfOfSlot(player, slot, destcontainer)
- Description: Moves half of the items from a specific inventory slot to a destination container.
- Parameters:
player-- Entity: The player entityslot-- Number: The inventory slot indexdestcontainer-- Entity: The destination container entity
- Returns: nil
- Error states: Returns early if slot or destcontainer validation fails
MoveInvItemFromCountOfSlot(player, slot, destcontainer, count)
- Description: Moves a specific count of items from a slot to a destination container.
- Parameters:
player-- Entity: The player entityslot-- Number: The inventory slot indexdestcontainer-- Entity: The destination container entitycount-- Number: The number of items to move
- Returns: nil
- Error states: Returns early if validation fails
MoveItemFromAllOfSlot(player, slot, srccontainer, destcontainer)
- Description: Moves all items from a source container slot to a destination.
- Parameters:
player-- Entity: The player entityslot-- Number: The source container slot indexsrccontainer-- Entity: The source container entitydestcontainer-- Entity: The destination container entity (optional)
- Returns: nil
- Error states: Returns early if validation fails or container is not opened by player
MoveItemFromHalfOfSlot(player, slot, srccontainer, destcontainer)
- Description: Moves half of the items from a source container slot to a destination.
- Parameters:
player-- Entity: The player entityslot-- Number: The source container slot indexsrccontainer-- Entity: The source container entitydestcontainer-- Entity: The destination container entity (optional)
- Returns: nil
- Error states: Returns early if validation fails or container is not opened by player
MoveItemFromCountOfSlot(player, slot, srccontainer, destcontainer, count)
- Description: Moves a specific count of items from a source container slot to a destination.
- Parameters:
player-- Entity: The player entityslot-- Number: The source container slot indexsrccontainer-- Entity: The source container entitydestcontainer-- Entity: The destination container entity (optional)count-- Number: The number of items to move
- Returns: nil
- Error states: Returns early if validation fails or container is not opened by player
MakeRecipeFromMenu(player, recipe, skin_index)
- Description: Crafts a recipe from the menu using the builder component.
- Parameters:
player-- Entity: The player entityrecipe-- Number: The RPC ID of the recipeskin_index-- Number (Optional): Skin index for the product
- Returns: nil
- Error states: Returns early if recipe ID is invalid or builder is missing
SetMovementPredictionEnabled(player, enabled)
- Description: Toggles movement prediction on the player controller.
- Parameters:
player-- Entity: The player entityenabled-- Boolean: Whether to enable movement prediction
- Returns: nil
- Error states: Returns early if enabled is not a boolean
MakeRecipeAtPoint(player, recipe, x, z, rot, skin_index, platform, platform_relative)
- Description: Crafts a recipe at a specific world position.
- Parameters:
player-- Entity: The player entityrecipe-- Number: The RPC ID of the recipex-- Number: X coordinatez-- Number: Z coordinaterot-- Number: Rotation angleskin_index-- Number (Optional): Skin indexplatform-- Entity (Optional): Platform entityplatform_relative-- Boolean: Whether coordinates are relative to platform
- Returns: nil
- Error states: Returns early if parameters are invalid or position is out of range
BufferBuild(player, recipe)
- Description: Buffers a build action for a recipe.
- Parameters:
player-- Entity: The player entityrecipe-- Number: The RPC ID of the recipe
- Returns: nil
- Error states: Returns early if recipe ID is invalid
CannotBuild(player, reason)
- Description: Notifies the player they cannot build via talker component.
- Parameters:
player-- Entity: The player entityreason-- String: The reason string key
- Returns: nil
- Error states: Returns early if reason is not a string
WakeUp(player)
- Description: Wakes the player up from sleeping if conditions are met.
- Parameters:
player-- Entity: The player entity
- Returns: nil
- Error states: None
exitgym(player)
- Description: Exits the gym state by pushing a locomote event.
- Parameters:
player-- Entity: The player entity
- Returns: nil
- Error states: None
SetWriteableText(player, target, text)
- Description: Sets text on a writeable component.
- Parameters:
player-- Entity: The player entitytarget-- Entity: The writeable target entitytext-- String (Optional): Text to write
- Returns: nil
- Error states: Returns early if target is not an entity
ToggleController(player, isattached)
- Description: Toggles the player controller attachment state.
- Parameters:
player-- Entity: The player entityisattached-- Boolean: Whether the controller is attached
- Returns: nil
- Error states: Returns early if isattached is not a boolean
OpenGift(player)
- Description: Opens the next gift via the giftreceiver component.
- Parameters:
player-- Entity: The player entity
- Returns: nil
- Error states: None
ClosePopup(player, popupcode, mod_name, ...)
- Description: Closes a popup dialog. The popup is closed regardless of validation result, but with different arguments depending on validation success.
- Parameters:
player-- Entity: The player entitypopupcode-- Number: The popup code IDmod_name-- String (Optional): Mod name...-- Any: Additional arguments for validation
- Returns: nil
- Error states: Returns early if popup code is invalid; popup is closed even if validation fails
RecievePopupMessage(player, popupcode, mod_name, ...)
- Description: Receives a popup message and sends it to the server.
- Parameters:
player-- Entity: The player entitypopupcode-- Number: The popup code IDmod_name-- String (Optional): Mod name...-- Any: Message arguments
- Returns: nil
- Error states: Returns early if popup code is invalid
RepeatHeldAction(player)
- Description: Repeats the currently held action via player controller.
- Parameters:
player-- Entity: The player entity
- Returns: nil
- Error states: None
ClearActionHold(player)
- Description: Clears the action hold state via player controller.
- Parameters:
player-- Entity: The player entity
- Returns: nil
- Error states: None
GetChatHistory(player, last_message_hash, first_message_hash)
- Description: Requests chat history from the server.
- Parameters:
player-- Entity/UserID: The player or user IDlast_message_hash-- Number: Hash of the last messagefirst_message_hash-- Number (Optional): Hash of the first message
- Returns: nil
- Error states: Returns early if hashes are invalid or history already sent
DoActionOnMap(player, actioncode, x, z, maptarget, mod_name)
- Description: Performs an action on the map at specific coordinates.
- Parameters:
player-- Entity: The player entityactioncode-- Number: The action codex-- Number: X coordinatez-- Number: Z coordinatemaptarget-- Entity (Optional): Map target entitymod_name-- String (Optional): Mod name
- Returns: nil
- Error states: Returns early if parameters are invalid
SetSkillActivatedState(player, skill_rpc_id, isunlocked)
- Description: Sets the activation state of a skill via skilltreeupdater. Note: Deactivation (isunlocked=false) is currently not implemented on server side due to potential desync issues.
- Parameters:
player-- Entity: The player entityskill_rpc_id-- Number: The skill RPC IDisunlocked-- Boolean: Whether the skill is unlocked
- Returns: nil
- Error states: Returns early if ID is invalid or skill does not exist
AddSkillXP(player, amount)
- Description: Adds XP to the player's skill tree.
- Parameters:
player-- Entity: The player entityamount-- Number: The amount of XP to add
- Returns: nil
- Error states: Returns early if amount is not a number
PostActivateHandshake(player, state)
- Description: Handles the post-activation handshake state.
- Parameters:
player-- Entity: The player entitystate-- Number: The handshake state
- Returns: nil
- Error states: Returns early if state is not a uint
OnScrapbookDataTaught(player, inst, response)
- Description: Handles scrapbook data being taught.
- Parameters:
player-- Entity: The player entityinst-- Entity: The scrapbook instanceresponse-- Any: The response data
- Returns: nil
- Error states: Returns early if inst is not an entity
SetClientAuthoritativeSetting(player, variable, value)
- Description: Sets a client-authoritative setting on the player.
- Parameters:
player-- Entity: The player entityvariable-- Any: The setting variablevalue-- Any: The setting value
- Returns: nil
- Error states: None
AOECharging(player, rotation, startflag)
- Description: Handles AOE charging state remotely.
- Parameters:
player-- Entity: The player entityrotation-- Number: The rotation anglestartflag-- Number (Optional): Start flag
- Returns: nil
- Error states: Returns early if rotation is invalid
DoubleTapAction(player, action, x, z, noforce, mod_name, platform, platform_relative)
- Description: Handles a double-tap action at a specific location.
- Parameters:
player-- Entity: The player entityaction-- Number: The action codex-- Number: X coordinatez-- Number: Z coordinatenoforce-- Boolean (Optional): Force flagmod_name-- String (Optional): Mod nameplatform-- Entity (Optional): Platform entityplatform_relative-- Boolean: Whether coordinates are relative
- Returns: nil
- Error states: Returns early if parameters are invalid or out of range
WobyCommand(player, cmd)
- Description: Executes a Woby command if classified data exists.
- Parameters:
player-- Entity: The player entitycmd-- Number: The command ID
- Returns: nil
- Error states: Returns early if cmd is invalid or commands unavailable
InteractionTarget(player, action, target)
- Description: Sets the interaction target remotely.
- Parameters:
player-- Entity: The player entityaction-- Number (Optional): Action codetarget-- Entity (Optional): Target entity
- Returns: nil
- Error states: Returns early if parameters are invalid
PredictGallopTrip(player, x, z, dir, speed, platform, platform_relative)
- Description: Predicts a gallop trip and pushes an event.
- Parameters:
player-- Entity: The player entityx-- Number: X coordinatez-- Number: Z coordinatedir-- Number: Directionspeed-- Number (Optional): Speedplatform-- Entity (Optional): Platform entityplatform_relative-- Boolean: Whether coordinates are relative
- Returns: nil
- Error states: Returns early if parameters are invalid or rotation invalid
ShowPopup(popupcode, mod_name, show, ...)
- Description: Client-side handler to show a popup dialog.
- Parameters:
popupcode-- Number: The popup code IDmod_name-- String (Optional): Mod nameshow-- Boolean: Whether to show the popup...-- Any: Additional arguments
- Returns: nil
- Error states: None
RecievePopupMessage(popupcode, mod_name, ...)
- Description: Client-side handler to receive a popup message.
- Parameters:
popupcode-- Number: The popup code IDmod_name-- String (Optional): Mod name...-- Any: Message arguments
- Returns: nil
- Error states: None
LearnRecipe(product, ...)
- Description: Client-side handler to learn a cookbook recipe.
- Parameters:
product-- String: The product prefab name...-- Any: Ingredient list
- Returns: nil
- Error states: None
LearnFoodStats(product)
- Description: Client-side handler to learn food stats.
- Parameters:
product-- String: The product prefab name
- Returns: nil
- Error states: None
LearnPlantStage(plant, stage)
- Description: Client-side handler to learn a plant stage.
- Parameters:
plant-- String: The plant prefab namestage-- Any: The growth stage
- Returns: nil
- Error states: None
LearnFertilizerStage(fertilizer)
- Description: Client-side handler to learn fertilizer data.
- Parameters:
fertilizer-- String: The fertilizer prefab name
- Returns: nil
- Error states: None
TakeOversizedPicture(plant, weight, beardskin, beardlength)
- Description: Client-side handler to record an oversized crop picture.
- Parameters:
plant-- String: The plant prefab nameweight-- Number: The weight of the cropbeardskin-- Any: Beard skin databeardlength-- Any: Beard length data
- Returns: nil
- Error states: None
RecieveChatHistory(chat_history)
- Description: Client-side handler to receive chat history.
- Parameters:
chat_history-- Table: The chat history data
- Returns: nil
- Error states: None
LearnBuilderRecipe(product)
- Description: Client-side handler to learn a builder recipe via event.
- Parameters:
product-- String: The recipe product name
- Returns: nil
- Error states: None
UpdateAccomplishment(name)
- Description: Client-side handler to update a generic KV accomplishment.
- Parameters:
name-- String: The accomplishment name
- Returns: nil
- Error states: None
UpdateCountAccomplishment(name, maxvalue)
- Description: Client-side handler to increment a count accomplishment.
- Parameters:
name-- String: The accomplishment namemaxvalue-- Number (Optional): Max value cap
- Returns: nil
- Error states: Returns early if maxvalue reached
SetSkillActivatedState(skill_rpc_id, isunlocked)
- Description: Client-side handler to set skill activation state.
- Parameters:
skill_rpc_id-- Number: The skill RPC IDisunlocked-- Boolean: Whether the skill is unlocked
- Returns: nil
- Error states: Returns early if character prefab is nil or skill invalid
AddSkillXP(amount)
- Description: Client-side handler to add skill XP.
- Parameters:
amount-- Number: The amount of XP to add
- Returns: nil
- Error states: None
PostActivateHandshake(state)
- Description: Client-side handler for post-activate handshake.
- Parameters:
state-- Number: The handshake state
- Returns: nil
- Error states: None
TryToTeachScrapbookData(inst)
- Description: Client-side handler to teach scrapbook data.
- Parameters:
inst-- Entity: The scrapbook instance
- Returns: nil
- Error states: None
ShardTransactionSteps(shardid, shardpayload_string)
- Description: Shard-side handler to process transaction steps.
- Parameters:
shardid-- Number/String: The shard IDshardpayload_string-- String: The serialized payload
- Returns: nil
- Error states: None
PruneShardTransactionSteps(shardid, newfinalizedid)
- Description: Shard-side handler to prune transaction steps.
- Parameters:
shardid-- Number/String: The shard IDnewfinalizedid-- Any: The new finalized ID
- Returns: nil
- Error states: None
ReskinWorldMigrator(shardid, migrator, skin_theme, skin_id, sessionid)
- Description: Shard-side handler to reskin a world migrator entity.
- Parameters:
shardid-- Number/String: The shard IDmigrator-- Number: The migrator IDskin_theme-- String: The skin themeskin_id-- Any: The skin IDsessionid-- Any: The session ID
- Returns: nil
- Error states: None
SyncWorldSettings(shardid, options_string)
- Description: Shard-side handler to sync world settings.
- Parameters:
shardid-- Number/String: The shard IDoptions_string-- String: The serialized options
- Returns: nil
- Error states: None
ResyncWorldSettings(shardid)
- Description: Shard-side handler to resync world settings.
- Parameters:
shardid-- Number/String: The shard ID
- Returns: nil
- Error states: None
SyncWorldStateTag(shardid, namespace, tag, enabled)
- Description: Shard-side handler to sync a world state tag.
- Parameters:
shardid-- Number/String: The shard IDnamespace-- String: The tag namespacetag-- String: The tag nameenabled-- Boolean: Whether the tag is enabled
- Returns: nil
- Error states: None
SyncBossDefeated(shardid, bossprefab)
- Description: Shard-side handler to sync boss defeated state.
- Parameters:
shardid-- Number/String: The shard IDbossprefab-- String: The boss prefab name
- Returns: nil
- Error states: None
SyncMermKingExists(shardid, exists)
- Description: Shard-side handler to sync Merm King existence.
- Parameters:
shardid-- Number/String: The shard IDexists-- Boolean: Whether the king exists
- Returns: nil
- Error states: None
SyncMermKingTrident(shardid, exists)
- Description: Shard-side handler to sync Merm King Trident state.
- Parameters:
shardid-- Number/String: The shard IDexists-- Boolean: Whether the trident exists
- Returns: nil
- Error states: None
SyncMermKingCrown(shardid, exists)
- Description: Shard-side handler to sync Merm King Crown state.
- Parameters:
shardid-- Number/String: The shard IDexists-- Boolean: Whether the crown exists
- Returns: nil
- Error states: None
SyncMermKingPauldron(shardid, exists)
- Description: Shard-side handler to sync Merm King Pauldron state.
- Parameters:
shardid-- Number/String: The shard IDexists-- Boolean: Whether the pauldron exists
- Returns: nil
- Error states: None
SendRPCToServer(code, ...)
- Description: Sends an RPC to the server via TheNet.
- Parameters:
code-- Number: The RPC code...-- Any: RPC arguments
- Returns: nil
- Error states: Asserts if RPC code is invalid
SendRPCToClient(code, ...)
- Description: Sends an RPC to clients via TheNet.
- Parameters:
code-- Number: The RPC code...-- Any: RPC arguments including user list
- Returns: nil
- Error states: Asserts if RPC code is invalid
SendRPCToShard(code, ...)
- Description: Sends an RPC to shards via TheNet.
- Parameters:
code-- Number: The RPC code...-- Any: RPC arguments including shard list
- Returns: nil
- Error states: Asserts if RPC code is invalid
HandleRPC(sender, tick, code, data)
- Description: Processes an incoming server-bound RPC with rate limiting.
- Parameters:
sender-- Entity/Table: The sender entity or userid tabletick-- Number: The simulation tickcode-- Number: The RPC codedata-- Table: The RPC data
- Returns: nil
- Error states: Logs error if sender is invalid or code unknown
HandleClientRPC(tick, code, data)
- Description: Processes an incoming client-bound RPC.
- Parameters:
tick-- Number: The simulation tickcode-- Number: The RPC codedata-- Table: The RPC data
- Returns: nil
- Error states: Returns early if ThePlayer is nil
HandleShardRPC(sender, tick, code, data)
- Description: Processes an incoming shard-bound RPC.
- Parameters:
sender-- Any: The sender shard IDtick-- Number: The simulation tickcode-- Number: The RPC codedata-- Table: The RPC data
- Returns: nil
- Error states: Logs error if code is unknown
HandleRPCQueue()
- Description: Processes pending RPC queues for server, client, and shard connections, handling rate limiting and timeline validation before invoking RPCs via TheNet.
- Parameters: None
- Returns: nil
- Error states: None
TickRPCQueue()
- Description: Resets RPC timeline tables to prepare for the next simulation tick.
- Parameters: None
- Returns: nil
- Error states: None
__index_lower(t, k)
- Description: Metatable __index function that performs case-insensitive key lookup by lowercasing the key.
- Parameters:
t-- table: The table being accessedk-- string: The key being looked up
- Returns: value: The value associated with the lowercased key
- Error states: None
__newindex_lower(t, k, v)
- Description: Metatable __newindex function that stores values using a lowercased key.
- Parameters:
t-- table: The table being modifiedk-- string: The key being setv-- any: The value to assign
- Returns: nil
- Error states: None
setmetadata(tab)
- Description: Assigns a metatable to a table enabling case-insensitive key access.
- Parameters:
tab-- table: The table to assign the case-insensitive metatable
- Returns: nil
- Error states: None
AddModRPCHandler(namespace, name, fn)
- Description: Registers a new mod RPC handler for server-side processing, updating rate limits.
- Parameters:
namespace-- string: The namespace for the mod RPCname-- string: The unique name of the RPC within the namespacefn-- function: The handler function to execute when the RPC is received
- Returns: nil
- Error states: None
AddClientModRPCHandler(namespace, name, fn)
- Description: Registers a new mod RPC handler for client-side processing.
- Parameters:
namespace-- string: The namespace for the client mod RPCname-- string: The unique name of the RPCfn-- function: The handler function to execute on the client
- Returns: nil
- Error states: None
AddShardModRPCHandler(namespace, name, fn)
- Description: Registers a new mod RPC handler for shard-side processing.
- Parameters:
namespace-- string: The namespace for the shard mod RPCname-- string: The unique name of the RPCfn-- function: The handler function to execute on the shard
- Returns: nil
- Error states: None
SendModRPCToServer(id_table, ...)
- Description: Sends a mod RPC to the server after validating the handler exists.
- Parameters:
id_table-- table: The RPC ID table containing namespace and id...-- varargs: Data arguments to pass to the RPC
- Returns: nil
- Error states: Asserts if the ID table or handler is invalid
SendModRPCToClient(id_table, ...)
- Description: Sends a mod RPC to a client after validating the handler exists.
- Parameters:
id_table-- table: The RPC ID table containing namespace and id...-- varargs: Data arguments to pass to the RPC
- Returns: nil
- Error states: Asserts if the ID table or handler is invalid
SendModRPCToShard(id_table, ...)
- Description: Sends a mod RPC to a shard after validating the handler exists.
- Parameters:
id_table-- table: The RPC ID table containing namespace and id...-- varargs: Data arguments to pass to the RPC
- Returns: nil
- Error states: Asserts if the ID table or handler is invalid
HandleModRPC(sender, tick, namespace, code, data)
- Description: Processes incoming mod RPCs from clients, enforcing rate limits and user ID validation.
- Parameters:
sender-- Entity or UserID: The sender of the RPCtick-- number: The simulation tick the RPC was sentnamespace-- string: The RPC namespacecode-- number: The RPC handler code IDdata-- table: The data payload
- Returns: nil
- Error states: Prints error if namespace, code, or sender is invalid
HandleClientModRPC(tick, namespace, code, data)
- Description: Processes incoming client mod RPCs queued for local execution.
- Parameters:
tick-- number: The simulation tick the RPC was sentnamespace-- string: The RPC namespacecode-- number: The RPC handler code IDdata-- table: The data payload
- Returns: nil
- Error states: Prints error if namespace or code is invalid
HandleShardModRPC(sender, tick, namespace, code, data)
- Description: Processes incoming shard mod RPCs queued for execution.
- Parameters:
sender-- Entity or ShardID: The sender of the RPCtick-- number: The simulation tick the RPC was sentnamespace-- string: The RPC namespacecode-- number: The RPC handler code IDdata-- table: The data payload
- Returns: nil
- Error states: Prints error if namespace or code is invalid
GetModRPCHandler(namespace, name)
- Description: Retrieves the registered handler function for a mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: function: The handler function
- Error states: None
GetClientModRPCHandler(namespace, name)
- Description: Retrieves the registered handler function for a client mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: function: The handler function
- Error states: None
GetShardModRPCHandler(namespace, name)
- Description: Retrieves the registered handler function for a shard mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: function: The handler function
- Error states: None
GetModRPC(namespace, name)
- Description: Retrieves the RPC table entry for a mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: table: The RPC entry
- Error states: None
GetClientModRPC(namespace, name)
- Description: Retrieves the RPC table entry for a client mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: table: The RPC entry
- Error states: None
GetShardModRPC(namespace, name)
- Description: Retrieves the RPC table entry for a shard mod RPC.
- Parameters:
namespace-- string: The RPC namespacename-- string: The RPC name
- Returns: table: The RPC entry
- Error states: None
MarkUserIDRPC(namespace, name)
- Description: Marks an RPC as requiring user ID validation instead of entity validation.
- Parameters:
namespace-- string or nil: The RPC namespacename-- string: The RPC name or namespace if namespace is nil
- Returns: nil
- Error states: None
DisableRPCSending()
- Description: Disables RPC sending functions by replacing them with no-op functions, used during world reset or regeneration.
- Parameters: None
- Returns: nil
- Error states: None
Events & listeners
Events pushed:
invalidrpc-- Pushed when a player sends an invalid RPClocomote-- Pushed in WakeUp and exitgym to resume player movementpredict_gallop_trip-- Pushed in PredictGallopTrip with trip dataLearnBuilderRecipe-- Pushed in CLIENT_RPC_HANDLERS.LearnBuilderRecipe
Events listened to:
- None