🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

debugging with LUA

Started by
1 comment, last by Filami 20 years, 10 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
Advertisement
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 -=-
Thancks!! It will be easier now to search!!
Techno Grooves

This topic is closed to new replies.

Advertisement