Jump to content

How to make prefabs not destroyable at world gen but not when crafted


Recommended Posts

Hi

I want to make Catcoon Dens created at world generation undestroyable which is already done but how do i make ones which are crafted act as default?

This is the code I use in modmain.lua.  

AddPrefabPostInit("catcoonden", function(inst)

    inst:RemoveComponent("workable")
    inst:RemoveComponent("propagator")
    inst:RemoveComponent("burnable")
    inst:RemoveComponent("hauntable")
end)

Thanks

 

Link to comment
Share on other sites

You can do a check in your AddPrefabPostInit to see whether the world time is higher than 0.1 or something, and differentiate between them like that.

But you'll still run into problems when restarting the server, since you don't save its state about which "type" it is (whether it was generated or crafted). For that, you'd have to set a tag on the ones that are world generated (only do this is AddPrefabPostInit if world time is less than 0.1), and then also extend onsave and onload to save this variable, and set it again on load, and also make the same changes to the appropriate ones as you do in your AddPrefabPostInit.

Edited by Ultroman
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...