Wobycommon
Based on game build 714014 | Last updated: 2026-03-07
Overview
wobycommon.lua is a shared utility module (not a component) that centralizes core logic for Walter's companion creature, Woby. It provides functions to initialize and manage Woby's action wheel (via SpellBook), handle dynamic spell availability based on player skilltree state, enforce container restrictions for courier bags, and generate visual/audio effects for lunar and shadow alignment transformations. This module is included by Woby prefabs and used during their initialization and operation.
Usage example
local wobycommon = require("prefabs/wobycommon")
local inst = CreateEntity()
-- Attach the SpellBook component first
inst:AddComponent("spellbook")
-- Initialize Woby's command wheel
wobycommon.SetupCommandWheel(inst)
-- Later, update available spells when the player's skills change
wobycommon.RefreshCommands(inst, player)
Dependencies & tags
Components used: spellbook, container, rideable, colouradder, playercontroller, focalpoint, skilltreeupdater, stackable
Tags: Uses largecreature, transforming, _container, companion, portablestorage, mermonly, mastercookware, FX, NOCLICK, DECOR, INLIMBO; creates wobybag*, woby_align_fade
Properties
No public properties — this module exposes only functions and constants for reuse.
Main functions
SetupCommandWheel(inst)
- Description: Initializes the
SpellBookcomponent on Woby with configuration for the action wheel, including radius, sounds, and spell item list. Sets up event listeners for skill activation/deactivation to refresh the wheel dynamically (client-side only). - Parameters:
inst(Entity) — The Woby entity instance. - Returns: Nothing.
- Error states: On the client, delays refresh setup until after the current frame due to construction timing issues.
RefreshCommands(inst, player)
- Description: Dynamically populates
inst._spellsbased on whether Woby islargecreatureor small, and which skilltree skills (e.g.,walter_woby_itemfetcher) are activated. Replaces disabled spells withBLANKorSPACERentries. - Parameters:
inst(Entity) — Woby entity; usesinst._spellsas the spell array.
player(Entity) — Player entity used to query skilltree state. - Returns: Nothing.
- Error states: Assumes
inst._spellsexists; does not handle missing player or skilltreeupdater.
MakeWobyCommand(cmd)
- Description: Factory function that returns a closure to execute a named Woby command (e.g.,
"PET","MOUNT"). Plays a negative sound if the command fails. - Parameters:
cmd(string or int) — Command name or its index inCOMMANDS. - Returns: Function — A zero-argument function that invokes
ThePlayer.woby_commands_classified:ExecuteCommand(cmd). - Error states: Returns a function that logs a negative sound on failure; does not guard against nil
ThePlayerorwoby_commands_classified.
DoLunarAlignFx(inst)
- Description: Triggers a 15-frame fade effect for lunar alignment on the rider or Woby itself. Uses
colouradderif present, otherwise falls back toAnimState:SetAddColour. Plays an SFX once at start. - Parameters:
inst(Entity) — Woby entity. - Returns: Nothing.
- Error states: If
rideablecomponent is present, affects the rider; otherwise affectsinst.
DoShadowAlignFx(inst)
- Description: Triggers a 15-frame fade effect for shadow alignment using
AnimState:SetMultColour. Plays an SFX once at start. - Parameters:
inst(Entity) — Woby entity. - Returns: Nothing.
- Error states: Same as
DoLunarAlignFx.
RestrictContainer(inst, restrict)
- Description: Restricts or releases access to Woby's container to only the linked player. Adds/removes a uniquely named tag (e.g.,
"wobybag1234") to the player and uses it as arestrictedtagin the container component. - Parameters:
inst(Entity) — Woby entity with acontainercomponent.
restrict(boolean) — Iftrue, restricts access; iffalse, removes restrictions. - Returns: Nothing.
- Error states: Safely handles nil or invalid
inst._playerlink.
WobyCourier_ForceDelivery(_pet, itemcountmax)
- Description: Moves items from Woby's container to the nearest valid chest at the courier destination. Tries to match stacks by prefab first, then uses any available space.
- Parameters:
_pet(Entity) — Woby entity with acontainer.
itemcountmax(number?, optional) — Maximum items to deliver before returning early. - Returns: Nothing.
- Error states: early return if
itemcountmaxthreshold is reached; relies onTheWorld.Map, container tags, andcanacceptgivenitems.
WobyCourier_FindValidContainerForItem(_pet, item)
- Description: Returns the first valid container at the courier destination that can accept the given item (prefab match or space).
- Parameters:
_pet(Entity) — Woby entity withcourierdata.
item(Entity) — The item to deliver. - Returns: Entity or
nil.
ReskinToolFilterFn(inst)
- Description: Filter function for UI reskin logic. Returns
must_have/must_not_havetag arrays to control whether an item can be skinned with lunar/shadow themes. - Parameters:
inst(Entity) — The item being skinned. - Returns: Two arrays:
must_have(array or nil),must_not_have(array or nil).
Lunar items require"_lunar", shadow require"_shadow", others may not have either.
SetupMouseOver(w)
- Description: Attaches an invisible
Imagehitbox with a raycast radius to a widget (e.g., spell button) to improve mouseover accuracy. - Parameters:
w(Widget) — UI widget (e.g., spell button). - Returns: Nothing.
MakeAutocastToggle(name, noclicksound, overrideanimname)
- Description: Factory that returns a post-init callback for spell widgets that enables autocast styling and sounds.
- Parameters:
name(string) — Autocast toggle ID.
noclicksound(boolean, optional) — Skip sound on toggle.
overrideanimname(string, optional) — Custom animation name. - Returns: Function — Callback to set up ring, animation updates, and sound overrides.
Events & listeners
- Listens to:
onremove— Cleanup listener for source-based colour effects (viacolouradder).onactivateskill_client/ondeactivateskill_client— Refreshes spell wheel when skills change.skilltreeinitialized_client— One-time refresh after skilltree is ready (client-side only).
- Pushes:
None — this module does not fire events directly.