lua

LuaInterface Docs?

I downloaded LuaInterface recently, but it doesn't come with a single bit of documentation. Am I just supposed to use the Lua API's docs or something? ...

Check if directory exists in lua?

How do I check if a directory exists in lua, preferably without using the LuaFileSystem module if possible? Trying to do something like this python line: os.path.isdir(path) ...

BadImageFormatException when attempting to use LuaInterface

I imported LuaInterface into a console project, referenced it, and wrote a small test script. When i run it, i get this: Could not load file or assembly 'LuaInterface, Version=2.0.0.16708, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Forgive me for be...

LuaJit increase stack/heap size

Hi, I keep getting a out of memory error in LuaJit. How do I increase the stack or heap size? Thanks ...

Do file only once in Lua

Hi, I was wondering if there's a way to do a lua file only once and have any subsequent attempts to do that lua file will result in a no-op. I've already thought about doing something akin to C++ header's #if/else/endif trick. I'm wondering if there's a standard way to implement this. James ...

Lua: use table as args

Hi, I have numerous functions (unknown at design time) that each take a specific number of arguments. I have a table of arguments. How do I call those functions with this table of arguments? Thanks, James ...

Explanation of Asm code

Hi, The following GCC inline asm is taken from LuaJit's coco library. Can someone provide a line by line explanation of what it does? static inline void coco_switch(coco_ctx from, coco_ctx to) { __asm__ __volatile__ ( "movl $1f, (%0)\n\t" "movl %%esp, 4(%0)\n\t" "movl %%ebp, 8(%0)\n\t" "movl 8(%1), %%ebp\n\t" "...

Architecture for Qt application with Lua scripting - pause execution.

My embedded project contains a Qt application for the PC which is mainly a simulator for debugging and testing. In the application I can create several widgets which represent either my embedded software or simulate the hardware controlled by the application or can generate external inputs for testing. I plan to improve the application ...

Cloning Lua state

Folks, is there a way to clone a Lua state? In my game application the initialization procedure of the Lua virtual machine is pretty heavy(about 1 sec, since many scripts are loaded at once). I have a separate Lua VM for each autonomous agent and once the agent is created its Lua initialization affects FPS pretty badly. I'm thinking a...

What strategy should be used when exposing c++ to Lua

I have a c++ library which has functionality exposed to Lua, and am seeking opinions on the best ways to organise my lua code. The library is a game engine, with a component based Game Object system. I want to be able to write some of these components as classes in Lua. I am using LuaBind, so I can do this but there are some implementat...

Selecting random phrase from a list

Hi - I've been playing around with a .lua file which passes a random phrase using the following line: SendChatMessage(GetRandomArgument("text1", "text2", "text3", "text4"), "RAID") My problem is that I have a lot of phrases and the one line of code is very long indeed. Is there a way to hold text1 text2 text3 text3 in a list some...

Changing one table seems to change the other

I'm writing a lua script, and one of the things it does is copy a table into a table of tables, and apply a couple transformations to it. What's odd though is when i go to use one of those tables later (and modify some of it's properties), changes will also seem to show up in other tables! Code: -- thanks to http://stackoverflow.com/que...

Better way to architect this function?

I have a function that consists mainly of a massive amount of calls (50+) to another function which inserts data into an array, with logic here and there dictating various conditions to insert various items into the array (plus a little bit on the end that writes the contents of the array out to a file). I'm wondering if there isn't a be...

Concatenation of strings in Lua

In many languages you can concatenate strings on variable assignment. I have a scenario, using the Lua programming language, where I need to append the output of a command to an existing variable. Is there a functional equivalent in Lua to the below examples? Examples of other languages: ===== PERL ===== $filename = "checkbook"; $fil...

TCL vs Lua - scripting a mmo server

I have a c++ server side project that I need to embed some sort of scripting into. It is part of an online MMO type of server. I have significant experience using TCL, and it seems like the natural fit. I've done a minimal amount of Lua in my game dev days, and I wonder if this might be a better language for embedded scripting. It is als...

Concatenation of tables in Lua

ORIGINAL POST Given that there is no built in function in Lua, I am in search of a function that allows me to append tables together. I have googled quite a bit and have tried every solutions I stumbled across but none seem to work properly. The scenario goes like this: I am using Lua embeded in an application. An internal command of...

Help with boost bind/functions

Hi, I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target sig Here's what I have so far: //somewhere else... ... registerFunction<LuaEngine>("testFunc", &LuaEngine::testFunc, this); ... //0 arg callback void funcCallback0(boost::function<void ()> func, lua_State *state)...

Reference to Lua function in C/C++

I have a functions nested relatively deeply in a set of tables. Is there a way in C/C++ to get a "reference" to that function and push that (and args) onto the stack when I need to use it? ...

Lua: Get the literal name of the parameter

For example, function test (a) name = nameof(a) print(name) end test(def) --should print "def" Are there any lua tricks to implement something similar to the above? ...

Lua Closures in implementing a DSL

Lua has a really nice no-parenthesis call syntax that coupled with function closures allow me to write the following local tag = 1 function test(obj) return function(str) return function (tbl) tbl.objtag = tag tbl.objname = str return tbl end end end test (tag) "def" { } test tag ...