I'm afraid you didn't understand the question correctly -- I admit it's phrased in a way that makes it easy to get it wrong.
I was familiar with the basic dependency operators: hard dependency (must be active), optional dependency ("? mod_name" -- mod may or may not be activated), and conflict ("! mod_name" -- having conflicting mods installed together with your own will break stuff). I've also learned about hidden optional dependencies ("(?) mod_name") that are not shown in the mod manager, but provide that mod_name is loaded before your own mod. However, I didn't look for "optional dependencies", but "optional requirements" (a term I used for lack of a better one). What I meant was a hard dependency on one mod from a list of mods or, more generally, using logic operators between dependencies. Could be as easy as "require A and (B or C)", or more complex like "require A and ( (B and not C) or (D and E))". Something like that isn't supported by the game yet, unfortunately.
Interesting, I also use table.insert, and it works although I don't have require("util"). I'd assumed that was more or less a standard class that would always be there. Also, I haven't found any documentation in the modding wiki on these things.Here is a piece of code I have for a chemistry mod. It optionally requires a number of mods that I know add chemistry recipes to the game. It doesn't even ask about particular mods, although you could do that with the api, ask for them by name, instead, this code just trolls the recipes, whatever is available from any mod, and copies the recipes into new recipes that work with my chemistry buildings to make the same things.
Code: Select all
require("util") function add_recipe_to_tech(tech_name,recipe_name) if data.raw["technology"][tech_name] then table.insert(data.raw["technology"][tech_name].effects, { type="unlock-recipe", recipe=recipe_name }) end end
That seemed so wrong! Then I realized that "~=" means "is not equal" instead of "matches string".Code: Select all
if ingredient.type ~= "fluid" then solid_input_count = solid_input_count + 1 end