Nuwbertron

modmain.lua

Jun 16th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.63 KB | Source Code | 0 0
  1. local _G = GLOBAL
  2. local EQUIPSLOTS = _G.EQUIPSLOTS
  3. local items_list = require("equip_list")
  4.  
  5. --[[ Get our Configs ]]
  6. local EQUIP_CONFIGS = {}
  7. local function CategoryConfigs(tbl, data)
  8.     --[[ v is the table that data contains ]]
  9.     for i, v in pairs(data) do
  10.         local prefab = v.prefab
  11.         --[[ Populate our input tbl ]]
  12.         tbl[prefab] = GetModConfigData(prefab)
  13.         if v.fx then
  14.             tbl[v.fx.prefab] = GetModConfigData(v.fx.prefab)
  15.         end
  16.     end
  17. end
  18.  
  19. for i, category in pairs(items_list) do
  20.     CategoryConfigs(EQUIP_CONFIGS, category.data)
  21. end
  22.  
  23. --[[ Hide Helper Functions ]]
  24. local function HideHeadSlot(AnimState)
  25.     AnimState:ClearOverrideSymbol("headbase_hat")
  26.     AnimState:ClearOverrideSymbol("swap_hat")
  27.  
  28.     AnimState:Show("HAIR_NOHAT")
  29.     AnimState:Show("HAIR")
  30.     AnimState:Show("HEAD")
  31. end
  32.  
  33. local function HideBodySlot(AnimState)
  34.     -- idk if this is bad practice but it works?
  35.     AnimState:ClearOverrideSymbol("backpack")
  36.     AnimState:ClearOverrideSymbol("swap_body_tall")
  37.     AnimState:ClearOverrideSymbol("swap_body")
  38. end
  39.  
  40. -- TODO: Determine what exactly `fx` for `alterguardianhat` and `minerhat` contain.
  41. local function HideItemFx(fx)
  42.     -- If `item.fx` is an entity itself, then we can just remove it directly
  43.     if fx.entity and EQUIP_CONFIGS[fx.prefab] then
  44.         fx:Remove()
  45.         return
  46.     elseif fx.entity and not EQUIPSLOTS[fx.prefab] then
  47.         return
  48.     end
  49.  
  50.     -- Otherwise, `item.fx` is a table of entities
  51.     for _, v in pairs(fx) do
  52.         if v.entity and EQUIP_CONFIGS[v.prefab] then
  53.             v:Remove()
  54.         end
  55.     end
  56. end
  57.  
  58. --[[ Hide Main Function ]]
  59. local function Hide(inst)
  60.     local AnimState = inst.AnimState
  61.     local inv = inst.replica.inventory
  62.  
  63.     local head_conf, body_conf
  64.     local headslot = inv:GetEquippedItem(EQUIPSLOTS.HEAD)
  65.     if headslot then
  66.         head_conf = EQUIP_CONFIGS[headslot.prefab]
  67.     end
  68.  
  69.     local bodyslot = inv:GetEquippedItem(EQUIPSLOTS.BODY)
  70.     if bodyslot then
  71.         body_conf = EQUIP_CONFIGS[bodyslot.prefab]
  72.     end
  73.  
  74.     if headslot and head_conf then
  75.         HideHeadSlot(AnimState)
  76.         if headslot.fx then
  77.             HideItemFx(headslot.fx)
  78.         end
  79.     end
  80.     -- evaluate them separately in case both are equipped
  81.     -- this also allows you to use individual configs for headslots and bodyslots
  82.     if bodyslot and body_conf then
  83.         HideBodySlot(AnimState)
  84.         if bodyslot.fx then
  85.             HideItemFx(bodyslot.fx)
  86.         end
  87.     end
  88. end
  89.  
  90. AddPlayerPostInit(function(inst)
  91.     inst:ListenForEvent("equip", Hide)
  92. end)
  93.  
  94. items_list = nil
Tags: Dst Mod
Advertisement
Add Comment
Please, Sign In to add comment