I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following:
A * getAnObject()
{
if(someBoolean)
return (A *) new B;
else
return (A *) new C;
}
Where "A" is the parent of classes "B" and "C". One can then typec...
[I've read the Lua manual, but it did not provide solid answers.]
Let's say I have a Lua Table, acting as an indexed array:
local myArray = {};
myArray[1] = "Foo";
myArray[2] = "Bar";
How do I best dispose of this Table? Do I just set myArray to nil? Or do I have to iterate through array and set each indexed element to nil?
Simila...
I'm lead dev for Bitfighter, and we're using Lua as a scripting language to allow players to program their own custom robot ships.
In Lua, you need not declare variables, and all variables default to global scope, unless declared otherwise. This leads to some problems. Take the following snippet, for example:
loc = bot:getLoc()
item...
I'm a Lua novice. I'm unit testing Lua 5.1 code using Lunity and LeMock.
My class is StorageManager. I'm unit testing its load() method, which loads files from disk. I don't want my unit tests dependent on actual files on the actual disk to test that.
So, I'm trying to inject the I/O dependency with a mock object and verify that obj...
i simply love javascript ... it's so elegant (imagine the quiet sound of lovestruck fanboy sighing in the background).
so, recently i have played with Lua via the löve2d framework (nice!) - and i think Lua is also great. they way i see it, those two languages are very similar.
there are obvious differences, like
syntax
problem domain...
I'm writing a jFlex lexer for Lua, and I'm having problems designing a regular expression to match one particular part of the language specification:
Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs fo...
How do you make a combo of two emotes in lua in World of Warcraft work?
function Button2_OnClick()
PlaySoundFile("Interface\\Addons\\Fart\\common_fart[1].wav");
DoEmote("moon");
DoEmote("sit");
DoEmote("dance");
DoEmote("beckon");
end
I am using Wow Addon Studio to make a fart application on Wow.
I used this functi...
I cant figure out how to get lua to do any common timing tricks, such as
sleep - stop all action on thread
pause/wait - don't go on to the next
command, but allow other code in the
application to continue
block - don't go on to next command until the
current one returns
And I've read that a
while os.clock()<time_point do
--nothi...
I need to perform operations on Lua tables from C where the tables are treated as lists or queues. Specifically I need to insert an element at the head, and remove the head element, and have the other elements move to accommodate the new element.
This would be simple in straight lua, i'd use table.insert and table.remove. But in C?
The...
I have a Lua program that is consuming data from an external device. The device is returning malformed XML that looks like:
<element attribute1="value1" attribute2="value2" attribute3=" m "value3" " attribute4="value4" />
In particular some of the fields are user editable and could conceivable contain items that should be escaped, bu...
I'm lead dev for Bitfighter, a game primarily written in C++, but using Lua to script robot players. We're using Lunar (a variant of Luna) to glue the bits together.
I'm now wrestling with how our Lua scripts can know that an object they have a reference to has been deleted by the C++ code.
Here is some sample robot code (in Lua):
if...
Been using Lua 5.0 in a Mac OS X universal binary app for some years. Lua scripts are compiled using luac and the compiled scripts are bundled with the app. They have worked properly in Tiger and Leopard, Intel or PPC.
To avoid library problems at the time, I simply added the Lua src tree to my Xcode project and compiled as is, with no ...
I'm trying to parse chat messages for keywords that I will use to trigger various functions. In order to use the chat I have to test in game mode, which is started by first clicking Tools-> Test-> Start Server and then clicking Tools-> Test-> Start Player. The command window is not available in game mode so I need a way to get some debug...
With intermediate knowledge of VB6, recently people have been suggesting to "upgrade" to a new language. I'm thinking about Lua - it's easy, simple and speedy. But there doesn't seem to be any infomation about creating applications similar to K3b, uTorrent, CCleaner and mIRC.
...
I have a script file embedded in the Workspace that contains functions. I would like call these functions from script files embedded in child objects of the Workspace. I don't want to have to copy and paste these functions into multiple script files. I figured the object oriented approach would be best if its possible.
...
C# has this and VB has ME. What is the Lua equivalent?
I am trying to reference the parent of the script class in Roblox.
...
I'm having a hard time grokking classes in lua. Fruitless googling led me to ideas about metatables and implied 3rd party libraries are necessary to simulate/write classes.
Here's a sample (just because I've noticed I get better answers when I provide sample code)
public class ElectronicDevice
{
protected bool _isOn;
public bo...
I've read somewhere on here where someone recommended using Loki's Small Object Allocator for Lua to help improve allocation performance. I read through the section in 'Modern C++ Design' and I think I've got a good enough understand on using Loki for this, with the exception of not using the SmallObject - Lua just wants raw memory, so ...
Ok, here's a problem I'm having.
I have Lua bindings to a rendering engine that has an internal render manager that keeps its own track of pointers for the render scene and manages them. The problem is that when I'm using it from Lua, if i don't keep a Lua reference to every single object i add to the C++ render manager, it starts to ga...
I'm dealing with timestamps in Lua showing the number of microseconds since the Epoch (e.g. "1247687475123456").
I would really like to be able to print that number in all its terrible glory, but Lua insists on printing it in scientific notation. I've scoured the available documentation about printing a formatted string, but the only av...