NorthstarLauncher
NorthstarLauncher copied to clipboard
Use Semver in Dependency Constants
If a mod for a dependency constant is loaded, this will create a sqvm constant that's a SQTable holding the dependency's major
, minor
and patch
version as integer. All other subversions are omitted.
If a dependency is not loaded, the constant will be 0
instead.
This does not break compatability with old versions since a table is a truthy value like 1
, as it is now.
This allows modders to compile code for ranges of mod versions.
For example:
#if HAS_UEBERBLICK
// This compiles only if the dependency is loaded. No matter the version of the dependency
#endif
#if HAS_UEBERBLICK && HAS_UEBERBLICK.major == 1
// This compiles ONLY if the dependency version is 1.x.x
#endif
#if HAS_UEBEBLICK && HAS_UEBERBLICK.major == 1 && HAS_UEBERBLICK.minor >= 2 && HAS_UEBERBLICK.minor <= 5
// This compiles only if the dependency's version is between 1.2.x - 1.5.x
#endif
Invalid version numbers are represented as -1
.
-
"1.2.test" major: 1 minor: 2 patch: -1
-
"1." major: 1 minor: -1 patch: -1
-
"heheheha" major: -1 minor: -1 patch: -1
etc.
I assume v1.12.1-rc
would then be:
major: 1 minor: 12 patch: 1
?
v1.12.1-rc would be
mj: -1 mn: 12 pt: -1
since I did not bother writing an semver parser because a) I have never seen a mod with a leading v in the version b) I don't think anyone is playing on release candidates
v1.12.1-rc would be
mj: -1 mn: 12 pt: -1
since I did not bother writing an semver parser because a) I have never seen a mod with a leading v in the version
the leading v
was a force of habit, forgot that it's not in the mods version
b) I don't think anyone is playing on release candidates
sadly cause we really need more playtesters x_x
I could just terminate on a -
, I guess. parsing rc subversion doesn't make sense imo
I could just terminate on a
-
, I guess. parsing rc subversion doesn't make sense imo
Yeah that's fine. Was just wondering whether it would be a -1
or whether the -rcX
is stripped and turned into just the 1
for patch ^^
Ignores now anything after a -
genuinely surprised any kind of table stuff works in #ifs?
Conditions for #if are normal squirrel expressions, they just need to be able to be evaluated at compile time (ie be constant).
Even stuff like this works #if { k = 1 }.k == int(CLIENT)
, even if unnecessary
fuck
This is broken atm actually idk what I did
fixed again.
dep_test.zip
To test: Install both mods in the zip. In the mp lobby, the globals a = 1
, b = 2
and c = 3
should be defined while d = 4
isn't.
Small request:
Make the version available as a string as well :)
Make the version available as a string as well :)
you can now do checks like #if CONSTANT.version == "1.2.3" #elseif CONSTANT.version == "1.2.3-rc1" #endif
It looks like the game crashes when accessing a dependency constant table and then recompiling scripts
@uniboi is this still going to be worked on? Or has the crashing discouraged you?
I think it might just be a refcount issue, I haven't tested any further though. Might try soon:tm:
@uniboi heads-up that there are merge conflicts here ^^
fixed in #685