lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello!

Sorry for my poor english...

I decided to use LUA for loading and saving configuration files, but how
it´s possible to SAVE such a configuration file from the LUA globals stack?

I tried it this way:

-- CODE BEGIN --
lua_pushvalue(L, LUA_GLOBALSINDEX);

lua_pushnil(L);
while (lua_next(L, -2) != 0) {
  if (!isInMyFilterValues(L)) {
    // save them to the file
  }

  // removes ?value?; keeps ?key? for next iteration
  lua_pop(L, 1);
}
-- CODE END --

But this sounds IMHO a little bit dirty?! Isn´t it?

And there are two problems to solve...
1.) If I save my config file to disk the tables are saved in the wrong
direction.
2.) How can I save comments? ("-- comment")

Thanks for your help! ;)

Cheers, Mike