Advertisement

debugging with LUA

Started by August 27, 2003 09:37 PM
1 comment, last by Filami 21 years, 2 months ago
Hi ppl. Imagine I have a code at main.lua and I do LUA_dostring("mais.lua"); Ok, this runs the script. But what abou if I want to run it line by line? (I mean, like goto cursor, next cursor, etc). How do I get the names for all variables on the Stack?
Techno Grooves
Im only just learning LUA, but it seems to me that this code from the LUA 5 manual should help,

int listvars (lua_State *L, int level) {   lua_Debug ar;   int i;   const char *name;   if (lua_getstack(L, level, &ar) == 0)      return 0;  /* failure: no such level in the stack */   i = 1;   while ((name = lua_getlocal(L, &ar, i++)) != NULL) {      printf("local %d %s\n", i-1, name);      lua_pop(L, 1);  /* remove variable value */   }   lua_getinfo(L, "f", &ar);  /* retrieves function */   i = 1;   while ((name = lua_getpuvalue(L, -1, i++)) != NULL) {      printf("upvalue %d %s\n", i-1, name);      lua_pop(L, 1);  /* remove upvalue value */   }   return 1;} 


Hope it helps.
-=- Murphy was an optimist -=-
Advertisement
Thancks!! It will be easier now to search!!
Techno Grooves

This topic is closed to new replies.

Advertisement