lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Title: RE: Ironic comment RE: cooperative multitasking

> I hope so, but we'd be interested in learning what kind of
> hacking is going on.

My own case might be a bit fringe, but I had two main hacks
to Lua. The first one was dealt with (using integers instead
of floating point values). The second one simply adds a new
pointer to the table structure.

Let me give a bit of background to what I do:
My game's objects each have an associated Lua table, which
represents the object in Lua. When a script wants to query
something about the engine state of an object (eg position)
or perform an action on an object (eg switch on), it calls
one of the many extensions from the engine, and supplies the
table to act on. Since the C++ code does not work with tables
but objects, I have to get the corresponding object. I solved
this by adding a void* pointer in the table structure, which
points back at its C++ owner.

Fair enough, I could use a std::map (or a Lua table :)) to
get the object (or userdata (this would become much more
doable actually with the new bare userdata) if using Lua
for this), but I didn't go this route, since this addition
of an owner pointer seems clean and simple to me (though
needing to alter Lua itself).

> Sure, but the book has to be about a stable language and
> we keep changing it!

I'm still using 4.0 alpha, the last version with the 3.2
style C API :)
Back to lurk mode now ;)

--
Vincent Penquerc'h