yanecc Posted September 7, 2024 Share Posted September 7, 2024 Now there are several specific properties for the character. inst.level = data.level or 0 inst.skillpoints = data.skillpoints or 0 How could I restore them after swapping from Wonkey? I've tried setting inst.SaveForReroll and inst.LoadForReroll in the character prefab, but nothing seemed to be preserved. Link to comment https://forums.kleientertainment.com/forums/topic/159558-helphow-to-keep-some-extra-properties-for-a-mod-character-swapping-from-wonkey/ Share on other sites More sharing options...
Rickzzs Posted September 8, 2024 Share Posted September 8, 2024 Use AddPrefabPostInit, do not add it in prefab.masterfn. 1 Link to comment https://forums.kleientertainment.com/forums/topic/159558-helphow-to-keep-some-extra-properties-for-a-mod-character-swapping-from-wonkey/#findComment-1746545 Share on other sites More sharing options...
LeafyFly Posted September 14, 2024 Share Posted September 14, 2024 If you only want these properties to be saved after swapping from Wonkey, you should put them into a component and add TransferComponent method to it. -- components/extra_properties.lua function ExtraProperties:TransferComponent(newinst) local newcmp = newinst.components.extra_properties if newcmp then newcmp.level = self.level newcmp.skillpoints = self.skillpoints end end -- modmain.lua if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit(YourCharacter, function(inst) inst:AddComponent("extra_properties") end) AddPrefabPostInit("wonkey", function(inst) inst:AddComponent("extra_properties") end) end Link to comment https://forums.kleientertainment.com/forums/topic/159558-helphow-to-keep-some-extra-properties-for-a-mod-character-swapping-from-wonkey/#findComment-1748044 Share on other sites More sharing options...
yanecc Posted September 14, 2024 Author Share Posted September 14, 2024 23 minutes ago, LeafyFly said: If you only want these properties to be saved after swapping from Wonkey, you should put them into a component and add TransferComponent method to it. -- components/extra_properties.lua function ExtraProperties:TransferComponent(newinst) local newcmp = newinst.components.extra_properties if newcmp then newcmp.level = self.level newcmp.skillpoints = self.skillpoints end end -- modmain.lua if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit(YourCharacter, function(inst) inst:AddComponent("extra_properties") end) AddPrefabPostInit("wonkey", function(inst) inst:AddComponent("extra_properties") end) end Oh, I have found it feasible to use SaveForReroll and LoadForReroll to store these variables, as long as they are added through AddPrefabPostInit. The LoadForReroll of other characters has not been changed, so it only works for the transformation process of monkey. Link to comment https://forums.kleientertainment.com/forums/topic/159558-helphow-to-keep-some-extra-properties-for-a-mod-character-swapping-from-wonkey/#findComment-1748051 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