[SOLVED] Logic branching according to Spaceage or Quality mods

Place to get help with not working mods / modding interface.
User avatar
Fishbus
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

[SOLVED] Logic branching according to Spaceage or Quality mods

Post by Fishbus »

What is the recommended path to logic changing prototype data according to what Wube mods are activated?
What is the function that recognises these mods are active on start up?

For example

if (active mod == space age)
then do this logic
ifelse if (active mod == space age && quality)
do this thing
else
yadda yadda an so on

Cheers
Last edited by Fishbus on Wed Dec 11, 2024 5:32 am, edited 1 time in total.
s6x
Inserter
Inserter
Posts: 32
Joined: Fri Nov 15, 2024 8:22 pm
Contact:

Re: Logic branching according to Spaceage or Quality mods

Post by s6x »

It's a table, called mods.

Code: Select all

if (mods["space-age"]) then
-- space age + quality stuff
elseif (mods["quality"]) then
-- quality without space age
else
-- neither one
end
Quality is required for Space Age so if you detect space-age you can assume that quality is also there.
User avatar
Fishbus
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Re: Logic branching according to Spaceage or Quality mods

Post by Fishbus »

s6x wrote: Tue Dec 10, 2024 9:47 pm It's a table, called mods.

Code: Select all

if (mods["space-age"]) then
-- space age + quality stuff
elseif (mods["quality"]) then
-- quality without space age
else
-- neither one
end
Quality is required for Space Age so if you detect space-age you can assume that quality is also there.
That's exactly the ticket, thank you.

It works but it has an error because it doesn't load the mod before my mod makes changes, so it will come up with an error saying a field I want to change/access is 'nil'.

For posterity; just make sure the info.json had the mod as a dependency so it is loaded before:

Code: Select all

 "dependencies": ["base >= 2.0","(?) quality" ],
That makes it all work.

Cheers!
Post Reply

Return to “Modding help”