Goldnugget
Based on game build 714014 | Last updated: 2026-03-05
Overview
goldnugget.lua defines two prefabs: goldnugget and lucky_goldnugget. Both are small, non-living entities that serve as collectible resources in DST, primarily used in crafting and trading. They are equipped with components that enable them to be picked up, stacked, eaten (yielding minimal hunger), and sold for in-game currency. They also feature a persistent ambient sparkle animation triggered periodically and re-triggered on entity wake.
Usage example
-- Spawn a gold nugget in the world
local nugget = SpawnPrefab("goldnugget")
nugget.Transform:SetPosition(x, y, z)
-- Spawn a lucky gold nugget
local lucky = SpawnPrefab("lucky_goldnugget")
lucky.Transform:SetPosition(x, y, z)
Dependencies & tags
Components used: edible, tradable, inspectable, inventoryitem, stackable, bait, snowmandecor.
Tags added: molebait, quakedebris, and conditionally minigameitem (unless YOTP event is active for standard nugget) or NOCLICK/knockbackdelayinteraction during knockback delay.
Lucky variant adds: minigameitem (only during YOTP event).
Properties
No public properties are defined directly in the goldnugget or lucky_goldnugget constructors. Instance properties like scrapbook_overridedata are set on inst, but these are prefab instance metadata rather than component-level properties.
Main functions
Not applicable.
Events & listeners
- Listens to:
knockbackdropped(only on lucky gold nugget) — triggersOnKnockbackDroppedto manage temporary interaction delays (NOCLICK,knockbackdelayinteractiontags) after knockback is processed. - Pushes: None.
Helper functions
shine(inst)
- Description: Initiates a repeating sparkle animation on the item. Plays "sparkle" once, then loops "idle". Recursively schedules itself every 4–9 seconds while the entity is awake.
- Parameters:
inst(Entity) — the gold nugget entity instance. - Returns: Nothing.
- Error states: None; safe to call multiple times.
OnEntityWake(inst)
- Description: Ensures the
shinetask is active if the entity wakes from sleep and no shining task is already scheduled. - Parameters:
inst(Entity). - Returns: Nothing.
- Error states: None.
OnKnockbackDropped(inst, data)
- Description: Handles knockback drop events to apply temporary interaction blocks. Adds
NOCLICKorknockbackdelayinteractiontags with associated delayed removal tasks based ondatafields. - Parameters:
inst(Entity)data(table | nil) — may containdelayinteraction(number) anddelayplayerinteraction(number) in seconds.
- Returns: Nothing.
- Error states: Silently ignores missing or
nildata.
Prefab definitions
goldnugget: Standard gold nugget. Addsstackable,bait, andsnowmandecorcomponents. Gold value not explicitly set in this function (inherits default 0 fromtradableunless elsewhere modified).lucky_goldnugget: Variant withscrapbook_overridedatafor custom scrapbook display. Setstradable.goldvalue = 1. Does not addbaitorsnowmandecor. IncludesKnockbackDroppedevent listener.
Special behaviors
- Shine effect: Non-visual-lighting effect handled via
AnimState; runs periodically only while awake. - Sinking behavior:
inventoryitem:SetSinks(true)ensures items sink in water (viaPhysicscomponent behavior). - Event-sensitive tagging:
goldnuggetgetsminigameitemtag unlessSPECIAL_EVENTS.YOTPis active.lucky_goldnuggetgetsminigameitemonly ifSPECIAL_EVENTS.YOTPis active.
- Hauntable support: Standard variant includes
MakeHauntableLaunchAndSmash, lucky variant onlyMakeHauntableLaunch. - Pristine state: Both prefabs call
entity:SetPristine(), indicating they are unmodified by world generation and safe for replication.