Cagealicous Posted October 28, 2019 Share Posted October 28, 2019 Ok, so I'm creating a new character using some code from previous versions of my character. I'm in progress of creating the code for the character and such, but I don't know how to change the character's gender through a line of code. Any ideas on how I can perform this? Link to comment Share on other sites More sharing options...
Jessie_ Posted October 28, 2019 Share Posted October 28, 2019 (edited) table.remove(CHARACTER_GENDERS.FEMALE, "prefabname") table.insert(CHARACTER_GENDERS.MALE, "prefabname") note that this solution doesn't work if you want each instance of one character to have different genders Edited October 28, 2019 by Jessie223 Link to comment Share on other sites More sharing options...
Cagealicous Posted October 28, 2019 Author Share Posted October 28, 2019 5 minutes ago, Jessie223 said: note that this solution doesn't work if you want each instance of one character to have different genders Well, what might you mean by that? As in if I were to change the gender from female to male, I could not do male to female? Link to comment Share on other sites More sharing options...
Jessie_ Posted October 28, 2019 Share Posted October 28, 2019 3 minutes ago, Cagealicous said: Well, what might you mean by that? As in if I were to change the gender from female to male, I could not do male to female? you can change it to and from any gender what i meant was if you use the code above, all instances of your character will have the same new gender Link to comment Share on other sites More sharing options...
Cagealicous Posted October 28, 2019 Author Share Posted October 28, 2019 6 minutes ago, Jessie223 said: you can change it to and from any gender what i meant was if you use the code above, all instances of your character will have the same new gender I think I see what you mean. So, if the character transforms and has the gender change, when they revert back, it will still be the same new one? Link to comment Share on other sites More sharing options...
Jessie_ Posted October 28, 2019 Share Posted October 28, 2019 17 minutes ago, Cagealicous said: I think I see what you mean. So, if the character transforms and has the gender change, when they revert back, it will still be the same new one? no if there are two or more instances of your character, all of them will share the same gender whenever it changes Link to comment Share on other sites More sharing options...
Cagealicous Posted October 28, 2019 Author Share Posted October 28, 2019 1 minute ago, Jessie223 said: no if there are two or more instances of your character, all of them will share the same gender whenever it changes Alright. I'll give it a go when I get the time and I'll reply if I come across any problems. Thanks. Link to comment Share on other sites More sharing options...
Cagealicous Posted October 28, 2019 Author Share Posted October 28, 2019 (edited) 12 hours ago, Jessie223 said: table.remove(CHARACTER_GENDERS.FEMALE, "prefabname") table.insert(CHARACTER_GENDERS.MALE, "prefabname") Well, this did not work. Instead, I rather got an error saying " bad argument #2 to 'remove' " which the way is used it is like so: local function becomeKat(inst) if TheWorld.ismastersim then inst.isKat:set(true) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "ethan_speed_mod", 1.1) inst.components.combat.damagemultiplier = 1.75 inst.components.eater.strongstomach = true inst.components.sanity:SetMax(75) inst.soundsname = "kat" inst:AddTag("monster") STRINGS.CHARACTERS.ETHAN = require "speech_kat" table.remove(CHARACTER_GENDERS.MALE, "ethan") table.insert(CHARACTER_GENDERS.FEMALE, "ethan") if inst.transform_task ~= nil then inst.transform_task:Cancel() inst.transform_task = nil end if not inst:HasTag("playerghost") then inst.components.skinner:SetSkinMode("cursed_skin", "kat") end end if not inst:HasTag("kat") then inst:AddTag("kat") if TheWorld.ismastersim and not inst:HasTag("playerghost") then SpawnPrefab("statue_transition_2").Transform:SetPosition(inst.Transform:GetWorldPosition()) SpawnPrefab("statue_transition").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.sg:PushEvent("powerdown") inst.components.talker:Say(GetString(inst, "ANNOUNCE_BECOME_KAT")) inst.SoundEmitter:PlaySound((inst.talker_path_override or "dontstarve/characters/")..(inst.soundsname or inst.prefab).."/hurt") end end end It is also in a later function that allows the character to revert back to himself. So, anyway I can fix this? Edited October 28, 2019 by Cagealicous Link to comment Share on other sites More sharing options...
KZtyler Posted October 28, 2019 Share Posted October 28, 2019 13 hours ago, Jessie223 said: no if there are two or more instances of your character, all of them will share the same gender whenever it changes I think you could try to explain what an instance means since he is having trouble understanding that. If I understand correctly, what Jessie223 is trying to say is that if you do that, if in your world there are 2 players with that character, both of them will change to male or female when you make the change. If that is okay for you then go ahead with that code. Link to comment Share on other sites More sharing options...
Cagealicous Posted October 28, 2019 Author Share Posted October 28, 2019 4 minutes ago, KZtyler said: I think you could try to explain what an instance means since he is having trouble understanding that. If I understand correctly, what Jessie223 is trying to say is that if you do that, if in your world there are 2 players with that character, both of them will change to male or female when you make the change. If that is okay for you then go ahead with that code. I might just scratch the idea entirely then. It would be just a huge mess doing that since more than one character would be different in that instance. Overall, the character is MALE, so when the character dies, he is still MALE, even if the form is FEMALE. So, I guess I'll just keep the character as MALE. Also, I can't get the code to work anyways. If there is a way for me to make the character have that transition, I will add it. Link to comment Share on other sites More sharing options...
KZtyler Posted October 28, 2019 Share Posted October 28, 2019 17 minutes ago, Cagealicous said: I might just scratch the idea entirely then. It would be just a huge mess doing that since more than one character would be different in that instance. Overall, the character is MALE, so when the character dies, he is still MALE, even if the form is FEMALE. So, I guess I'll just keep the character as MALE. Also, I can't get the code to work anyways. If there is a way for me to make the character have that transition, I will add it. An instance equals to a person playing that character. For example, if we both join a server, and we both pick Wolfgang, there would be 2 instances of Wolfgang. Link to comment Share on other sites More sharing options...
Cagealicous Posted October 29, 2019 Author Share Posted October 29, 2019 5 hours ago, KZtyler said: An instance equals to a person playing that character. For example, if we both join a server, and we both pick Wolfgang, there would be 2 instances of Wolfgang. I understand what you are saying. I'm just saying I won't do it since I want it to be only for that person who is playing the character as in for only one character, not multiples. Although, all instances of the character would change because the transformation is based upon what time of the day it is. So, I don't think it would be a big problem, but what if it were for individuals who were doing a transformation based upon an increment of some component or some other instance. It just would cause too many problems, so I think I'll pass. Also, I can't figure out how to use it. 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