mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Lua setGlobalVariable / getGlobalVariable added in model library
This commit is contained in:
parent
6868b69aad
commit
1466f96e51
2 changed files with 26 additions and 1 deletions
|
@ -741,6 +741,29 @@ static int luaModelSetOutput(lua_State *L)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaModelGetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
if (phase < MAX_PHASES && idx < MAX_GVARS)
|
||||
lua_pushinteger(L, g_model.phaseData[phase].gvars[idx]);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int luaModelSetGlobalVariable(lua_State *L)
|
||||
{
|
||||
int idx = luaL_checkunsigned(L, 1);
|
||||
int phase = luaL_checkunsigned(L, 2);
|
||||
int value = luaL_checkinteger(L, 3);
|
||||
if (phase < MAX_PHASES && idx < MAX_GVARS && value <= 500) {
|
||||
g_model.phaseData[phase].gvars[idx] = value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaPopupInput(lua_State *L)
|
||||
{
|
||||
uint8_t event = luaL_checkinteger(L, 2);
|
||||
|
@ -849,6 +872,8 @@ static const luaL_Reg modelLib[] = {
|
|||
{ "setCustomFunction", luaModelSetCustomFunction },
|
||||
{ "getOutput", luaModelGetOutput },
|
||||
{ "setOutput", luaModelSetOutput },
|
||||
{ "getGlobalVariable", luaModelGetGlobalVariable },
|
||||
{ "setGlobalVariable", luaModelSetGlobalVariable },
|
||||
{ NULL, NULL } /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue