Jump to content

Any tips on making mods compatible with each other?


Drof
 Share

Recommended Posts

Hey all,

Just started modding. Messing around with a character mod to learn the ropes of scripting. It's going pretty well!

So I understand that you can completely override files (prefabs, components, etc.) by including them in your mod directory. Would that not cause a conflict with other mods which do the same? If so, is there a straightforward way around it aside from just "find a way to do it that doesn't involve overriding the original file?"

Also, generally any other legacy / compatibility tips would be nice if you have any to spare. 

Link to comment
Share on other sites

EDIT: Too late, but I've realised that this is the Don't Starve subforum, not the Don't Starve Together subforum. So I can't really be sure what I've said below also applies. I hope it's of help to somebody anyway

----------

It's bad modding practice to outright replace files. If you outright replace files, that would cause incompatibilities with mods that also use that file and future official updates that will use that file.

If you want to make changes to existing content without causing incompatibilities, then you should use postinits and other methods:

AddPrefabPostInit

AddPrefabPostInit("prefabname",function(inst)
	inst.example = true
end)

AddPlayerPostInit

AddPlayerPostInit(function(inst)
	inst.example = true
end)

AddComponentPostInit

AddComponentPostInit("componentname",function(self)
	self.example = true
end)

AddClassPostConstruct (for classes that aren't prefabs or components such as widgets, screens, etc)

AddClassPostConstruct("foldername/filename",function(self)
    self.example = true
end)

Editing Functions

local _functionname = functionname or (function() return end)
functionname = function(argument, ...)
	dosomething()
	return _functionname(argument, ...)
end

Require (for some other files that you can't change with AddClassPostConstruct)

local example = GLOBAL.require("example")

local _examplefunctionname = example.functionname or (function() return end)
example.functionname = function(argument, ...)
	dosomething()
	return _examplefunctionname(argument, ...)
end

 

Edited by JohnWatson
  • Like 1
  • Thanks 1
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...