lua

how to read lua table return value from c++

hi, I have a lua function that returns table (contains set of strings) the function run fine using this code: lua_pushstring (lua, "funcname"); lua_gettable (lua, LUA_GLOBALSINDEX); lua_pushstring(lua, "someparam"); lua_pcall (lua, 1, 1, 0); the function returns a table. how do I read it's contents from my c++ code? ...

Lua domain specific configuration help

I have 5000 data item definition configuration which we are expecting to be designed like, -- Name of the device VARIABLE Name { type=Float, length=20, <<few more definition here>> } -- The device running elapsed time since its last boot VARIABLE BootTime { type=Integer, <<few more definition here>> } I will be...

Assistance with Lua Cosine, wrong results returned

Ok, first up, this is NOT for a class, test, or other student type activity. I'm a scripter for a game, and am trying to implement the math library for all to use, and unfortunately, all I have available to me is very basic lua. The implemented version cannot be changed, and does not include any libraries. For those wondering, its for ...

Dictionary based switch-like statement with actions

Hi, I'm relatively new to Python and would like to know if I'm reinventing a wheel or do things in a non-pythonic way - read wrong. I'm rewriting some parser originally written in Lua. There is one function which accepts a field name from imported table and its value, does some actions on value and stores it in target dictionary under ...

Pushing a lua table

I have created a lua table in C, but i'm not sure how to push that table onto the top of a stack so I can pass it to a lua function. Does anyone know how to do this? This is my current code: lua_createtable(state, libraries.size(), 0); int table_index = lua_gettop(state); for (int i = 0; i < libraries.size(); i++) { lua_pushstring...

Binding Lua to Ada in win32 (xp,vista,etc.)?

There is only one public library for binding Lua to Ada I have found (http://coreland.ath.cx/code/lua-ada), but how can it be used on a Windows platform? What do I need to use in my ada-project to get lua.ads.adb libraries defined in project-files working properly? I tried to put lua sources in my ada-project directory befory compiling ...

How to control cmd-window in win32 from Ada-code?

Hi to all. I've made a simple Lua-execution in Ada, it cooly run everything I need via Lua.Load_Buffer("os.execute('wxlua.exe wx.lua')") but I don't need win32 cmd.exe-window, which is default opens on program's start-up. Is there any way to control this event directly from Ada? P.S. os.execute() sends commands directly to Windows, not...

Stack unwinding in C++ when using Lua.

I recently stumbled into this this C++/Lua error int function_for_lua( lua_State* L ) { std::string s("Trouble coming!"); /* ... */ return luaL_error(L,"something went wrong"); } The error is that luaL_error use longjmp, so the stack is never unwound and s is never destructed, leaking memory. There are a few more Lua API's th...

How do I use applyLinearImpulse based on rotation in Corona / Lua

I am using the Corona Gaming Addition SDK to build an iphone / andorid game. I have a space ship on the screen and I will allow the user to rotate the ship 360 degrees. I would like to then call the applyLinearImpulse method to allow the user to thrust the ship forward in the direction the ship is facing. The method accepts these argume...

What are the key tools and steps it takes to make a 3d video game?

What are the key steps and tools it takes to creating a 3d video game. For example, I understand that a 3d artist will create 3d models in 3d Studio Max, or Maya, but where do these models go from there? Are the 3d models first animated by a 3d animator in 3d Studio Max/Maya? Then do these models along with the animation loops get sen...

Variables not equivalent fstream vs. declaration

Basically I'm reading the contents of a file using fstream then converting it to const char* type. I'm supplying this to Lua, and Lua will do something with this. This however does not work. What does work is if I do: const char* data = "print('Hello world')"; luaL_pushstring(L, data); luaL_setglobal(L, "z"); They both are in the t...

In Lua, how can you print the name of the current function, like the C99 __func__ identifier?

Something like this: function foo() print( __func__ ) ... end How can it be done? ...

Using Maven as build tool for Lua programs

Hello, I need a build tool for compiling,testing, reporting and the deployment of Lua programs. I chose Maven 2 because of our Polarion version supports it. Unfortunately, I couldn't find any Maven plugins/archetypes for Lua. As I am a newbie in Maven I want to know whether it is difficult to write a customized Lua plugin for Maven. ...

Scite Lua: string comparison raises "attempt to call a string value"?

Hi all, Trying to write a Lua script for Scite (something like lua-users wiki: Scite Comment Box), and when I write the following piece of code: fchars = string.sub(line, 1, 3) if fchars == "//" or fchars == "##" print "got it" end ... the compilation fails with "attempt to call a string value". I have tried different variant...

In lua, how to do the function of a-b while a & b are arrays or tables

i am a new programmer and started with lua . i want to do the function that array a -b , the following are my program, it didn't work well function delTwo (a ,b) local i = 0 local lengthA = #a local lengthB = #b for i = 1 ,lengthA do for j =1 , lengthB do if a[i]==b[j] then a[i] = nil end end for i = 1 , le...

Loading files not in local folders when embedding lua in C++

I'm writing a basic scripting system using lua in C++. One of my glue functions is... lua_register(luaVM, "openFile", l_dial.l_specifyF); The function is as follows. static int l_specifyF(lua_State* luaVM) { const char* c = lua_tostring(luaVM, -1); cDialogManager::getSingletonPtr()->clearVector(); try{ luaL_dofile...

running lua scripts using fastCGI

hello, i am currently trying to figure out ways to run lua scripts using fastCGI with either lighttpd or nginx. the only thing i was able to dig up yet was wsapi of the kepler project. but i wonder, if there are other possibilities. important for me is: should be as lightweight as possible should be stable enough to use in a productio...

Lua's GC and realtime game

As I know, the tracing GC can't avoid thread blocking during complete GC. I had used XNA+C#, and GC time impossible to remove. So I switched to lower level language C, but I realized I need scripting language. I'm considering Lua, but I'm worrying about Lua's GC mechanism. Lua is using incremental tracing GC, and thread blocking should ...

What's the advantage of stack-less Python's microthread than Lua's coroutine in state machine implementation for game?

Any advantage on stack-less python implentation than Lua's coroutine? What's the difference of them? ...

ANTLR Lua long string grammar rules

I'm trying to create ANTLR parser for Lua. So i took grammar produced by Nicolai Mainero(available at ANTLR's site, Lua 5.1 grammar) and begin to work. Grammar is good. One thing not working: LONG STRINGS. Lua specification rule: Literal strings can also be defined using a long format enclosed by long brackets. We define an op...