Lua setGlobalVariable / getGlobalVariable added in model library
This commit is contained in:
@@ -741,6 +741,29 @@ static int luaModelSetOutput(lua_State *L)
|
|||||||
|
|
||||||
return 0;
|
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)
|
static int luaPopupInput(lua_State *L)
|
||||||
{
|
{
|
||||||
uint8_t event = luaL_checkinteger(L, 2);
|
uint8_t event = luaL_checkinteger(L, 2);
|
||||||
@@ -849,6 +872,8 @@ static const luaL_Reg modelLib[] = {
|
|||||||
{ "setCustomFunction", luaModelSetCustomFunction },
|
{ "setCustomFunction", luaModelSetCustomFunction },
|
||||||
{ "getOutput", luaModelGetOutput },
|
{ "getOutput", luaModelGetOutput },
|
||||||
{ "setOutput", luaModelSetOutput },
|
{ "setOutput", luaModelSetOutput },
|
||||||
|
{ "getGlobalVariable", luaModelGetGlobalVariable },
|
||||||
|
{ "setGlobalVariable", luaModelSetGlobalVariable },
|
||||||
{ NULL, NULL } /* sentinel */
|
{ NULL, NULL } /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -692,7 +692,7 @@ PACK(typedef struct t_MixData {
|
|||||||
PACK( union u_gvarint_t {
|
PACK( union u_gvarint_t {
|
||||||
struct {
|
struct {
|
||||||
int8_t lo;
|
int8_t lo;
|
||||||
uint8_t hi;
|
uint8_t hi;
|
||||||
} bytes_t;
|
} bytes_t;
|
||||||
int16_t word;
|
int16_t word;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user