Jump to content

Prefab Loading Question


Recommended Posts

Couple super quick questions.  If you have prefabs in your mods /prefabs/ directory, are they loaded automatically?  I've noticed a couple mods that have empty modmain files but prefabs and they work fine so I'm assuming it loads everything into memory regardless?  If so, does this only happen if modmain is empty? 

Assuming the above, using prefabs that already exist overwrite the old prefabs, right?  (Looking at Animal Variety and it looks like it just overwrites the original prefabs.)

 

Link to comment
Share on other sites

it always replaces files with your mod files, if they are in "same" location and have the same name (same location means a "prefab" folder. At least I think that this is neccesary... but won't hurt ^^)

But overwriting game scripts is usually not a good idea. Your mod won't be compatible, if game devs change the scripts (you have to add those changes manually) and there could be compatibilty issues with other mods.

So better use things like "AddPrefabPostInit" in modmain.
Overwriting things is only a good idea, if you don't want any game update changes or similar. Eg. in my "teleportato" mod, I included the teleportato prefab without editing it direclty (I did it in modmain instead), just to be sure in case game devs changing anything there, it won't break my mod, since teleportato is a special thing (not DST compatible by default)

The other usecase people overwrite prefabs, is when they need to change "local" variables or functions. This is usually not possible with AddPrefabPostInit.  But rezecib already developed a small "hack" for this:
see "getupvalue" "setupvalue" code from DarkXero. Maybe also in the modmain he posted a post later:

 

Edited by Serpens
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...