lua-users home
lua-l archive

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

I've been playing with that idea for a while now. I'm working on a game that has an in-game editor, and was looking for a way to allow the level designers easy access to the lua code of the scripting engine. I was thinking something along the lines of good old-fashioned muds: a database of objects which users can create, destroy, and edit on the fly, and have the engine be able to save and load the entire database as source code.
This could get really messy quickly, so I was thinking of keeping it simple. The concept would be a thin layer of wrapper functions that takes a table name, index, and string of source to assign to that table and index. The layer would do the actual assignment, as well as dump the source to a structured file of some sort (XML, ini-style, whatever). There would also have to be calls to handle the addition and removal of tables from the database, which would make the relevant changes to the source file.
I thought about wrapping dofile, but that would involve manually parsing out the code, which I'd rather leave to lua itself.
I'd be willing to help work on a library to support this. Sort of on the topic, had anyone been crazy enough to make an XML parser for lua?

Scott Rutledge

At 05:52 PM 26/02/2001 +0000, Nick Trout wrote:
Good day one and all. I was wondering if anyone had had any thoughts about treating Lua code as an object so that you can play with it and use it interactively. I think this was mentioned a while ago but nor followed up?
Off the top of my head... I was thinking of having a Lua class called "_Code". You make an instance of this and instead of using dofile() you call _Code:dofile() for things you want to keep, edit, recompile and save. When you use _Code:dofile(), it reads your file, parses it and executes it. The class remembers the source code of the code executed and if you want to edit something you can go to _Code and retrieve it. You then edit it and return it to _Code which executes it and can save it for you. _Code could also supply you with a table containing all the editable stuff available. Ergo, you have code editing mungojiggery. This could perhaps be a wrapper for the debug interface?
Any thoughts please?

Clothes make the man. Naked people have little or no influence on society.
Mark Twain (1835 - 1910)