Nuwbertron

modinfo.lua - as good as I can get it

Jun 22nd, 2025 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.52 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 ITEM_PREFABS = {}
  7. local FX_PREFABS = {}
  8.  
  9. local function CategoryConfigs(data)
  10.     for _, v in pairs(data) do
  11.         local prefab = v.prefab
  12.         if prefab then
  13.             ITEM_PREFABS[prefab] = GetModConfigData(prefab)
  14.         end
  15.         if v.fx and v.fx.prefab then
  16.             FX_PREFABS[v.fx.prefab] = GetModConfigData(v.fx.prefab)
  17.         end
  18.     end
  19. end
  20.  
  21. for _, category in pairs(items_list) do
  22.     CategoryConfigs(category.data)
  23. end
  24.  
  25. --[[ Hide Helper Functions ]]
  26. local function HideHeadSlot(inst)
  27.     local AnimState = inst.AnimState
  28.     local build = inst:GetSkinBuild() or AnimState:GetBuild()
  29.  
  30.     AnimState:ClearOverrideSymbol("headbase_hat")
  31.     AnimState:ClearOverrideSymbol("swap_hat")
  32.     AnimState:ClearOverrideSymbol("swap_face")
  33.     AnimState:ClearOverrideSymbol("face")
  34.  
  35.     AnimState:Show("HAIR_NOHAT")
  36.     AnimState:Show("HAIR")
  37.     AnimState:Show("HEAD")
  38.    
  39. --You'd think at least one of these would work...
  40.     AnimState:ShowSymbol("face")
  41.  
  42.     AnimState:OverrideSymbol("face", build, "face")
  43.  
  44.     AnimState:SetSymbolMultColour("face", 1, 1, 1, 1)
  45. --None of them work...
  46.  
  47. -- This crashes the game, for some reason.
  48.     --inst:ShowSkin()
  49.  
  50. end
  51.  
  52. local function HideBodySlot(AnimState)
  53.     -- idk if this is bad practice but it works?
  54.     AnimState:ClearOverrideSymbol("backpack")
  55.     AnimState:ClearOverrideSymbol("swap_body_tall")
  56.     AnimState:ClearOverrideSymbol("swap_body")
  57. end
  58.  
  59. -- TODO: Determine what exactly `fx` for `alterguardianhat` and `minerhat` contain.
  60. local function HideItemFx(fx)
  61.     -- If `item.fx` is an entity itself, then we can just remove it directly
  62.     if fx.entity and FX_PREFABS[fx.prefab] then
  63.         fx:Remove()
  64.         return
  65.     elseif fx.entity and not EQUIPSLOTS[fx.prefab] then
  66.         return
  67.     end
  68.  
  69.     -- Otherwise, `item.fx` is a table of entities
  70.     for _, v in pairs(fx) do
  71.         if v.entity and FX_PREFABS[v.prefab] then
  72.             v:Remove()
  73.         end
  74.     end
  75. end
  76.  
  77. --In case FX still sticks (like with 'lunarplanthat_fx' and 'voidclothhat_fx')
  78. local function RemovePlayerFX(inst)
  79.     for _, ent in pairs(_G.Ents) do
  80.         if ent and ent.entity and ent.entity:IsValid() and ent.prefab and FX_PREFABS[ent.prefab] then
  81.             -- Check if it's following the player
  82.             if ent.entity:GetParent() == inst and ent.Remove then
  83.                 ent:Remove()
  84.             end
  85.         end
  86.     end
  87. end
  88.  
  89. --[[ Hide Main Function ]]
  90. local function Hide(inst)
  91.     local AnimState = inst.AnimState
  92.     local inv = inst.replica.inventory
  93.  
  94.     local head_conf, body_conf
  95.     local headslot = inv:GetEquippedItem(EQUIPSLOTS.HEAD)
  96.     if headslot then
  97.         head_conf = ITEM_PREFABS[headslot.prefab]
  98.     end
  99.  
  100.     local bodyslot = inv:GetEquippedItem(EQUIPSLOTS.BODY)
  101.     if bodyslot then
  102.         body_conf = ITEM_PREFABS[bodyslot.prefab]
  103.     end
  104.  
  105.     if headslot and head_conf then
  106.             RemovePlayerFX(inst)
  107.         if headslot.fx then
  108.             HideItemFx(headslot.fx)
  109.         end
  110.         HideHeadSlot(inst)
  111.     end
  112.     -- evaluate them separately in case both are equipped
  113.     -- this also allows you to use individual configs for headslots and bodyslots
  114.     if bodyslot and body_conf then
  115.         HideBodySlot(AnimState)
  116.         if bodyslot.fx then
  117.             HideItemFx(bodyslot.fx)
  118.         end
  119.     end
  120. end
  121.  
  122. AddPlayerPostInit(function(inst)
  123.     inst:ListenForEvent("equip", Hide)
  124. end)
  125.  
  126. items_list = nil
Tags: Dst Mod
Advertisement
Add Comment
Please, Sign In to add comment