grikey Posted September 27, 2024 Share Posted September 27, 2024 (edited) Hello. First of all, I'm sorry for my bad English. I got help from a translator. My custom character has ability to transform based on the state of the world or sanity. I made the transformation function using SetBuild("animfilename"). The ability worked properly. However, I got into trouble when I added a skin to my character. After the transformation, I use SetBuild ("baseanim") to return to my original appearance, but it returns to the default appearance, not the selected skin. Here is the code I used. local function SanityChange(inst, data, forcesilent) if not inst:HasTag("playerghost") then if inst.components.sanity.current < 40 and not TheWorld.state.isfullmoon then inst.AnimState:SetBuild("first_transform") elseif inst.components.sanity.current > 40 and TheWorld.state.isday then inst.AnimState:SetBuild("baseanim") elseif inst.components.sanity.current > 40 and TheWorld.state.isdusk then inst.AnimState:SetBuild("baseanim") end end end local function Character_States(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "name_speed_mod", 1.2) if not inst:HasTag("playerghost") then if (TheWorld.state.isnight and not TheWorld.state.isfullmoon) then inst.AnimState:SetBuild("second_transform") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "name_speed_mod", 1.3) elseif (TheWorld.state.isnight and TheWorld.state.isfullmoon) then inst.AnimState:SetBuild("third_transform") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "name_speed_mod", 1.5) else inst.AnimState:SetBuild("baseanim") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "name_speed_mod", 1.2) end end end I thought I would need a set process for the skin I selected, so I added the next line. inst.AnimState:SetBuild("baseanim") inst.components.skinner:SetSkinMode("normal_skin", "wilson") It did not work with the following error. [string "scripts/components/skinner.lua"]:419: attempt to concatenate field 'prefab' (a nil value) LUA ERROR stack traceback: scripts/components/skinner.lua:419 in (upvalue) _SetSkinMode (Lua) <411-435> self = skintype = normal_skin clothing = table: 0000000023C03F70 inst = 115159 - (valid:true) skin_name = skintype = normal_skin default_build = wilson base_skin = ../mods/workshop-2812783478/scripts/ms_customslots.lua:134 in (method) SetSkinMode (Lua) <133-136> Need a modification so that character can get the skin of my choice at the end of transformation. If you have any ideas on how to use SetSkinMode or reset characters, please help. Edited September 27, 2024 by grikey text legibility Link to comment https://forums.kleientertainment.com/forums/topic/159985-how-to-use-setskinmode-with-modded-skins-api/ Share on other sites More sharing options...
grikey Posted September 28, 2024 Author Share Posted September 28, 2024 I thought I could solve it by looking at the skinner component. I added the following lines to make the skin work. local skin_name = inst.components.skinner.skin_name if skin_name == "charactername_none" or skin_name == nil then skin_name = "charactername" end And I made SetBuild. inst.AnimState:SetBuild(skin_name) Finally it worked. Link to comment https://forums.kleientertainment.com/forums/topic/159985-how-to-use-setskinmode-with-modded-skins-api/#findComment-1751107 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