mt-mods / technic

Technic mod for Minetest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add version information to namespace

S-S-X opened this issue · comments

commented

We should also consider adding some version identifier to the technic namespace, to make it easier for other mods to distinguish between technic versions, something like technic.plus = true.

technic.plus sounds simple and good, this could also include version number. Might be useful to have technic.version too but technic.plus for sure is safer and simpler option if someone else got idea to also add technic.version.

I like the name technic.plus (.version would work for me too). Would prefer a number rather than a boolean there. Something like an international date (20211104 today) would allow easy comparisons in additon to simple checks if existing.

Originally posted by @SwissalpS in #233 (comment)

There's good suggestions, I think at least three people agreed with technic.plus naming.
PR #233 adds technic.plus = true which should be safe value for basic use but might be useful to give bit more information about version.

Every approach has upsides and downsides, important thing is to decide what format to use and why. Version information can be changed later but is not very good idea to do so.
(I've seen some software changing version format / variable names and it makes it really hard to do checks against something like that).

  • Upsides/downsides for using date based version?
  • Upsides/downsides for using actual release version?
  • Some other format?

the date variant can be extended to include time by making it a float. That allows overkill precision: 20211105.030512

Another option would be to use unix timestamp, but that isn't easy for humans to read.

I would lean to to the (major) version number in the technic.version variable and a simple true in the technic.plus variable, dates don't mean much when you want to check for features IMO.

Another possibility would some kind of feature table like the engine itself uses:

* `minetest.features`: Table containing API feature flags

      {
          glasslike_framed = true,  -- 0.4.7
          nodebox_as_selectionbox = true,  -- 0.4.7
          get_all_craft_recipes_works = true,  -- 0.4.7
          -- The transparency channel of textures can optionally be used on
          -- nodes (0.4.7)
          use_texture_alpha = true,
          -- Tree and grass ABMs are no longer done from C++ (0.4.8)
          no_legacy_abms = true,
          -- Texture grouping is possible using parentheses (0.4.11)
          texture_names_parens = true,
          -- Unique Area ID for AreaStore:insert_area (0.4.14)
          -- etc...
}

Checking for compatibility should be as simple as:

if technic.plus and technic.features.has_cnc_mk2 then
 -- something something
end

I would lean to to the (major) version number in the technic.version variable and a simple true in the technic.plus variable, dates don't mean much when you want to check for features IMO.

👍 Also has the benefit of only needing to be updated each release, instead of every commit. Could also include the minor version after the decimal point: technic.version = 1.2

Another possibility would some kind of feature table like the engine itself uses:

Hmm, could be useful for some things, but I can't think of much off the top of my head. Version number and checking for API functions existing is probably enough.