Savedscale
Based on game build 714014 | Last updated: 2026-03-03
Overview
Savedscale is a lightweight component responsible for persisting and restoring an entity's non-default scale values across game sessions. It integrates with the DST save/load system by implementing OnSave and OnLoad callbacks. The component records scale components (x, y, z) only when they differ from the default value of 1, optimizing saved data size by omitting redundant information.
Usage example
local inst = CreateEntity()
inst:AddComponent("savedscale")
-- Scale is automatically saved and loaded with the entity; no manual intervention required.
Dependencies & tags
Components used: None identified
Tags: None identified
Properties
No public properties
Main functions
OnSave()
- Description: Captures the entity's current scale and returns a minimal table of non-default values for saving.
- Parameters: None.
- Returns: A table with keys
x,y, and/orzcontaining scale values that differ from1, ornilif all scales are1. - Error states: If
inst.Transformis missing or inaccessible, behavior is undefined (component assumes valid transform).
OnLoad(data)
- Description: Restores the entity's scale using the saved data table.
- Parameters:
data(table or nil) — a table containing scale values underx,y, andzkeys, ornilif no custom scale was saved. - Returns: Nothing.
- Error states: If
dataisnil, defaults all axes to1. Ifdata.yordata.zare omitted, they default todata.x.
Events & listeners
None identified