Bundle
Based on game build 714014 | Last updated: 2026-03-04
Overview
bundle.lua defines a collection of prefabs used for wrapping, storing, and delivering items in the game. It provides two mainPrefab families: bundle (for simple storage wrapping) and gift (which supports animated jiggles and cannot be peeked), plus variant-specific red pouches and seed packets. Each bundle uses the unwrappable component for item containment and release, integrates with stackable, fuel, burnable, and inventoryitem components for durability and UI behavior, and supports master-side initialization with dynamic loot generation. The prefabs are created via factory functions MakeBundle, MakeWrap, and MakeContainer.
Usage example
-- Example: Spawn a gift bundle with variation support and enable jiggles
local inst = SpawnPrefab("gift")
inst:MakeJiggle() -- Enables jiggle animation and unwrap delay logic
inst.components.unwrappable:WrapItems({ "stick", "flint" })
-- Later, unwrap it to release contents
inst.components.unwrappable:Unwrap(player, false)
Dependencies & tags
Components used: bundlemaker, burnable, container, fuel, inventoryitem, inspectable, propagator, stackable, unwrappable, inventoryitemmoisture, builder.
Tags: bundle, unwrappable, canpeek (only when setupdata.peekcontainer is true).
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
jiggle | boolean | nil | Whether the bundle supports animated jiggles when wrapped. |
suffix | string | nil | Current animation suffix (_small, _medium, _large, _onesize, or ..variation). |
variation | number | nil | Random variant index (if variations > 0). |
burnt | boolean | false | Set to true when the bundle is burnt and triggers ash spawn on unwrap. |
pendingunwrap | boolean | nil | Temporary state during delayed unwrap of large bundles. |
Main functions
MakeBundle(name, numsizes, variations, loot, tossloot, setupdata, bank, build, inventoryimage)
- Description: Factory function that returns a
Prefabfor a bundle item (e.g.,bundle,gift,redpouch). Supports multiple sizes, random variations, custom loot tables, and per-variant post-inits. Handles both common (pre-init) and master-specific logic. - Parameters:
name(string) - Prefab base name.
numsizes(number) - Number of distinct sizes (1,2, or3).
variations(number ornil) - Number of visual variants (e.g.,2for red/blue gift wraps).
loot(table ornil) - Static list of prefabs to drop on unwrap.
tossloot(boolean ornil) - Whether loot items are auto-dropped with velocity.
setupdata(table) - Options table; keys may includepeekcontainer(bool),lootfn,common_postinit, andmaster_postinit.
bank,build,inventoryimage(strings) - Optional overrides for anim bank, build, and inventory image name. - Returns: Prefab instance.
MakeWrap(name, containerprefab, tag, cheapfuel)
- Description: Factory function that returns a
Prefabfor a wrapping sheet (e.g.,bundlewrap) used to wrap bundles. Primarily used in crafting recipes. - Parameters:
name(string) - Prefab name (e.g.,"bundle").
containerprefab(string) - Name of the associated bundle container prefab.
tag(string ornil) - Optional tag to add.
cheapfuel(boolean) - Iftrue, sets fuel value toTUNING.TINY_FUEL; otherwiseTUNING.MED_FUEL. - Returns: Prefab instance.
MakeContainer(name, build, tag)
- Description: Factory function that returns a
Prefabfor an invisible container used for bundling or construction. Always placed in the world but does not persist (persists = false). - Parameters:
name(string) - Prefab name (e.g.,"bundle_container").
build(string) - UI animation build name.
tag(string ornil) - Optional tag (e.g.,"repairconstructionsite"). - Returns: Prefab instance.
MakeJiggle(inst)
- Description: Enables jiggle animation support on the bundle instance (e.g., for gifts). Must be called after the bundle is created and before it is wrapped. Attaches
UnwrapDelaytounwrappable, sets event callbacks for animation state, and manages thejiggletask. - Parameters:
inst(Entity) - The bundle instance. - Returns: Nothing.
UpdateInventoryImage(inst)
- Description: Updates the inventory item’s image name based on current size suffix and variation. Called automatically during wrapping and post-load.
- Parameters:
inst(Entity) - The bundle instance. - Returns: Nothing.
UnwrapDelay(inst, doer)
- Description: Returns a delay (in seconds) before the bundle unwrap is performed. Used specifically for large bundles with
variationset to create an animated unwrap delay (e.g., shaking before opening). - Parameters:
inst(Entity) - The bundle instance.
doer(Entity ornil) - The entity unwrapping the bundle. - Returns: Number — delay in seconds, or
nilif no delay. Returns0.5for large bundles with animations.
Events & listeners
- Listens to:
unwrappeditem— fires on loot items when they are spawned from unwrap (viaitem:PushEvent).
wrappeditem— fires on the bundle when items are added viaWrapItems(viainst.components.unwrappable:WrapItems). - Pushes:
unwrapped— fired when the bundle is fully unwrapped (includesdoerin data).
wrapped— fired after wrapping completes (handled byOnWrappedcallback, which plays sound and triggers jiggles).
imagechange— pushed viainventoryitem:ChangeImageName.
ondropped,onownerdropped,unwrappeditem,wrappeditem— propagated to child items or parent inventory.