KXWl1 Posted December 27, 2021 Share Posted December 27, 2021 I have a new problem, that is, changing the skin of pets. Here is the code: if target:HasTag("critter") then local fx = SpawnPrefab("reskin_tool_fx") local fx_info = reskin_fx_info[target.prefab] or {} local scale_override = fx_info.scale or 1 fx.Transform:SetScale(scale_override, scale_override, scale_override) local fx_pos_x, fx_pos_y, fx_pos_z = target.Transform:GetWorldPosition() fx_pos_y = fx_pos_y + (fx_info.offset or 0) fx.Transform:SetPosition(fx_pos_x, fx_pos_y, fx_pos_z) local newcritter = SpawnPrefab(target.prefab) if target.prefab == "critter_lamb" then if target.AnimState.build == "sheepington_build" then newcritter.AnimState:SetBuild("lamb_winter") elseif target.AnimState.build == "lamb_winter" then newcritter.AnimState:SetBuild("sheepington_build") end elseif target.prefab == "critter_puppy" then if target.AnimState.build == "pupington_build" then newcritter.AnimState:SetBuild("puppy_winter") elseif target.AnimState.build == "puppy_winter" then newcritter.AnimState:SetBuild("pupington_build") end elseif target.prefab == "critter_perdling" then if target.AnimState.build == "perdling_winter" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_build") else newcritter.AnimState:SetBuild("perdling_rooster") end elseif target.AnimState.build == "perdling_rooster" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_build") else newcritter.AnimState:SetBuild("perdling_winter") end elseif target.AnimState.build == "perdling_build" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_winter") else newcritter.AnimState:SetBuild("perdling_rooster") end end elseif target.prefab == "critter_kitten" then if target.AnimState.build == "kitten_winter" then newcritter.AnimState:SetBuild("kittington_build") elseif target.AnimState.build == "kittington_build" then newcritter.AnimState:SetBuild("kitten_winter") end elseif target.prefab == "critter_dragonling" then if target.AnimState.build == "dragonling_winter" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_build") else newcritter.AnimState:SetBuild("dragonling_bat") end elseif target.AnimState.build == "dragonling_bat" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_build") else newcritter.AnimState:SetBuild("dragonling_winter") end elseif target.AnimState.build == "dragonling_build" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_winter") else newcritter.AnimState:SetBuild("dragonling_bat") end end elseif target.prefab == "critter_glomling" then if target.AnimState.build == "glomling_winter" then newcritter.AnimState:SetBuild("glomling_build") elseif target.AnimState.build == "glomling_build" then newcritter.AnimState:SetBuild("glomling_winter") end end newcritter.Transform:SetPosition(Vector3(target.Transform:GetWorldPosition()):Get()) if target.components.perishable ~= nil then newcritter.components.perishable:SetPercent(target.components.perishable:GetPercent()) end target:Remove() return true end After entering the game, there is no problem changing the pet's skin, but strangely, I can only change the pet's skin back to the original state, and I can't change the pet's skin of the original state to other skins. Can anyone help me see what's wrong with this code? Link to comment https://forums.kleientertainment.com/forums/topic/136525-again-about-my-clean-sweeper-mod/ Share on other sites More sharing options...
Leonidas IV Posted December 29, 2021 Share Posted December 29, 2021 On 12/26/2021 at 11:34 PM, KXWl1 said: elseif target.AnimState.build == "glomling_build" then newcritter.AnimState:SetBuild("glomling_winter") For example here, have you ever tried to print something to see if it's falling here? Link to comment https://forums.kleientertainment.com/forums/topic/136525-again-about-my-clean-sweeper-mod/#findComment-1529201 Share on other sites More sharing options...
KXWl1 Posted December 29, 2021 Author Share Posted December 29, 2021 41 minutes ago, Leonidas IV said: For example here, have you ever tried to print something to see if it's falling here? oh I will try later. But I want to ask if the "xxx.AnimState.build == xx" exists? 1 Link to comment https://forums.kleientertainment.com/forums/topic/136525-again-about-my-clean-sweeper-mod/#findComment-1529207 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