Skip to content

Commit

Permalink
Script API: introduce an API version number
Browse files Browse the repository at this point in the history
As the list of minetest.features.* grows, it seems to be more future-proof
to use a numeric value to refer to in the documentation.
Similar concepts are already in use:

 * formspec version
 * protocol version
  • Loading branch information
SmallJoker committed Mar 17, 2024
1 parent 234b01a commit c696f8f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/game/features.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
-- Minetest: builtin/features.lua

-- The changelog is located in doc/lua_api.md
core.api_version = 1

core.features = {
glasslike_framed = true,
nodebox_as_selectionbox = true,
Expand Down
19 changes: 19 additions & 0 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5277,6 +5277,23 @@ Minetest includes the following settings to control behavior of privileges:
'minetest' namespace reference
==============================

API Version
-----------

* `minetest.api_version`: numeric value
* Describes the modding API capabilities and behavior. This value
depends on the server version and can be used to achieve backwards
compatibility in mods.
* This supersedes the concept of `minetest.features`.
* Exists since Minetest version 5.9.0. Use the expression
`(minetest.api_version or 0)` as a fallback.

**API Version History**

* API version 1 (5.9.0):
* All of `minetest.features`


Utilities
---------

Expand Down Expand Up @@ -5401,6 +5418,8 @@ Utilities
lsystem_decoration_type = true,
-- Overrideable pointing range using the itemstack meta key `"range"` (5.9.0)
item_meta_range = true,

-- All the features above are present if `(minetest.api_version or 0) >= 1`
}
```

Expand Down

0 comments on commit c696f8f

Please sign in to comment.