check version in script

Started by Monsieur OUXX, Fri 25/11/2016 12:43:58

Previous topic - Next topic

Monsieur OUXX

I've been reading this and this and I can't sort out what's real, what's a suggestion, and from what version it applies.

I've tried this script in both 3.3.4 and 3.4.0.6 and both display only "FLAGS:"

Code: ags
    String result="FLAGS:";
    //I think API_VERSION does not exist -- testing just in case
    #ifdef API_VERSION >= 3.4.0
    result=String.Format("%s 1", result);
    #endif
     
    #ifdef API_VERSION < 2.7.2
    result=String.Format("%s 2", result);
    #endif
    
    #ifdef API_VERSION < 3.4
    result=String.Format("%s 3", result);
    #endif
    


    //At least one of those should work??? At least in 3.4.0.6 ???
    #ifdef SCRIPT_API_v330
    result=String.Format("%s 4", result);
    #endif
     
    #ifdef SCRIPT_API_v334
    result=String.Format("%s 5", result);
    #endif
    
    #ifdef SCRIPT_API_v340
    result=String.Format("%s 6", result);
    #endif
    
    #ifdef SCRIPT_API_v3406
    result=String.Format("%s 7", result);
    #endif

    Display( result);


How should I proceed to test the current version?
 

Crimson Wizard

#1
First of all...

Quote from: Monsieur OUXX on Fri 25/11/2016 12:43:58
I've been reading this and this and I can't sort out what's real, what's a suggestion, and from what version it applies.
I have a one big advice for you, and anyone else: read Changes.txt in your AGS installation! Every our release comes with full changes history, which spans back to first version ever made by CJ. Usually you can find at least basic reference to what was included (sometimes with short explanation).
Also I include changelog for new version when it is released in the corresponding posts in this forum:
http://www.adventuregamestudio.co.uk/forums/index.php?board=28.0
Also, for every big version I add "Upgrading to XXX" article to the manual which comes with AGS, mentioning most notable additions.


Quote from: Monsieur OUXX on Fri 25/11/2016 12:43:58
I've tried this script in both 3.3.4 and 3.4.0.6 ...
3.4.0.6 is a very old Alpha release of 3.4.0. It was made 28th of July 2015, which is more than a year ago! (3.3.4 was just an update to 3.3.0, it does not have much new stuff anyway).
Latest version is 3.4.0.13, titled "AGS 3.4.0 - Patch 1", I strongly recommend to use it instead.

The new SCRIPT_API_*** macros were implemented just before the final release of 3.4.0, they are not included into 3.4.0.6.

There is no "API_VERSION" macro, also >= and other conditional operators do not work in AGS script's preprocessor macros (I am curious how that even processed, maybe it just skips over them?).


How this works

Regarding how this works. There are three ways to check some version in script.
1. Original way was to use "#ifver" and "#ifnver" preprocessor directives. They let you find out if script is being compiled under certain version of AGS Editor. You can meet those in many script modules written having compatibility in mind.
Code: ags

#ifver 3.4.0
// the code here will be compiled only if Editor's version is 3.4.0 or higher
#endif

#ifnver 3.4.0
// the code here will be compiled only if Editor's version is LOWER than 3.4.0
#endif



Now, the problem with this was that it did not let you find out if certain new or old API is enabled for compilation. There were other macros which allowed to test compatibility script modes, but they worked rather as "thematic" groups, than the actual version of script:
* AGS_NEW_STRINGS
* AGS_SUPPORTS_IFVER
* STRICT (true if certain of old non-OO functions are disabled)
* STRICT_STRINGS (true if old string functions are disabled)
* STRICT_AUDIO (true if old audio functions are disabled)


AGS 3.4.0 introduces three new macros, controlled by related switches in the General Settings:

1. "NEW_DIALOGOPTS_API". This macro is defined if new dialog options rendering API is enabled for the game (this API is explained here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=52499.msg636523561#msg636523561). Notably "get_active_option" does not work if new API is on.

2. SCRIPT_API_vXXX set of macros. Note that they never include fourth version number.
This macro means "include script API which was NEW at given version". It defines the TOP boundary of available API content.

It is important to understand, that for the given script API mode, ALL of the preceding macros are also declared.
What this means is that if user set, for example, Script API = 3.3.4, then following macros will currently be declared:
- SCRIPT_API_v321
- SCRIPT_API_v330
- SCRIPT_API_v334

3. SCRIPT_COMPAT_vXXX set of macros.
This macro means "include all the script API which was still available at given version" (even if it became obsoleted in later ones). It defines the BOTTOM boundary of available API content.

For the given compatibility mode, ALL of the subsequent macros are also declared.
What this means is that if user set, for example, Compatible with API = 3.3.4, then following macros will currently be declared:
- SCRIPT_COMPAT_v334
- SCRIPT_COMPAT_v335
- SCRIPT_COMPAT_v340



Practical example: game developer sets following values in their project:
Script API: 3.4.0
Script Compatibility: 3.3.0

This means that it's guaranteed that all AGS functions that worked in versions 3.3.0 -> 3.4.0 by default will work in the game script.

Monsieur OUXX

Thanks a lot; I'll see how I can best use this. Thanks thanks thanks.
 

SMF spam blocked by CleanTalk