How a mod can support both factorio 0.16 and 0.17

Place to get help with not working mods / modding interface.
NovaM
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Apr 24, 2019 5:11 pm
Contact:

How a mod can support both factorio 0.16 and 0.17

Post by NovaM »

Hello,

I search a way to detect the factorio base version at runtime.
For sample in data.lua

Code: Select all

local factorio_version = "0.16.51" -- HERE: how to get this version string !

local factorio_major_version = factorio_version:sub(1,4)

if factorio_major_version == "0.16" then
    data:extend({
      ...CODE FOR 0.16...
    }
elseif factorio_major_version == "0.17" then
    data:extend({
      ...CODE FOR 0.17...
    }
else
     ...RAISE AN ERROR, NOT COMPATIBLE...
end
My need is how to get the factorio version string at runtime, during the data.lua step ?

Regards,
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How a mod can support both factorio 0.16 and 0.17

Post by DaveMcW »

Code: Select all

local factorio_version = game.active_mods["base"]
NovaM
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Apr 24, 2019 5:11 pm
Contact:

Re: How a mod can support both factorio 0.16 and 0.17

Post by NovaM »

Thanks for your answer even it does not run at the data.lua step.
I read again the doc https://lua-api.factorio.com/latest/Data-Lifecycle.html
I wrote a test mod and get the base version from the mods["base"].

Code: Select all

local factorion_version = mods["base"]
the mods["base"] is available at the steps:
- settings.lua, settings-updates.lua, settings-final-fixes.lua
- data.lua, data-updates.lua, data-final-fixes.lua
but not at the control.lua step.

I don't found the way to get the base version at the control step, but it is not my primary need for now.

Regards,
Post Reply

Return to “Modding help”