Saddle
Based on game build 714014 | Last updated: 2026-03-07
Overview
The saddle.lua file defines several saddle prefabs (basic, war, race, Wathgrithr, and shadow) used for equipping onto beefalo mounts. Each saddle applies modifiers to the mount via the saddler component, manages finite durability via finiteuses, and supports optional features such as planar damage/defense, damage type bonuses/resists, and visual FX (especially for the shadow saddle). The file also implements specialized logic for the shadow saddle, including forge repairability, FX spawning, and colour syncing.
Usage example
local saddle = Prefab("saddle_war")
local inst = saddle.fn()
inst.components.saddler:SetBonusDamage(10)
inst.components.finiteuses:SetUses(50)
inst:PushEvent("equipped", { owner = player })
Dependencies & tags
Components used: saddler, finiteuses, inspectable, inventoryitem, planardamage, planardefense, damagetypebonus, damagetyperesist, colouraddersync, updatelooper, highlightchild.
Tags added: usesdepleted (via finiteuses), broken (shadow saddle), FX, combatmount (some saddles), show_broken_ui (shadow saddle).
Properties
No public properties are initialized directly in this file. Saddle behavior is controlled through the data table passed to MakeSaddle, and individual components expose their state via methods (e.g., inst.components.saddler.bonusdamage).
Main functions
SetupSaddler(inst)
- Description: Attaches and configures the
saddlercomponent with stats derived from the saddle's data table. Also sets discard callbacks and swap details for animations/skins. - Parameters:
inst(Entity) — the saddle instance. - Returns: Nothing.
- Error states: Does nothing if
inst._datais missing or malformed.
ShadowSaddle_Fx_SetOwner(inst, owner)
- Description: Assigns an owner to the shadow saddle FX entity, managing parent-child relationships, FX attachment, colour syncing, and footprint generation logic (for player-only mounts).
- Parameters:
inst(Entity) — the FX entity (saddle_shadow_fx);owner(Entity) — the mounting entity (player or beefalo). - Returns: Nothing.
- Error states: Returns early if
ownerequalsinst._fxowner.
MakeSaddle(name, data)
- Description: Factory function that creates and returns a
Prefabfor a saddle type. Handles common setup (physics, animation, inventory), data caching, component instantiation (saddler,finiteuses, etc.), and post-initialization hooks. - Parameters:
name(string) — prefab name (e.g.,"saddle_basic").data(table) — configuration with keys likebonusdamage,speedmult,uses,floater,extra_tags,commoninit,postinit, etc.
- Returns:
Prefab— a ready-to-spawn saddle prefab.
CreateFxFollowFrame(i)
- Description: Creates a non-networked visual FX entity that follows the saddle attachment symbol on the mount. Includes animation, colour override, and highlight child logic.
- Parameters:
i(number) — frame index (1–3). - Returns:
Entity— the created FX follow entity.
Events & listeners
- Listens to:
equipped— triggersShadowSaddle_OnEquipped(createssaddle_shadow_fx),unequipped— triggersShadowSaddle_OnUnequipped(destroyssaddle_shadow_fx),saddle_shadow_fx.ownerevent— client-side only, triggers FX refresh on owner change,onremove— internal toColourAdder:AttachChild(automatically managed).
- Pushes:
percentusedchange(viafiniteuseson use/depletion),saddle_shadow_fx.ownerevent(networked event for client sync),BuffExpired-style logic viaOnUsedUp(spawns breaking chunks and removes saddle).