Mod API Reference:IsVersionOrHigher: Difference between revisions

From Warzone Wiki
Jump to navigation Jump to search
Created page with "'''WL.IsVersionOrHigher''': A function that can be called to determine what version of the Warzone code is running. It takes a single argument, a string, that identifies what..."
 
No edit summary
 
Line 10: Line 10:
   end
   end


 
Note that the Warzone server can be assumed to always be running the latest version of Warzone code.  However, in single-player games, the Server_ hooks are invoked on the client, so you can't assume that you're always in the latest version of the code just because you're in a server hook.


[[Category:Mod API Reference]]
[[Category:Mod API Reference]]

Latest revision as of 22:09, 11 January 2022

WL.IsVersionOrHigher: A function that can be called to determine what version of the Warzone code is running. It takes a single argument, a string, that identifies what version to compare to, and returns a boolean.

Note that this function was only added in Warzone version 5.17, so if you need to support older versions than that, you should check that the IsVersionOrHigher function itself exists.

This should be used whenever you are using an API feature that says it was added in a specific version to verify that the feature is available. For example, if a feature says it was added in version 5.17, you could check like this:

 if (not WL.IsVersionOrHigher or not WL.IsVersionOrHigher("5.17")) then
     UI.Alert("You must update your app to the latest version to use this mod");
     return;
 end

Note that the Warzone server can be assumed to always be running the latest version of Warzone code. However, in single-player games, the Server_ hooks are invoked on the client, so you can't assume that you're always in the latest version of the code just because you're in a server hook.