Bufferedmapaction
Based on game build 722832 | Last updated: 2026-04-28
Overview
bufferedmapaction.lua registers a classified prefab entity used for map-based action targeting. The prefab creates a networked entity that attaches to a target entity and synchronizes action requests between client and server. On the client, it listens for action dirty events and triggers playercontroller:PullUpMap() to open the map screen. On the server, it stores the doer reference and handles action setup. The prefab is referenced by its name "bufferedmapaction" and is typically instantiated internally by the action system rather than directly spawned by mods.
Usage example
-- This prefab is typically created internally by the action system.
-- Direct spawn example for debugging:
local inst = SpawnPrefab("bufferedmapaction")
inst.Transform:SetPosition(0, 0, 0)
-- Server-side setup (master only):
if TheWorld.ismastersim and inst.SetupMapAction then
local target = SomeEntity
local action = ACTIONS.EXPLORE
local doer = ThePlayer
inst.SetupMapAction(action, target, doer)
end
-- Client-side action retrieval:
if not TheWorld.ismastersim and inst.GetAction then
local action = inst.GetAction()
end
Dependencies & tags
External dependencies:
ACTIONS_BY_ACTION_CODE-- global table mapping action codes to action definitionsRPC.DoActionOnMap-- RPC handler for canceling map targets on serverThePlayer-- local player entity reference for client-side map triggeringTheWorld-- world entity for mastersim check and network replication
Components used:
playercontroller-- accessed viaplayer.components.playercontroller:PullUpMap()to open map screen
Tags:
CLASSIFIED-- added in fn(); marks entity as hidden from normal entity queries
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
action | net_ushortint | --- | Stores the action code. Dirty event: actiondirty. Synced from server to client. |
assets | table | nil | Assets array passed to Prefab() — empty in this file. |
prefabs | table | nil | Dependent prefabs array — empty in this file. |
Main functions
fn()
- Description: Prefab constructor. Creates the entity, adds transform and network components, declares the
actionnetvar, and assigns function references. Splits initialization based onTheWorld.ismastersim: client receives event listeners and read-only accessors; server receives setup functions and doer validation. Returnsinstfor the prefab system. - Parameters: None
- Returns: entity instance
- Error states: None — runs on every host (client and server) with appropriate branching.
CreateIcon(target, icondata) (local)
- Description: Creates a classified mini-map icon entity parented to the target. Sets the icon image, priority, and display properties (draws over fog of war, no cache). Used when the action dirty event fires on the client to visualize the map target.
- Parameters:
target-- entity to parent the icon toicondata-- table containingicon,selectedicon,priority,selectedpriorityfields
- Returns: created icon entity instance
- Error states: Errors if
targetoricondatais nil (no guard present in source).
OnActionDirty(inst) (local)
- Description: Client-only callback triggered when the
actionnetvar changes. Retrieves the local player, gets the parent target entity, creates a map icon if icondata exists, and callsplayercontroller:PullUpMap()to open the map screen focused on the target. - Parameters:
inst-- bufferedmapaction entity instance - Returns: None
- Error states: Errors if
inst.entity:GetParent()returns nil (no guard before accessing target.bufferedmapaction_icondata).ThePlayerandplayercontrollerare guarded.
OnEntityReplicated(inst) (local)
- Description: Client-only callback when the entity is replicated from server. Sets the parent entity's
bufferedmapactionreference to this instance and registers a listener forcancelmaptargetevents that sends an RPC to the server to cancel the map target. - Parameters:
inst-- bufferedmapaction entity instance - Returns: None
- Error states: None — guards against nil parent before accessing parent.bufferedmapaction.
OnRemoveEntity(inst) (local)
- Description: Cleanup callback when the entity is removed. Clears the parent entity's
bufferedmapactionreference if it points to this instance, preventing dangling references. - Parameters:
inst-- bufferedmapaction entity instance - Returns: None
- Error states: None — guards against nil parent and mismatched reference.
GetAction(inst) (local)
- Description: Returns the action definition from
ACTIONS_BY_ACTION_CODEusing the stored action code value. Used on client to read the current action type. - Parameters:
inst-- bufferedmapaction entity instance - Returns: Action definition table or
nilif action code is invalid. - Error states: None — returns nil if action code is not in
ACTIONS_BY_ACTION_CODEtable (expected behavior, not a crash).
IsDoer_Client(inst, doer) (local)
- Description: Client-side doer validation. Returns true if the provided
doermatchesThePlayer. Used to verify action ownership on the client. - Parameters:
inst-- bufferedmapaction entity instancedoer-- entity to check
- Returns:
trueif doer is the local player,falseotherwise. - Error states: None — handles nil doer gracefully.
IsDoer_Server(inst, doer) (local)
- Description: Server-side doer validation. Returns true if the provided
doermatches the storedinst.doerreference. Used to verify action ownership on the server. - Parameters:
inst-- bufferedmapaction entity instancedoer-- entity to check
- Returns:
trueif doer matches stored doer,falseotherwise. - Error states: None — handles nil doer gracefully.
SetupMapAction(inst, action, target, doer) (local)
- Description: Server-only setup function. Stores the action code in the netvar, sets the parent entity reference, stores the doer, and registers a
cancelmaptargetlistener that removes this entity if the matching doer cancels. CallsOnActionDirtyimmediately if the doer has a HUD (triggers map open on client). - Parameters:
inst-- bufferedmapaction entity instanceaction-- action definition table withcodefieldtarget-- entity to attach the action todoer-- player entity initiating the action
- Returns: None
- Error states: Errors if
action,target, ordoeris nil (no guards present in source). Also errors ondoer.HUDaccess if doer is nil (no guard before this check).
Events & listeners
Listens to:
actiondirty(client only) -- triggersOnActionDirty; fires when theactionnetvar changes value. Opens the map screen for the local player.cancelmaptarget(client and server) -- triggers removal of this entity when the matching doer cancels the map target. Client variant sendsSendRPCToServer(RPC.DoActionOnMap, nil, nil, nil, target)to cancel on server. Server variant removes this entity directly viainst:Remove()when matching doer cancels.
World state watchers: None identified.
Pushes: None identified — this prefab does not fire events on its entity.