Reworked how to call 'standard' stuff from within lua scripts, so now it's much simpler both in lines of code and usage. A script can now call core.console('hf mf nested 1 0 a ffffffffffff') in order to execute anything via the old command line parser

This commit is contained in:
martin.holst@gmail.com 2013-10-04 19:29:46 +00:00
parent 4f269f63da
commit 0a85b72549
2 changed files with 13 additions and 94 deletions

View file

@ -136,6 +136,18 @@ static int l_ukbhit(lua_State *L)
lua_pushboolean(L,ukbhit() ? true : false);
return 1;
}
/**
* @brief Calls the command line parser to deal with the command. This enables
* lua-scripts to do stuff like "core.console('hf mf mifare')"
* @param L
* @return
*/
static int l_CmdConsole(lua_State *L)
{
CommandReceived((char *)luaL_checkstring(L, 1));
return 0;
}
/**
* @brief Sets the lua path to include "./lualibs/?.lua", in order for a script to be
@ -172,6 +184,7 @@ int set_pm3_libraries(lua_State *L)
{"foobar", l_foobar},
{"ukbhit", l_ukbhit},
{"clearCommandBuffer", l_clearCommandBuffer},
{"console", l_CmdConsole},
{NULL, NULL}
};