PanAzej Posted September 4, 2015 Share Posted September 4, 2015 Hello! I'm making a character mod and I'd like to know two things: 1. I want to make hair_hat show only when the hat equipped wants it to be visible (so it doesn't show when we're wearing Garland or Earmuffs). I have this so far:inst.AnimState:Hide("hair_hat")inst:ListenForEvent("unequip", function() inst.AnimState:Hide("hair_hat")end)inst:ListenForEvent("equip", function() if inst.AnimState:Show("hair_hat") then inst.AnimState:Hide("hair_hat") else inst.AnimState:Hide("hair_hat") inst.AnimState:Show("hair")end end)But it doesn't work. I'm not sure what "if" should check for. It could check hat prefab, but isn't there any other solution? (mod would be broken with other modded hats that don't hide hair) 2. How to check if our character is sleeping in a tent/siesta/sleeping bag? I made a character that falls asleep from time to time, and his "sleeping counter" should reset when it takes a nap in a tent, but I'm not sure how to check that.I tried to check if player "IsKnockedOut" or "IsAsleep" but it doesn't seem to work. Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/ Share on other sites More sharing options...
ZupaleX Posted September 4, 2015 Share Posted September 4, 2015 Hello. I don't think that inst.AnimState:Show("hair_hat") return a boolean and if it does I would guess it return true if it succeed to do the job, false otherwise. It is then not a proper check. Secondly, could you give the complete code you are using? Because I suspect that "inst" refers actually to your hat and not to the "owner". If that's the case, then you try to hide the symbol "hair_hat" on the hat itself, for which it doesn't exist. Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669319 Share on other sites More sharing options...
DarkXero Posted September 4, 2015 Share Posted September 4, 2015 local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_hat", "hatbuild", "swap_hat") -- What is the build for the swap_hat symbol? owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") if owner:HasTag("player") then owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAT") end end local function onunequip(inst, owner) owner.AnimState:ClearOverrideSymbol("swap_hat") owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAT") end end inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669384 Share on other sites More sharing options...
PanAzej Posted September 4, 2015 Author Share Posted September 4, 2015 Thanks for the replies! Hello. I don't think that inst.AnimState:Show("hair_hat") return a boolean and if it does I would guess it return true if it succeed to do the job, false otherwise. It is then not a proper check. Secondly, could you give the complete code you are using? Because I suspect that "inst" refers actually to your hat and not to the "owner". If that's the case, then you try to hide the symbol "hair_hat" on the hat itself, for which it doesn't exist. The code is from my character's master_postinit (I'm sorry I didn't specify):local master_postinit = function(inst)--cutinst.AnimState:Hide("hair_hat")inst:ListenForEvent("unequip", function() inst.AnimState:Hide("hair_hat")end)inst:ListenForEvent("equip", function()if inst.AnimState:Show("hair")==true then inst.AnimState:Hide("hair_hat") inst.AnimState:Show("hair") else inst.AnimState:Show("hair_hat") inst.AnimState:Hide("hair")endend) end It seems, that it always returns false, because even when wearing a "flowerhat" it hides "hair" and shows only "hair_hat" layer. What I'm trying to do here, is to force my character's animation to show hair_hat layer only when a hat I'm equipping tells the game to hide "hair" in its code.Flowerhat and earmuffs for example show both hair_hat and hair.I want to check if hat I'm equipping is trying to show hair_hat and hair and then hide hair_hat layer of my character. Is there a way to do that? Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669422 Share on other sites More sharing options...
ZupaleX Posted September 4, 2015 Share Posted September 4, 2015 I am not sure i understand what you want to achieve but take darkxero post and adapt it to your needs (keep the Hide ("hair_hat") only maybe?) Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669477 Share on other sites More sharing options...
DarkXero Posted September 4, 2015 Share Posted September 4, 2015 (edited) @PanAzej, the only hats that do this is the flowerhat, the earmuffshat, and the eyebrellahat.So:local overrideHats = { flowerhat = true, earmuffshat = true, eyebrellahat = true,} inst.AnimState:Hide("hair_hat") inst:ListenForEvent("unequip", function(inst, data) inst.AnimState:Hide("hair_hat") end) inst:ListenForEvent("equip", function(inst, data) if overrideHats[data.item.prefab] then inst.AnimState:Hide("hair_hat") inst.AnimState:Show("hair") else inst.AnimState:Show("hair_hat") inst.AnimState:Hide("hair") end end)Is this it? Edited September 4, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669531 Share on other sites More sharing options...
PanAzej Posted September 5, 2015 Author Share Posted September 5, 2015 @PanAzej, the only hats that do this is the flowerhat, the earmuffshat, and the eyebrellahat.So:local overrideHats = { flowerhat = true, earmuffshat = true, eyebrellahat = true,} inst.AnimState:Hide("hair_hat") inst:ListenForEvent("unequip", function(inst, data) inst.AnimState:Hide("hair_hat") end) inst:ListenForEvent("equip", function(inst, data) if overrideHats[data.item.prefab] then inst.AnimState:Hide("hair_hat") inst.AnimState:Show("hair") else inst.AnimState:Show("hair_hat") inst.AnimState:Hide("hair") end end)Is this it?Thank you very much! I wanted to know if hair_hat layer can be hidden based on what layers hat prefab wants to hide (in case somebody adds a mod with a hat that makes hair layer visible, my character equips it, and it looks bad). But this works too, it's good enough, thanks! Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-669638 Share on other sites More sharing options...
PanAzej Posted September 25, 2015 Author Share Posted September 25, 2015 Hey, I'm back with another problem. I'm making a character who's scared of spiders - I'm trying to make her unequip spiderhat right away and drop it on the ground. The problem is: spiderhat stays equipped in the head slot. Why doesn't "unequip" function remove it after it's finished? I'm probably doing something wrong here... Here's my code from modmain.lua: function SpiderhattulaPostInit(inst) if GLOBAL.TheWorld.ismastersim then inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITYAURA_TINY*0.2 inst.components.sanityaura:GetAura("tula") local oldonequip = inst.components.equippable.onequipfn local oldonunequip = inst.components.equippable.onunequipfn inst.components.equippable.onequipfn = function(inst, owner) local owner = inst.components.inventoryitem.owner if owner and owner.prefab == "tula" then inst.components.equippable:Unequip(owner, EQUIPSLOTS.HEAD) -- Unequip that right away! else oldonequip(inst, owner)end endinst.components.equippable.onunequipfn = function(inst, owner) if inst.components.inventoryitem.owner and inst.components.inventoryitem.owner.prefab == "tula" then owner.sg:GoToState("refuseeat") STRINGS.CHARACTERS.GENERIC.ANNOUNCE_TULAUNEQUIP = "Yuck, it's nasty!" owner.components.talker:Say(GetString(inst, "ANNOUNCE_TULAUNEQUIP")) inst.components.inventoryitem.owner.components.inventory:DropItem(inst, true, true)else oldonunequip(inst, owner)end end endendAddPrefabPostInit("spiderhat", SpiderhattulaPostInit)Please help! Link to comment https://forums.kleientertainment.com/forums/topic/57622-hats-hair-and-sleeping-in-a-tent/#findComment-675857 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now