Goregonzola Posted July 6, 2020 Share Posted July 6, 2020 (edited) Hey there! I want to give my character the ability to gain Sanity if she's around other players. I was able to achieve the same with some mobs, but I'm not sure how can I do it to players. I'm using this code for the mobs (it's in my modmain.lua): Spoiler local function PositiveSanity(inst, observer) if observer.prefab == "spinel" then return TUNING.SANITYAURA_MED end return 0 end AddPrefabPostInit("butterfly", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = PositiveSanity end) Is there a general codename for players (like "butterfly" above) or is it a lot more complicated than this? Thanks in advance! Edited July 6, 2020 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/119832-is-there-a-general-codename-for-players/ Share on other sites More sharing options...
-LukaS- Posted July 6, 2020 Share Posted July 6, 2020 (edited) Every character has a prefab. The name is the same as the characters, with some exceptions like Maxwell named Waxwell and Wigfrid named Wathgrith. But I think it's better checking for players instead of checking for prefabs. You can do it like this: AddPlayerPostInit(function(inst) -- function for every player local function PositiveSanity(inst, observer) if observer.prefab == "wilson" then -- "wilson" can be any character return TUNING.SANITYAURA_SMALL end return 0 end if inst.components.sanityaura ~= nil then --= checking if the sanityaura component is there inst.components.sanityaura.aurafn = PositiveSanity else inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = PositiveSanity end end) Edited July 6, 2020 by IThatGuyI 2 Link to comment https://forums.kleientertainment.com/forums/topic/119832-is-there-a-general-codename-for-players/#findComment-1351401 Share on other sites More sharing options...
Goregonzola Posted July 7, 2020 Author Share Posted July 7, 2020 Yay, thanks 1 Link to comment https://forums.kleientertainment.com/forums/topic/119832-is-there-a-general-codename-for-players/#findComment-1351693 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