Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _G = GLOBAL
- local EQUIPSLOTS = _G.EQUIPSLOTS
- local items_list = require("equip_list")
- --[[ Get our Configs ]]
- local EQUIP_CONFIGS = {}
- local function CategoryConfigs(tbl, data)
- --[[ v is the table that data contains ]]
- for i, v in pairs(data) do
- local prefab = v.prefab
- --[[ Populate our input tbl ]]
- tbl[prefab] = GetModConfigData(prefab)
- if v.fx then
- tbl[v.fx.prefab] = GetModConfigData(v.fx.prefab)
- end
- end
- end
- for i, category in pairs(items_list) do
- CategoryConfigs(EQUIP_CONFIGS, category.data)
- end
- --[[ Hide Helper Functions ]]
- local function HideHeadSlot(AnimState)
- AnimState:ClearOverrideSymbol("headbase_hat")
- AnimState:ClearOverrideSymbol("swap_hat")
- AnimState:Show("HAIR_NOHAT")
- AnimState:Show("HAIR")
- AnimState:Show("HEAD")
- end
- local function HideBodySlot(AnimState)
- -- idk if this is bad practice but it works?
- AnimState:ClearOverrideSymbol("backpack")
- AnimState:ClearOverrideSymbol("swap_body_tall")
- AnimState:ClearOverrideSymbol("swap_body")
- end
- -- TODO: Determine what exactly `fx` for `alterguardianhat` and `minerhat` contain.
- local function HideItemFx(fx)
- -- If `item.fx` is an entity itself, then we can just remove it directly
- if fx.entity and EQUIP_CONFIGS[fx.prefab] then
- fx:Remove()
- return
- elseif fx.entity and not EQUIPSLOTS[fx.prefab] then
- return
- end
- -- Otherwise, `item.fx` is a table of entities
- for _, v in pairs(fx) do
- if v.entity and EQUIP_CONFIGS[v.prefab] then
- v:Remove()
- end
- end
- end
- --[[ Hide Main Function ]]
- local function Hide(inst)
- local AnimState = inst.AnimState
- local inv = inst.replica.inventory
- local head_conf, body_conf
- local headslot = inv:GetEquippedItem(EQUIPSLOTS.HEAD)
- if headslot then
- head_conf = EQUIP_CONFIGS[headslot.prefab]
- end
- local bodyslot = inv:GetEquippedItem(EQUIPSLOTS.BODY)
- if bodyslot then
- body_conf = EQUIP_CONFIGS[bodyslot.prefab]
- end
- if headslot and head_conf then
- HideHeadSlot(AnimState)
- if headslot.fx then
- HideItemFx(headslot.fx)
- end
- end
- -- evaluate them separately in case both are equipped
- -- this also allows you to use individual configs for headslots and bodyslots
- if bodyslot and body_conf then
- HideBodySlot(AnimState)
- if bodyslot.fx then
- HideItemFx(bodyslot.fx)
- end
- end
- end
- AddPlayerPostInit(function(inst)
- inst:ListenForEvent("equip", Hide)
- end)
- items_list = nil
Advertisement
Add Comment
Please, Sign In to add comment