fixerhere Posted November 4, 2020 Share Posted November 4, 2020 Ok so i wanted to make my character to have a negative sanity aura and it kinda works? except my character also gets negative sanity which i don't really want Also i wanted that if i wear a garland sanity aura will be equal zero but my character gets negative sanity Here is my sanity aura code inst:DoPeriodicTask(60.0, function(inst) if inst.components.sanity and inst:HasTag("playerghost") then return end local x,y,z = inst.Transform:GetWorldPosition() local players = TheSim:FindEntities(x, y, z, 5, {"player"}, {"playerghost", "INLIMBO"}, nil) for _,v in ipairs(players) do if v.components.sanity then v.components.sanity:DoDelta(-1) end end end) I just started making my character and I'm not really good at LUA coding so sorry if i look dumb Link to comment Share on other sites More sharing options...
Thomas Die Posted November 5, 2020 Share Posted November 5, 2020 13 hours ago, fixerhere said: TheSim:FindEntities(x, y, z, 5, {"player"}, {"playerghost", "INLIMBO"}, nil) Add the players tagg next to playerghost and INLIMBO if you want only the character to not get it ifyou want everyone else to get it do "If v ~= inst then" Then should make it so that if it finds you then it should work 1 1 Link to comment Share on other sites More sharing options...
fixerhere Posted November 5, 2020 Author Share Posted November 5, 2020 Thank you! It works well but do you know how to deactivate the aura when wearing a garland and make it so my character takes negative sanity wearing it? Link to comment Share on other sites More sharing options...
Thomas Die Posted November 5, 2020 Share Posted November 5, 2020 (edited) Garland probably has its own tagg just add another "If inst:HasTagg("insert_garland") then" Edited November 5, 2020 by thomas4846 Oopsie 1 Link to comment Share on other sites More sharing options...
fixerhere Posted November 5, 2020 Author Share Posted November 5, 2020 So i was looking and garland has "flower" tag I tried it to see what happens and nothing :/ can i possibly add myself a tag to a garland and if yes how? Link to comment Share on other sites More sharing options...
Thomas Die Posted November 5, 2020 Share Posted November 5, 2020 Uhh I think it should be a tagg in onequip Also just noticed by why does it happen every 60 sec 1 Link to comment Share on other sites More sharing options...
fixerhere Posted November 5, 2020 Author Share Posted November 5, 2020 I wanted it so it doesn't make a sound every second of sanity dropping so i just made it 60 seconds I will keep looking for the tagg Link to comment Share on other sites More sharing options...
fixerhere Posted November 5, 2020 Author Share Posted November 5, 2020 (edited) Ok i think i found something but i'm not sure if it's right Tagg is called "healingflower" but it's in the hats_lavaarena prefab so it's probably wrong Also i don't know if i'm blind but i don't see garland onequip? Only garland code i saw is this one local function flower_custom_init(inst) inst:AddTag("open_top_hat") inst:AddTag("show_spoilage") end local function flower() local inst = simple(flower_custom_init) inst.components.floater:SetSize("med") inst.components.floater:SetScale(0.68) if not TheWorld.ismastersim then return inst end inst.components.equippable.dapperness = TUNING.DAPPERNESS_TINY inst.components.equippable:SetOnEquip(opentop_onequip) inst:AddComponent("perishable") inst.components.perishable:SetPerishTime(TUNING.PERISH_FAST) inst.components.perishable:StartPerishing() inst.components.perishable:SetOnPerishFn(inst.Remove) MakeHauntableLaunchAndPerish(inst) return inst end Edited November 5, 2020 by fixerhere Link to comment Share on other sites More sharing options...
fixerhere Posted November 6, 2020 Author Share Posted November 6, 2020 Now i made my own hat beacuse i didn't know how to do it with garland so now the hat has a "evilflowerhat" tag so now how can i make it so when i wear it sanity aura is stopped? Link to comment Share on other sites More sharing options...
Thomas Die Posted November 6, 2020 Share Posted November 6, 2020 if inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) == "flowerhat" then --code end Okay sorry for the long ass reply but basically this finds what you're wearing then it works like that cus it's a lot easier then tags sometimes Link to comment Share on other sites More sharing options...
penguin0616 Posted November 7, 2020 Share Posted November 7, 2020 @thomas4846 :GetEquippedItem returns the item, not the item prefab. 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted November 7, 2020 Share Posted November 7, 2020 AHH Kay so like uhm inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD).prefab == "prefab_name" Link to comment Share on other sites More sharing options...
penguin0616 Posted November 7, 2020 Share Posted November 7, 2020 @thomas4846 You also need to check that an item is present before you check for the prefab, or else it will error. *evil laugh* 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted November 7, 2020 Share Posted November 7, 2020 HMMMMMM so local HAT = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) if HAT ~= nil and HAT.prefab == "prefab_name" then --code end THIS WORKS RIGHT? 1 1 Link to comment Share on other sites More sharing options...
penguin0616 Posted November 8, 2020 Share Posted November 8, 2020 @thomas4846 Yep. 1 1 Link to comment 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