lua gsub %b <-- how does this work?
In the following lua code: function interp(s, tab) return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end)) end what does the %b mean? and how does this match stuff like "${name}" ? ...
In the following lua code: function interp(s, tab) return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end)) end what does the %b mean? and how does this match stuff like "${name}" ? ...
Sample code: function Account:new (o) o = o or {} -- create object if user does not provide one setmetatable(o, self) self.__index = self return o end taken from: http://www.lua.org/pil/16.1.html What is the purpose of the: self.__index = self line? And why is it executed every time an object is created? ...
I'm looking at incorporating Lua into a C++ project, and am a bit confused by the presence of the two binaries (lua51.dll and lua5.1.dll) in the distribution from Luabinaries. According to the docs... In Windows your library or application must be linked with a stub library. A stub library is a library with only the function d...
Two quick questions (I hope...) with the following code. The script below checks if a number is prime, and if not, returns all the factors for that number, otherwise it just returns that the number prime. Pay no attention to the zs. stuff in the script, for that is client specific and has no bearing on script functionality. The scri...
Hi, I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python. Does anyone know how to do this? Joe ...
I've skimmed Programing in Lua, I've looked at the Lua Reference. However, they both tells me this function does this, but not how. When reading SICP, I got this feeling of: "ah, here's the computational model underlying scheme"; I'm trying to get the same sense concerning lua -- i.e. a concise description of it's vm, a "how" rather th...
I have a makefile that looks like: default: lua blah.lua Now, in Vim, I type ":make". There's an error in my Lua code; it gives a file name + line number. I would like Vim to jump to the right file/line. How do I make this happen? ...
Hello I just got started looking at Lua as an easy way to access the SQLite DLL, but I ran into an error while trying to use the DB-agnostic LuaSQL module: require "luasql.sqlite" module "luasql.sqlite" print("Content-type: Text/html\n") print("Hello!") Note that I'm trying to start from the most basic setup, so only have the follo...
I have embedded Lua in an Objective-C application using LuaObjCBridge. I need to know how to stop the Lua process if it taking too much time (infinite loop?). Would running it in a separate thread help? ...
Although the program I'm working on is in Java, answering this from a C perspective is also fine, considering that most of this is either language-agnostic, or happens on the Lua side of things. In the outline I have for the architecture of a game I'm programming, individual types of game objects within a particular class (eg: creatures...
I have a string in lua. It's a bunch of [a-zA-Z0-9]+ separated by a number (1 or more) spaces. How do I take the string and split it into a table of strings? Thanks! ...
I really like C's __LINE__ and __FILE__ ... does lua provide something similar? (I find it useful for tracking down printf's ... to know which file and which line the message comes from). Thanks! ...
I am using LuaSQL, and query for a result set using con:execute(sql_stmt), which returns a cursor. How do I see if there is at least one row in that resultset, without doing a cursor:fetch to pop that first row? ...
Okay, so when I run lua, I get something like: lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio > Now, I want a prompt like this, 1) in a GUI application I've written. My GUI application can provide functions like: get_input_from_screen(); and write_this_crap_out_to_screen(); and more functions I can write as necessary I als...
I want to have C++ objects that I can read/write in both C++ & Lua. I have looked at: http://www.lua.org/pil/28.html However, I do not like that solution, since my objects have constructors & destructors (and they are important as I use RAII and these take care of reference counts). What I don't like in the PIL solution is that the ob...
How do I send a string between 2 PSPs? Here is a test script: Script A Adhoc.init() Adhoc.connect() data1 = "Trey777" data2 = "This is a test!!..." Outdata = "Name"..data1.."text"..data2 function senddata() Adhoc.send(Outdata) end While true do screen.waitVblankStart() screen:flip() end Script B red = Color.new(255,0,0) Adhoc.in...
Hi, I don't understand the rational behind the decision of this part of Lua. Why does indexing start at 1? I have read(as many others did) this great paper. It seems to me a strange corner of a language that is very pleasant to learn and program. Don't get me wrong, Lua is just great but there has to be an explanation somewhere. Most of...
In many scheme/lisp dialects, when an error occurs, a "recursive repl" is popped up ... one can execute scheme/lisp code at the frame where the error occured, and go up/down the stack. Is it possible to do something similar to this in lua? Thanks! ...
Some days ago, our program crash. I found the crash in lua code. So I check lua code, found the stack overflow. Please look this code In function luaD_precall: 1 if (!cl->isC) { /* Lua function? prepare its call */ 2 CallInfo *ci; 3 StkId st, base; 4 Proto *p = cl->p; 5 luaD_checkstack(L, p->maxstacksize); 6 ...
I know of: http://lua-users.org/wiki/SimpleLuaApiExample It shows me how to build up a table (key, value) pair entry by entry. Suppose instead, I want to build a gigantic table (say something a 1000 entry table, where both key & value are strings), is there a fast way to do this in lua (rather than 4 func calls per entry: push key val...