diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/lua.cc | 21 | 
1 files changed, 17 insertions, 4 deletions
| diff --git a/client/lua.cc b/client/lua.cc index af64efb..8a18b1e 100644 --- a/client/lua.cc +++ b/client/lua.cc @@ -60,19 +60,31 @@ static int get_widget(lua_State *L)    Widget *widget = lua->getWidget(name); -  DEBUG(lua, "FIND: %s (%p)\n", name.toStdString().c_str(), widget); -    if(widget) {      wdg_make_widget(L, widget);    } else {      lua_pushnil(L);    } -  DEBUG(lua, "DONE\n"); -    return 1;  } +static int debug(lua_State *L) +{ +  int n = lua_gettop(L); // number of arguments +  if(n != 1) { +    char errstr[512]; +    sprintf(errstr, "Number of args expected 1, got %d", n); +    lua_pushstring(L, errstr); +    lua_error(L); +    return 1; +  } + +  DEBUG(lua, "%s", lua_tostring(L, lua_gettop(L))); + +  return 0; +} +  LUA::LUA(Widget **rootwidget)  {    this->rootwidget = rootwidget; @@ -102,6 +114,7 @@ void LUA::clear()    lua_setglobal(L, GLOBAL_POINTER); // Assign it to a global lua var.    lua_register(L, "widget", get_widget); +  lua_register(L, "debug", debug);    register_widget(L);  } | 
