Writeable Replica
Based on game build 714014 | Last updated: 2026-03-03
Overview
Writeable Replica implements the client-side interface for writing on writeable entities (e.g., signs, journals). It handles the display of the writing UI, text input, and synchronization with the server via RPC calls. It relies on the writeable component on the server (when present) and falls back to direct communication via a classified child entity for networked clients. It is not responsible for the actual logic of writing—only for managing the client experience and relaying data.
Usage example
local inst = CreateEntity()
inst:AddComponent("writeable_replica")
-- Writing UI and text handling occurs automatically when the player interacts
-- via the writeable's interaction UI; this component connects to the server
-- writeable component or classified entity to propagate changes.
Dependencies & tags
Components used: writeable, classified (via self.classified)
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
screen | widget (optional) | nil | Reference to the writeable UI widget, created when writing starts. |
opentask | Task (optional) | nil | Delayed task used to begin writing after classification data is attached. |
classified | Entity (optional) | nil | Child entity holding networked writeable data; created on master or attached from inst.writeable_classified on clients. |
Main functions
AttachClassified(classified)
- Description: Attaches a
classifiedentity to this component. Once attached, it schedules writing to begin after a zero-time delay viaopentask. - Parameters:
classified(Entity) — the classified data container entity. - Returns: Nothing.
DetachClassified()
- Description: Detaches the
classifiedentity, cancels pending tasks, and ends any ongoing writing session. - Parameters: None.
- Returns: Nothing.
BeginWriting(doer)
- Description: Starts the writing interaction. If a server
writeablecomponent exists, it delegates to it. Otherwise (client-only path), it creates a UI screen if the player is the doer. - Parameters:
doer(Entity) — the entity (usually a player) attempting to start writing. - Returns: Nothing.
- Error states: No-op if
doerisnil, or ifdoer.HUDis missing, or if writing is already in progress on thewriteablecomponent.
Write(doer, text)
- Description: Sends the written text to the server. If a
writeablecomponent exists, it delegates to it. Otherwise, it triggers an RPC to set the text on the server. - Parameters:
doer(Entity) — the entity performing the write (must beThePlayerfor the client path).text(string |nil) — the text to write (length checked before sending).
- Returns: Nothing.
- Error states: Writing is rejected if
textexceedsMAX_WRITEABLE_LENGTHordoer ~= ThePlayerin the classified path.
EndWriting()
- Description: Cleans up and closes the writing UI and cancels any pending open tasks. Delegates to
writeablecomponent if present. - Parameters: None.
- Returns: Nothing.
- Error states: No explicit failure; silently handles missing HUD or screen instances.
SetWriter(writer)
- Description: Assigns the target for classified data (e.g., owner or owner entity). Used during construction or target reassignment.
- Parameters:
writer(Entity |nil) — the entity that should receive write access; ifnil, defaults toself.inst. - Returns: Nothing.
- Error states: Asserts if
writeris non-nilwhen nowriteablecomponent is present (i.e., unexpected usage outside construction).
Events & listeners
- Listens to:
onremoveon theclassifiedentity (viaself.ondetachclassified) — triggersDetachClassified()when the classified entity is removed.
- Pushes: None identified.
Notes
- This component runs on clients only; the actual write logic resides in
components/writeable.luaon the master simulation. - It is designed to support both the traditional
writeablecomponent path (server-side authoritative) and a legacy/classified path for networked data propagation. - RPC
RPC.SetWriteableTextis used to transmit text changes from client to server when thewriteablecomponent is absent. - The
OnRemoveEntity()override ensures theclassifiedchild is removed only on the master simulation to prevent duplicate cleanup.