. . . Posted October 30, 2016 Share Posted October 30, 2016 (edited) Hello, I have a question. So, like the title says is there a way to call upon a character's gender? I tried... if v.CHARACTER_GENDERS.MALE then v.components.health:DoDelta(-99999) end But it just crashed the game saying "attempt to index field 'CHARACTER_GENDERS' (a nil value)".. So, if someone knows if this's even possible that would be great ! If it isn't possible that's fine too . Thanks for reading my problem, have a great day/night ! Edited October 30, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/ Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 (edited) Try this: local gender = GetGenderStrings(data.char) --Edit: I made a mistake. if gender == "MALE" then inst.components.health:DoDelta(-9999) end Edited October 30, 2016 by DarkKingBoo Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831073 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 I tried something like this inst:ListenForEvent("onattackother", function(inst, data) local gender = GetGenderStrings(inst.char) if data.target:HasTag("player") and inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) inst.components.sanity:DoDelta(-10) if gender == "MALE" then target.components.health:DoDelta(-9999) end elseif data.target:HasTag("player") and not inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) end end) and it didn't do anything? Maybe I did it wrong? And thanks for helping DarkKingBoo ! Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831074 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 I made a mistake, try data.char instead. Also added a print, check your log to see if it came up as DEFAULT. If not then change MALE to whatever that says (assuming its not nil). inst:ListenForEvent("onattackother", function(inst, data) local gender = GetGenderStrings(data.char) print(gender) --Lets see if it comes up as "DEFAULT". If it did, that means it didn't work! if data.target:HasTag("player") and inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) inst.components.sanity:DoDelta(-10) if gender == "MALE" then target.components.health:DoDelta(-9999) end elseif data.target:HasTag("player") and not inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) end end) Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831075 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 3 minutes ago, DarkKingBoo said: I made a mistake, try data.char instead. Also added a print, check your log to see if it came up as DEFAULT. If not then change MALE to whatever that says (assuming its not nil). inst:ListenForEvent("onattackother", function(inst, data) local gender = GetGenderStrings(data.char) print(gender) --Lets see if it comes up as "DEFAULT". If it did, that means it didn't work! if data.target:HasTag("player") and inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) inst.components.sanity:DoDelta(-10) if gender == "MALE" then target.components.health:DoDelta(-9999) end elseif data.target:HasTag("player") and not inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) end end) In my log it came up as "DEFAULT" so what should I do? Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831080 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 Oh derp, again I can't read. Try data.target or data.other. If those don't work, I'll run some quick tests. Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831083 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 9 minutes ago, DarkKingBoo said: Try data.target or data.other. By that you meant instead of local gender = GetGenderStrings(data.char) I do local gender = GetGenderStrings(data.other) or local gender = GetGenderStrings(data.target) I tried those both right now & they didn't do anything, sorry to bother you so much .. Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831084 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 Thats okay, I did some tests. Its data.prefab. Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831085 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 4 minutes ago, DarkKingBoo said: Thats okay, I did some tests. Its data.prefab. I tried this & it still didn't work ? inst:ListenForEvent("onattackother", function(inst, data) local gender = GetGenderStrings(data.prefab) print(gender) --Lets see if it comes up as "DEFAULT". If it did, that means it didn't work! if data.target:HasTag("player") and inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) inst.components.sanity:DoDelta(-10) if gender == "MALE" then target.components.health:DoDelta(-9999) end elseif data.target:HasTag("player") and not inst.components.sanity:IsSane() then inst.components.talker:Say(GetString(inst, "ANNOUNCE_HITPLAYER")) end end) Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831088 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 What are you hitting? Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831089 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) Wilson with PVP on with my fists Edited October 30, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831091 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 What does the console say? "DEFAULT" or "MALE"? Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831093 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) DEFAULT Wilson has no gender ! lol Edited October 30, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831094 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 Ok so lets do it the same way I tested it. Lets try hitotherfn. I was able to get Wilson's gender through this. --place this somewhere above master_postinit local function onhitother(inst, data) local gender = GetGenderStrings(data.prefab) print(gender) --Lets see if it comes up as "DEFAULT". If it did, that means it didn't work! if gender == "MALE" then data.components.health:DoDelta(-9999) end end --place this somewhere inside master_postinit. inst.components.combat.onhitotherfn = onhitother Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831097 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 2 minutes ago, DarkKingBoo said: Ok so lets do it the same way I tested it. Lets try hitotherfn. I was able to get Wilson's gender through this. This worked !! Thanks so much DarkKingBoo, i'll be sure to credit you for this. Also, can inst.components.combat.onhitotherfn = onhitother be replaced with? inst:ListenForEvent("onattackother", onhitother) Again, thanks so much ! Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831098 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 (edited) No unfortunately, inst.components.combat.onhitotherfn Is what made the difference. Its usually more reliable in terms of reading/affecting the target which inst:ListenForEvent("onattackother", onhitother) Doesn't seem to do it at all. I don't know the exact reason why though. Edit: Also call me Leonardo Coxington, DarkKingBoo is my slave name. Edited October 30, 2016 by DarkKingBoo Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831100 Share on other sites More sharing options...
. . . Posted October 30, 2016 Author Share Posted October 30, 2016 (edited) That's fine, thanks so much for your help DarkKingBoo ! If I can just ask 1 more question is do you maybe know where I could find all the genders? Then I know which genders I can use? EDIT: Okay, Sir Leonardo Coxington ! Edited October 30, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831101 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 Found in Don't Starve Together/data/scripts/constants.lua CHARACTER_GENDERS = { FEMALE = { "willow", "wendy", "wickerbottom", "wathgrithr", }, MALE = { "wilson", "woodie", "waxwell", "wolfgang", "wes", "webber", }, ROBOT = { "wx78", "pyro", }, NEUTRAL = {}, --empty, for modders to add to PLURAL = {}, --empty, for modders to add to } Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831106 Share on other sites More sharing options...
GentlemanFridge Posted October 30, 2016 Share Posted October 30, 2016 Wait, Pyro is still in there? Huh, I thought he got deleted a while back. Link to comment https://forums.kleientertainment.com/forums/topic/71266-solved-how-to-call-upon-characters-gender/#findComment-831142 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