Nuwbertron

modmain.lua FX fixed

Jun 18th, 2025
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | Source Code | 0 0
  1. local _G = GLOBAL
  2. local EQUIPSLOTS = _G.EQUIPSLOTS
  3. local items_list = require("equip_list")
  4.  
  5. --[[ Get 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 Visuals ]]
  26. local function HideHeadSlot(anim)
  27.     anim:ClearOverrideSymbol("headbase_hat")
  28.     anim:ClearOverrideSymbol("swap_hat")
  29.     anim:ClearOverrideSymbol("face")
  30.     anim:Show("HAIR_NOHAT")
  31.     anim:Show("HAIR")
  32.     anim:Show("HEAD")
  33.     anim:Show("FACE")
  34. end
  35.  
  36. local function HideBodySlot(anim)
  37.     anim:ClearOverrideSymbol("backpack")
  38.     anim:ClearOverrideSymbol("swap_body_tall")
  39.     anim:ClearOverrideSymbol("swap_body")
  40. end
  41.  
  42. --[[ Safe FX Removal ]]
  43. local function RemovePlayerFX(inst)
  44.     for _, ent in pairs(_G.Ents) do
  45.         if ent and ent.entity and ent.entity:IsValid() and ent.prefab and FX_PREFABS[ent.prefab] then
  46.             -- Check if it's following the player
  47.             if ent.entity:GetParent() == inst and ent.Remove then
  48.                 ent:Remove()
  49.             end
  50.         end
  51.     end
  52. end
  53.  
  54. --[[ Main Hide Function ]]
  55. local function Hide(inst)
  56.     if not inst or not inst.replica or not inst.replica.inventory then return end
  57.     local anim = inst.AnimState
  58.     local inv = inst.replica.inventory
  59.  
  60.     local head = inv:GetEquippedItem(EQUIPSLOTS.HEAD)
  61.     if head and ITEM_PREFABS[head.prefab] then
  62.         HideHeadSlot(anim)
  63.     end
  64.  
  65.     local body = inv:GetEquippedItem(EQUIPSLOTS.BODY)
  66.     if body and ITEM_PREFABS[body.prefab] then
  67.         HideBodySlot(anim)
  68.     end
  69.  
  70.     RemovePlayerFX(inst)
  71. end
  72.  
  73. AddPlayerPostInit(function(inst)
  74.     inst:ListenForEvent("equip", Hide)
  75.     inst:ListenForEvent("unequip", Hide)
  76. end)
  77.  
  78. items_list = nil
Tags: Dst Mod
Advertisement
Add Comment
Please, Sign In to add comment