Primalflower Posted May 25, 2019 Share Posted May 25, 2019 Say i wanted to replace all deciduous trees with, another modded in tree, by the name of "saptree". Would there be an easy way to do this? Link to comment Share on other sites More sharing options...
YakumoYukari Posted May 25, 2019 Share Posted May 25, 2019 I think the easiest way is to change the appearance. SetBuild() on the prefab will change how it looks. AddPrefabPostInit("prefabname", function(inst) inst:SetBuild("buildname") end) According to deciduoustrees.lua, there're 5 types of trees. "deciduoustree_normal", "deciduoustree_tall", "deciduoustree_short", "deciduoustree_burnt, "deciduoustree_stump". So each one you override the build will change their appearance. If changing their appearance is not what you want, you can do something like this. AddPrefabPostInit("prefabname", function(inst) if not GLOBAL.TheWorld.ismastersim then return end GLOBAL.SpawnPrefab("saptree").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end) Spawn an alternative prefab and move to where the original prefab is and remove the original. But if you do this in deciduoustrees, world's regrowth system will consider the original trees have been removed and should be planted. Which may cause the endless spawn of deciduoustrees. I'm not sure though. Maybe you need to tweak the world regrowth system as well in this case. Maybe better ways exist, so don't give up finding a better way. Link to comment Share on other sites More sharing options...
Primalflower Posted June 4, 2019 Author Share Posted June 4, 2019 On 5/25/2019 at 6:32 AM, YakumoYukari said: I think the easiest way is to change the appearance. SetBuild() on the prefab will change how it looks. AddPrefabPostInit("prefabname", function(inst) inst:SetBuild("buildname") end) According to deciduoustrees.lua, there're 5 types of trees. "deciduoustree_normal", "deciduoustree_tall", "deciduoustree_short", "deciduoustree_burnt, "deciduoustree_stump". So each one you override the build will change their appearance. If changing their appearance is not what you want, you can do something like this. AddPrefabPostInit("prefabname", function(inst) if not GLOBAL.TheWorld.ismastersim then return end GLOBAL.SpawnPrefab("saptree").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end) Spawn an alternative prefab and move to where the original prefab is and remove the original. But if you do this in deciduoustrees, world's regrowth system will consider the original trees have been removed and should be planted. Which may cause the endless spawn of deciduoustrees. I'm not sure though. Maybe you need to tweak the world regrowth system as well in this case. Maybe better ways exist, so don't give up finding a better way. when i just did the second one in my modmain, this happened. no deciduous trees (the prefab i was replacing) spawned, nor did saptrees spawn. Am I missing something in the execution of the second on other than just AddPrefabPostInit("deciduoustree", function(inst) if not GLOBAL.TheWorld.ismastersim then return end GLOBAL.SpawnPrefab("saptree").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end) ? Link to comment Share on other sites More sharing options...
. . . Posted June 5, 2019 Share Posted June 5, 2019 Try AddPrefabPostInit("prefabname", function(inst) if not GLOBAL.TheWorld.ismastersim then return end inst:DoTaskInTime(0, function() GLOBAL.SpawnPrefab("saptree").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end) end) 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