. . . Posted May 15, 2016 Share Posted May 15, 2016 Hello, so I want my character to gain sanity when going under a tree so I did this inst:ListenForEvent("sheltered", function(inst, data) inst.components.talker:Say(GetString(inst, "ANNOUNCE_SHELTERED")) inst.components.sanity:DoDelta(TUNING.SANITY_TINY) The problem's that when she leaves under the tree she gets another sanity boost which I don't want... Is there an "stopsheltered" event ?! Any help's appreciated so much! And thanks for reading ! Link to comment Share on other sites More sharing options...
Aquaterion Posted May 15, 2016 Share Posted May 15, 2016 (edited) your data variable has a true or false. so you can do something like if data then --on enter else --on exit end Edited May 15, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 I did this and it crashed (I probably wrote it wrong didn't I)? if inst:ListenForEvent("sheltered", function(inst, data) then inst.components.sanity:DoDelta(TUNING.SANITY_SMALL) else inst.components.sanity:DoDelta(-TUNING.SANITY_TINY) end Thanks for the help anyways !!! Link to comment Share on other sites More sharing options...
Aquaterion Posted May 15, 2016 Share Posted May 15, 2016 (edited) inst:ListenForEvent("sheltered", function(inst, data) if data then inst.components.sanity:DoDelta(TUNING.SANITY_SMALL) else inst.components.sanity:DoDelta(-TUNING.SANITY_TINY) end end) Should be like this ^ Edited May 15, 2016 by Aquaterion Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 Thank you so much Aquaterion!! It worked and now I can do many things with this new coding you thought me, thanks so much again !!!!! I'm really happy thank you, thank you !!!!!!! Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 I hate to bother you but I have one more question maybe you could help with Aquaterion! With the code you gave I want to make my character "hide" so I did this inst:ListenForEvent("sheltered", function(inst, data) if data then inst.components.temperature.inherentinsulation = 5 * TUNING.INSULATION_SMALL inst.components.temperature.inherentsummerinsulation = 5 * TUNING.INSULATION_SMALL inst:AddTag("hide") else inst.components.temperature.inherentinsulation = -5 * TUNING.INSULATION_SMALL inst.components.temperature.inherentsummerinsulation = -5 * TUNING.INSULATION_SMALL inst:RemoveTag("hide") end end) I got inst:AddTag("hide") from bushhat in hats prefab but it doesn't seem to make my character hide from creatures like the bushhat does, maybe you can help me, please ? If you don't know it's okay and thanks for all your help ! Link to comment Share on other sites More sharing options...
Aquaterion Posted May 15, 2016 Share Posted May 15, 2016 are you trying to hide ur character, or just make him not get aggro from monsters? This should work for aggro: inst:AddTag("notarget") Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 Thank you so much Aquaterion, you're a mod saver! Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 I'm so, so sorry to bother you again Aquaterion but can you maybe please tell me the tag or what I have to do to make it more like hiding because inst:AddTag("notarget") makes my character really over powered because you can just hit something go in a tree and they won't target you ... If there's so such a tag or code to make it more like hiding in the bushhat (or you don't know how) then it's okay . And i'm super sorry I keep asking so many questions, please forgive me and thanks so MUCH!!!!!!!! Link to comment Share on other sites More sharing options...
Aquaterion Posted May 15, 2016 Share Posted May 15, 2016 3 minutes ago, SuperDavid said: I'm so, so sorry to bother you again Aquaterion but can you maybe please tell me the tag or what I have to do to make it more like hiding because inst:AddTag("notarget") makes my character really over powered because you can just hit something go in a tree and they won't target you ... If there's so such a tag or code to make it more like hiding in the bushhat (or you don't know how) then it's okay . And i'm super sorry I keep asking so many questions, please forgive me and thanks so MUCH!!!!!!!! well I think that's more of a problem of how you want it, the bush hat is activatable and makes you unable to move when you use it, your feature requires you to be in a certain place. What you could do is check if your character has enemies targetting him local enemy = FindEntity(inst, 50, function(guy) return guy.components.combat:TargetIs(inst) end)) if enemy == nil then inst:AddTag("notarget") end Link to comment Share on other sites More sharing options...
. . . Posted May 16, 2016 Author Share Posted May 16, 2016 I put it like this and it crashed inst:ListenForEvent("sheltered", function(inst, data) if data then inst.components.temperature.inherentinsulation = 5 * TUNING.INSULATION_SMALL inst.components.temperature.inherentsummerinsulation = 5 * TUNING.INSULATION_SMALL local enemy = FindEntity(inst, 50, function(guy) return guy.components.combat:TargetIs(inst) end)) if enemy == nil then inst:AddTag("notarget") end else i'm so sorry I don't know where to put it . Thank you again for replying back ! Link to comment Share on other sites More sharing options...
Aquaterion Posted May 16, 2016 Share Posted May 16, 2016 5 minutes ago, SuperDavid said: I put it like this and it crashed inst:ListenForEvent("sheltered", function(inst, data) if data then inst.components.temperature.inherentinsulation = 5 * TUNING.INSULATION_SMALL inst.components.temperature.inherentsummerinsulation = 5 * TUNING.INSULATION_SMALL local enemy = FindEntity(inst, 50, function(guy) return guy.components.combat:TargetIs(inst) end)) if enemy == nil then inst:AddTag("notarget") end else i'm so sorry I don't know where to put it . Thank you again for replying back ! remove 1 of the ) at the end TargetIs(inst) end)) to TargetIs(inst) end) I think that should be the issue Link to comment Share on other sites More sharing options...
. . . Posted May 16, 2016 Author Share Posted May 16, 2016 I did this inst:ListenForEvent("sheltered", function(inst, data) if data then local enemy = FindEntity(inst, 50, function(guy) return guy.components.combat:TargetIs(inst) end) if enemy == nil then inst:AddTag("notarget") end And it crashed and said "attempt to index field 'combat' (a nil value)" the moment I go under a tree Link to comment Share on other sites More sharing options...
Aquaterion Posted May 16, 2016 Share Posted May 16, 2016 function(guy) return guy.components.combat ~= nil and guy.components.combat:TargetIs(inst) end) Chane the appropriate part to the above. Sry on phone Link to comment Share on other sites More sharing options...
. . . Posted May 16, 2016 Author Share Posted May 16, 2016 Thank you so, so, so, so, SO MUCH, Aquaterion!!!!!!!!!!!!!! Without your help I could've never done this, I will definitely credit you for helping me with my character's coding when I finish it, again thank you so much for being so patient with me, I appreciate it so, so much !!!!!!!!!! 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