Page MenuHomeFeedback Tracker

Howto easy cooperate between mods?
New, UrgentPublic


When want make interoperability with other mod, for me is best way use preprocessor annotation. Another mod have #define MODNAME and in my mod i am using #ifdef MODNAME....

Preprocessor anntotation can hide code which is not defined when mod is not present.

But this actually not working correct, or we as modders using it wrong way. Sometimes its detect others mod define, sometimes not. Can devs help us howto achieve better interoperability between mods? Nobody want make milions of small mods only for compatibility betweem mod A and mod B. This preprocessor definition will be very useful when works 100%. Not only in .c files but also in .cpp config files.

I think there should be some exception for these defines, to load it first, then all mods will see all definitions from other mods and can easy integrate methods from others mods.

Will be very helpful feature for easy cooperation between mods.


Operating System
Windows 7

Event Timeline

Hunterz created this task.Jun 30 2021, 4:05 PM

The mod load order as well as script module order 3_Game -> 4_World -> 5_Mission can influence which define is present at which time. In my experience defines work as intended if used correctly. Do you have a minimal example setup where it sometimes works and sometimes does not?

For example from yesterday updated of MuchCarKey I cannot detect this mod in my Carcover. But Helkiana using in his mod same method, just create common folder, which is every time loaded. Before yesterday update of his mod all working smooth.

AXEL7 added a subscriber: AXEL7.Jul 14 2021, 11:15 PM

I am test on 1.12 version this with:

  1. Client-server mod breachingcharge with block define
  2. Only server mod with my code and if def

If i am don't add a 'requiredaddon' #ifdef is not worked, but with added 'requiredaddon' as 'breachingcharge' it is worked ;)

Experimenting today and looks like required addons acts as soft depedency, when requied addon is not present server start without complains. When wants see defines from other mod, must add it to required addons and the are these defines recognized in my mod.

Hmm looks like it works this way only on my local server :/

You should have MOD A and MOD B work separately.
Then when someone wants to use MOD A and MOD B, they should be using a different version which is compatible or a optional add-on version.

You cannot insure a load order without a requiredaddons, so that means you would have to have #ifdef written into both mods.
So for example MOD A would have a #IFDEF MOD_B and MOD B would have #IFDEF MOD_A and then compatibility code.

In Carcover

#IFDEF MuchCarKey
// Code to make compatible

in MuchCarKey

#IFDEF Carcover
// code to make comaptibel