Preserver
Based on game build 714014 | Last updated: 2026-03-03
Overview
Preserver is a utility component that allows an entity to modify the rate at which items it contains or owns decay due to perish or temperature effects. It does not directly control decay itself, but exposes configurable multipliers used by other systems (e.g., the itemspawner or inventory decay logic). It supports both static and dynamic (function-based) multiplier values via FunctionOrValue.
Usage example
local inst = CreateEntity()
inst:AddComponent("preserver")
inst.components.preserver:SetPerishRateMultiplier(0.5)
inst.components.preserver:SetTemperatureRateMultiplier(2.0)
-- Later, a decay system may call:
local multiplier = inst.components.preserver:GetPerishRateMultiplier(item)
Dependencies & tags
Components used: None identified
Tags: None identified
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
perish_rate_multiplier | number or function | 1 | Multiplier applied to the base perish rate. Can be a constant or a function fn(inst, item) -> number. |
temperature_rate_multiplier | number or function | 1 | Multiplier applied to the base temperature decay rate. Can be a constant or a function fn(inst, item) -> number. |
Main functions
SetPerishRateMultiplier(rate)
- Description: Sets the multiplier used when computing perish decay rate for items associated with the entity. Accepts either a number or a function.
- Parameters:
rate(number or function) — the new multiplier. - Returns: Nothing.
GetPerishRateMultiplier(item)
- Description: Returns the current perish rate multiplier, resolving it if it is a function.
- Parameters:
item(entity) — the item for which the multiplier is being requested (passed to the function ifperish_rate_multiplieris a function). - Returns: number — the resolved multiplier, or
1if resolution returnsnil. - Error states: Returns
1ifFunctionOrValueyieldsnil(e.g., function returnsnil).
SetTemperatureRateMultiplier(rate)
- Description: Sets the multiplier used when computing temperature decay rate for items associated with the entity.
- Parameters:
rate(number or function) — the new multiplier. - Returns: Nothing.
GetTemperatureRateMultiplier(item)
- Description: Returns the current temperature rate multiplier, resolving it if it is a function.
- Parameters:
item(entity) — the item for which the multiplier is being requested (passed to the function iftemperature_rate_multiplieris a function). - Returns: number — the resolved multiplier, or
1if resolution returnsnil. - Error states: Returns
1ifFunctionOrValueyieldsnil.
GetDebugString()
- Description: Returns a human-readable string summarizing the current multiplier configuration, useful for debugging.
- Parameters: None.
- Returns: string — formatted as
"PerishRate: X, TemperatureRate: Y", whereX/Yare either"FN"(function), a numeric string, or"1"ifnil.
Events & listeners
None identified