Skip to main content

Craftingmenu Skinselector

Based on game build 714014 | Last updated: 2026-03-08

Overview

SkinSelector is a UI widget responsible for rendering and managing the skin selection interface within the crafting menu. It displays a spinner control to switch between different visual skins for a crafted item, based on owned unlockables and event availability. It integrates with TheInventory to query skin ownership and uses RecipeTile.sSetImageFromRecipe to update the preview image when the selection changes.

Usage example

local SkinSelector = require "widgets/redux/craftingmenu_skinselector"
local selector = SkinSelector(recipe, owner, nil)
selector:SetPosition(x, y)
root:AddChild(selector)
-- Selection can be changed via spinner controls or programmatically:
selector:SelectSkin("my_custom_skin")
if selector:HasSkins() then
-- Use selector:GetItem() to get the currently selected skin item
local selected_skin = selector:GetItem()
end

Dependencies & tags

Components used: None (widget only; uses global systems TheInventory, Profile, TheNet, SKINS_EVENTLOCK, PREFAB_SKINS, HIDE_SKIN_DECORATIONS, DEFAULT_SKIN_COLOR, BROWN, UIFONT, STRINGS.UI.CRAFTING.DEFAULT, VIRTUAL_CONTROL_INV_ACTION_LEFT, VIRTUAL_CONTROL_INV_ACTION_RIGHT, GetSkinName, GetColorForItem, GetSkinInvIconName, IsSpecialEventActive) Tags: None identified

Properties

PropertyTypeDefault ValueDescription
recipetablenilThe recipe being configured (contains product, imagefn, etc.)
ownerentitynilOwner entity (not actively used beyond storage)
skins_listtablenilList of owned skin data (includes item name, timestamp, skin_custom)
skins_optionstablenilList of spinner option structures (text, image, colour, new_indicator)
spinnerSpinnernilMain UI spinner widget
spinner_bgImagenilBackground image behind spinner
line_topImagenilTop horizontal separator line
line_bottomImagenilBottom horizontal separator line
new_tagImagenil"NEW" label shown for newly acquired skins
focus_forwardWidgetself.spinnerForward focus to the spinner for controller navigation
spinner_has_named_skinsbooleanfalseWhether any skins have custom names
onlyskinsbooleanfalseFlag set if only skins (no default) are allowed for this recipe

Main functions

GetItem()

  • Description: Returns the currently selected skin item name, or nil if default or invalid.
  • Parameters: None.
  • Returns: string (skin item prefab name) or nil.
  • Error states: Returns nil when self.onlyskins is false and the selected index is 1 (default).

GetIndexForSkin(skin)

  • Description: Maps a skin item name to its 1-based spinner index.
  • Parameters: skin (string) – the skin prefab name to find.
  • Returns: number – spinner index (offset by 1 unless self.onlyskins is true), or 1 if not found.

SelectSkin(skin_name)

  • Description: Sets the spinner to the index corresponding to the given skin name.
  • Parameters: skin_name (string or nil) – skin prefab name; nil selects the first/default option.
  • Returns: Nothing.

HasSkins()

  • Description: Indicates whether multiple skin options are available for selection.
  • Parameters: None.
  • Returns: booleantrue if more than one option exists in self.skins_options.

GetSkinsList()

  • Description: Queries inventory and PREFAB_SKINS to build a list of currently owned skins for the recipe's product.
  • Parameters: None.
  • Returns: table – list of { type, item, timestamp, skin_custom? } entries for owned skins that meet unlock/event conditions.
  • Error states: May return an empty list if no skins are owned, locked, or unsupported.

GetSkinOptions()

  • Description: Builds the full spinner options list, including default and all unlocked skins.
  • Parameters: None.
  • Returns: table – list of { text, data, colour, image?, new_indicator? } option tables.
  • Error states: May include only the default option if no skins are unlocked or event-locked.

OnControl(control, down)

  • Description: Forwards controller input to the internal spinner.
  • Parameters:
    • control (number) – virtual control ID.
    • down (boolean) – whether the control was pressed.
  • Returns: booleantrue if input was consumed by spinner, else false.

RefreshControllers(controller_mode)

  • Description: Updates spinner controller bindings based on input mode (keyboard/gamepad).
  • Parameters: controller_mode (number) – active controller mode constant.
  • Returns: Nothing.

Events & listeners

  • Listens to: None.
  • Pushes: None.