|
Hi,
In C++, I have a map<string, string> , containing an unknown number of entries. How can I pass this to a Lua function, so that the Lua function can use the data as a table?
Hugo
Started by Rocketmagnet on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Generalized pairs is expected....
Create a proxy table table
A discussion of fixes to Lua for generalized pairs is in the wiki and this mailing list thread .
Copy the map into a new Lua table, and pass the Lua table.
A couple options...
|
|
Currently I'm building my own script VM manager class in C++, I have no problems with any of the lua & lua C or C++ stuff, but the one section that confuses me is: when to use lua_pop and when to use lua_remove .
From what I understand, lua_pop is to ...
Started by Necrolis on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
lua_getfield(L, LUA_GLOBALSINDEX, "t"); /* table to be indexed */ lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */....
Snippets from Lua reference manual .
A typical example of lua_remove is accessing tables.
|
|
I downloaded Eclipse Classic off of the Eclipse website then the Lua Eclipse IDE plugin . I followed the install instructions but Eclipse doesn't seem to recognize or be able to understand lua files. Can someone help?
Started by RCIX on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
But at least....
When I opened the file another error when it is wrong) .
Add more information
Which installation guide did you follow? ( Lua Eclipse Installation ?) Which a generic project, added a generic file linked to an existing Lua file.
|
Ask your Facebook Friends
|
Hi all?
I read something about Lua this day, and I was wondering what it was. I did a Google and Wikipedia (I understanded it until they begun talking about a C API) search bit I still don't understand it. Can someone explain me what Lua is and maybe ...
Started by Koning Baard XIV on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
It allows to use the simpler syntax of....
Lua is a lightweight interpreted programming language developed in Brazil with a focus on embedding:
print("Hello World!")
Wikipedia Summary
Official Site
Lua is a scripting language for C and C++.
|
|
I am using the lua C-API to read in configuration data that is stored in a lua file.
I've got a nice little table in the file and I've written a query C-function that parses out a specific field in the table. (yay it works!)
It works by calling a few ...
Started by Oren on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If your C function is called by another C function that uses the Lua stack, then those values will....
If your C function is called from Lua, the values you leave behind will be the values that your C function returns to Lua.
It depends.
|
|
I want to create a table like
myTable = { [0] = { ["a"] = 4, ["b"] = 2 }, [1] = { ["a"] = 13, ["b"] = 37 } }
using the C API?
My current approach is
lua_createtable(L, 0, 2); int c = lua_gettop(L); lua_pushstring(L, "a"); lua_pushnumber(L, 4); lua_settable...
Started by Etan on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
#include <stdio.h> #include "lua.h" #include "lauxlib.h" #include "lualib.h" int main() { int res; lua_State *L = lua_open(); luaL_openlibs(L); lua_newtable(L); /* bottom table */ lua....
Is the lua_setfield function.
|
|
I was wondering, what can i use to program in Lua on the Mac? I'm looking for something that i can use to compile/interpret lua script on the mac.
Started by RCIX on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
It will build lua (the interpreter which (from the shell):
sudo port install lua
I LOVE macports!
Here is my terminal session from compiling and installing Lua from....
The Lua source easily compiles with no changes on the mac.
|
|
I'm embedding a Lua interpreter in my current project (written in C ) and I am looking for an example of how to handle errors. This is what I have so far...
if(0 != setjmp(jmpbuffer)) /* Where does this buffer come from ? */ { printf("Aargh an error!\...
Started by Adam Pierce on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I think....
Here 's a cross-referenced Doxygen of the same.
This is defined in the Lua core header lstate.h .
The jump buffer chain is part of the struct lua_longjmp pointed to by errorJmp field in the per-thread state struct lua_State .
|
|
Consider the following example (a simple 2d vector lib). Here there is a single constructor function which returns an object table with methods. My issue with this approach is that it is creating new tables with every constructor. Is there a way to use...
Started by Nick on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Since....
Consider using tolua which allows your lua code to directly interact with specified portions containing a light userdatum with the instance data, as well as a bunch of C functions wrapped into Lua with objects in a variety of ways.
|
|
Hi, how do I check the value of the top of the stack in Lua?
I have the following C++ code:
if (luaL_loadfile(L, filename) == NULL) { return 0;// error.. } lua_pcall(L,0,0,0); // execute the current script.. lua_getglobal(L,"variable"); if (!lua_isstring...
Started by krebstar on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
In either case, the return value is an int where 0 if the file was loaded, but the code calls... .
My guess as lua_load() or one additional error code.
lua_pcall is unnecessary.
I think you want to replace luaL_loadfile with lua_dofile .
|