Lua scripts can detect EdgeTX via getVersion
Add a sixth parameter to getVersion so that scripts can detect whether running on EdgeTX or OpenTX. i.e. `local ver, radio, maj, minor, rev, osname = getVersion()`
This commit is contained in:
@@ -99,7 +99,16 @@ If running in simulator the "-simu" is added
|
||||
* (number) minor version (ie 1 if version 2.1.5)
|
||||
* (number) revision number (ie 5 if version 2.1.5)
|
||||
|
||||
@status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0
|
||||
@retval multiple (available since 2.1.7) returns 6 values:
|
||||
* (string) OpenTX version (ie "2.1.5")
|
||||
* (string) radio type: `x12s`, `x10`, `x9e`, `x9d+`, `x9d` or `x7`.
|
||||
If running in simulator the "-simu" is added
|
||||
* (number) major version (ie 2 if version 2.1.5)
|
||||
* (number) minor version (ie 1 if version 2.1.5)
|
||||
* (number) revision number (ie 5 if version 2.1.5)
|
||||
* (string) OS name ( i.e. EdgeTX or nil if OpenTX)
|
||||
|
||||
@status current Introduced in 2.0.0, expanded in 2.1.7, radio type strings changed in 2.2.0, os name added in EdgeTX 2.4.0
|
||||
|
||||
### Example
|
||||
|
||||
@@ -107,12 +116,13 @@ This example also runs in OpenTX versions where the function returned only one v
|
||||
|
||||
```lua
|
||||
local function run(event)
|
||||
local ver, radio, maj, minor, rev = getVersion()
|
||||
local ver, radio, maj, minor, rev, osname = getVersion()
|
||||
print("version: "..ver)
|
||||
if radio then print ("radio: "..radio) end
|
||||
if maj then print ("maj: "..maj) end
|
||||
if minor then print ("minor: "..minor) end
|
||||
if rev then print ("rev: "..rev) end
|
||||
if osname then print ("osname: "..osname) end
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -134,7 +144,8 @@ static int luaGetVersion(lua_State * L)
|
||||
lua_pushnumber(L, VERSION_MAJOR);
|
||||
lua_pushnumber(L, VERSION_MINOR);
|
||||
lua_pushnumber(L, VERSION_REVISION);
|
||||
return 5;
|
||||
lua_pushstring(L, "EdgeTX");
|
||||
return 6;
|
||||
}
|
||||
|
||||
/*luadoc
|
||||
|
||||
Reference in New Issue
Block a user