Mightygym
Based on game build 714014 | Last updated: 2026-03-03
Overview
Mightygym manages the state, item handling, and animation synchronization for the Mighty Gym structure. It supports loading/unloading heavy items, enabling players with the strongman component to enter, exercise, and exit the gym while synchronizing visual and gameplay effects (e.g., weight art, hunger burn rate, skin swapping). It integrates closely with the inventory, mightiness, strongman, burnable, freezable, sleeper, grogginess, hunger, skinner, symbolswapdata, pumpkincarvable, and talker components.
Usage example
local gym = Prefabs["mighty_gym"]()
gym:AddComponent("mightygym")
-- Load two heavy items into the gym
local item1 = SpawnPrefab("cavein_boulder")
local item2 = SpawnPrefab("moon_altar_glass")
gym.components.mightygym:LoadWeight(item1, 1)
gym.components.mightygym:LoadWeight(item2, 2)
-- Start a workout with a player
gym.components.mightygym:CharacterEnterGym(player)
Dependencies & tags
Components used: inventory, burnable, freezable, sleeper, grogginess, health, hunger, strongman, mightiness, skinner, symbolswapdata, pumpkincarvable, talker, inventoryitem.
Tags added/removed: loaded, hasstrongman, fireimmune, ingym.
Tags checked: burnt, strongman, debuffed, ignoretalking.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | Owner entity (the gym structure). |
strongman | Entity or nil | nil | Player currently using the gym. |
weight | number | 0 | Total calculated weight of loaded items. |
full_drop_slot | number | 1 | Slot used for overflow when inventory is full during LoadWeight. |
skins | table | nil | Clothing data of the strongman during workout. |
monkey_curse | boolean | nil | Monkey curse state of the strongman. |
skin_base_data | table | nil | Skin definitions for the strongman's base prefab. |
Main functions
SetLevelArt(level, target)
- Description: Sets the visual level indicators (
meter_color2) on the gym (and optionally a target, e.g., thestrongman). Shows/hides symbols and applies skin overrides if present. - Parameters:
level(number) — Current weight level used to determine which color symbol to show (meter_color2).target(Entityornil) — Entity to apply art to; defaults toself.inst.
- Returns: Nothing.
- Error states: Does nothing if
targetlacksAnimStateorgym_skin/prefabdata.
CalcWeight()
- Description: Calculates total weight by scanning the gym’s inventory for items tagged
"heavy"and summing theirgymweight(default2). Updatesself.weight. - Parameters: None.
- Returns: number — Total weight value.
- Error states: Does not count items if fewer than 2 heavy items are loaded.
CheckForWeight()
- Description: Scans inventory slots 1 and 2; if occupied by heavy items, calls
SetWeightSymboland adds the"loaded"tag. Skips if gym is"burnt". - Parameters: None.
- Returns: Nothing.
SwapWeight(item, swapitem)
- Description: Swaps an existing item at its current slot for a new
swapitemusingLoadWeight. - Parameters:
item(Entity) — Existing item to remove.swapitem(Entity) — New item to insert.
- Returns: Nothing.
SetWeightSymbol(weight, slot)
- Description: Sets override symbols for the gym and
strongmanbased on the item’ssymbolswapdata. Handles skinned and non-skinned items, and spawns apumpkincarving_swap_fxfor pumpkins. Clears existing FX IDs. - Parameters:
weight(Entity) — Item withsymbolswapdatacomponent.slot(number) — Slot index (1or2) corresponding to"swap_item"or"swap_item2".
- Returns: Nothing.
- Error states: Early return if
weightlackssymbolswapdata. Does nothing ifis_skinneddata is invalid.
LoadWeight(weight, slot)
- Description: Adds
weightto the gym’s inventory (auto-drop if full), updates weight symbols, plays material-specific sound, sets"loaded"tag, and updates visual level art. Ifstrongmanis present, updatesstrongman’s art andinmightygymreplica. - Parameters:
weight(Entity) — Heavy item to load.slot(number ornil) — Desired inventory slot (1or2). If omitted or inventory full, auto-selects slot.
- Returns: Nothing.
UnloadWeight()
- Description: Drops all items from the gym, clears override symbols and FX, resets
full_drop_slot, removes"loaded"tag, updates level art (includingstrongman), and plays"item_removed"sound. - Parameters: None.
- Returns: Nothing.
CanWorkout(doer)
- Description: Validates whether
doer(typically a player) can start a workout. Checks tags, fire state, gym usage, hunger, and item load (requires exactly 2 heavy items). - Parameters:
doer(Entity) — Entity attempting to use the gym.
- Returns:
true— If workout is allowed.false, "ONFIRE"/"SMOULDER"/"FULL"/"HUNGRY"/"NOWEIGHT"/"UNBALANCED"— On failure with reason.
CalculateMightiness(perfect)
- Description: Calculates the mightiness gain rate based on total weight and whether the workout was perfect. Uses
TUNING.GYM_RATE.*constants. - Parameters:
perfect(boolean) —trueif the workout met quality criteria (e.g., perfect form).
- Returns: number — The may amount to apply (e.g.,
TUNING.GYM_RATE.LOW,MED, orHIGH).
SetSkinModeOnGym(doer, skin_mode)
- Description: Applies the appropriate skin variant (e.g.,
normal,winter,monkey) to the gym’s anim state usingSetSkinsOnAnim. - Parameters:
doer(Entity) — Thestrongmanentity.skin_mode(string) — Skin mode (e.g.,"normal","wrestler").
- Returns: Nothing.
StartWorkout(doer)
- Description: Initializes workout state for
doer: setsself.strongman, updates hunger burn rate, caches clothing/skins, applies item skins to the gym, and adds"hasstrongman"tag. - Parameters:
doer(Entity) — Player withstrongmantag andmightinesscomponent.
- Returns: Nothing.
StopWorkout()
- Description: Ends workout: resets gym build, clears
strongman, removes hunger modifier, clears skin data, and removes"hasstrongman"tag. - Parameters: None.
- Returns: Nothing.
InUse()
- Description: Checks if a
strongmanis currently in the gym. - Parameters: None.
- Returns: boolean —
trueifself.strongman ~= nil.
CharacterEnterGym(player)
- Description: Transitions a player into the gym: hides the physical gym, overlays gym art on the player, applies physics/scale overrides, syncs weight art, starts workout, and sets up event listeners for exit conditions.
- Parameters:
player(Entity) — Thestrongmanentering the gym.
- Returns: Nothing.
CharacterExitGym(player)
- Description: Exits the player from the gym: restores the gym, reapplies the gym’s original build/skin, teleports the player, plays
"jumpout"state (or teleports on state-incompatible condition), clears overrides, kills workout sound, resets state, and stops workout. - Parameters:
player(Entity) — Thestrongmanexiting the gym.
- Returns: Nothing.
Events & listeners
- Listens to:
"onremove"(onself.inst) — Callstrytoexitgymto force exit if gym is removed."attacked"(onself.inst) — Callstrytoexitgymon damage to prevent unsafe gym usage."stopworkout"(onplayer) — Callsonstopworkoutto transition gym state to"workout_pst".
- Pushes: None. (Note: Events like
"buff_expired"or"onremove"are handled, not pushed, by this component.)