. . . Posted May 15, 2016 Share Posted May 15, 2016 I really hope somebody can help me with this... So I'm having problems coding with my character... For example I want my character to lose sanity when it hits a butterfly so I wrote this code inst:ListenForEvent("onattackother", function(inst, data) if victim.prefab == "butterfly" then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HIT")) inst.components.sanity:DoDelta(-TUNING.SANITY_HUGE) end) but it just keeps crashing and I have no idea of what to do ... Can someone please enlighten me on what would be the correct way to go about this because I have no idea what's wrong... I'll be so thankful if someone can help me ! And thank you for taking some time to read my problem !! Link to comment Share on other sites More sharing options...
DarkXero Posted May 15, 2016 Share Posted May 15, 2016 16 minutes ago, SuperDavid said: Can someone please enlighten me on what would be the correct way to go about this because I have no idea what's wrong... Wrong syntax. END is missing for the IF. Game crash. Also victim is nil. So victim.prefab crashes the game. The event doesn't event have a victim entry on that data table incoming. inst:ListenForEvent("onattackother", function(inst, data) if data.target.prefab == "butterfly" then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HIT")) inst.components.sanity:DoDelta(-TUNING.SANITY_HUGE) end end) Should be this. You will need a ANNOUNCE_HIT entry on your character's speech or it will read "UNKNOWN STRING". Link to comment Share on other sites More sharing options...
. . . Posted May 15, 2016 Author Share Posted May 15, 2016 Thank you so much DarkXero !!! You really saved me and now I can finally do things the right way, thanks 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