13 Apr, 2009, Dark Gryphon wrote in the 1st comment:
Votes: 0
This is my LamaMUD Core Design Document. It is severely incomplete, and probably requires a lot more explaining.

——

The msg() function

msg("attack", somemob);


msg() is our main message interface. Using msg, we can move all text completely seperate from the code. It is also used in Bot Mode - the system that is used by NPCs to react to events. So, the example above would output something like "You attack <somemob.name>" if not in Bot Mode, but it would run a hook like:
hooks["msg"].run("attack", somemob)

if it is in Bot Mode.

——

The hooks table

hooks["cmd"].run("say", "Hello", "World");


The hooks table is our main modularization effort. Essentially, whenever something interesting happens, a hook is supposed to be called. Multiple hooks can be added to a single hook name if desired. hooks["anything"] is always defined, thanks to a metatable. To add a hook:
function hook_example()
print "Example!";
return nil; #Continue running hooks - return any other value to stop running hooks
end
hooks["example"].add(hook_example);


——

The log server

logserv.log("trade", otherplayer, "Gave:\n1 gold coin\n\nRecieved:\n1 piece of bread");


The log server allows the game to log player events easily, and the administrators to browse through these using a simple interface, based on Regular Expressions. The point is to use it as an anti-cheating device - log everything that could be used to prove that a player did/did not cheat.

——

Classes

foo = new(bar);


Classes allow the game to classify tables using a simple interface. For example, all items are subclasses of the class abstract_item. Classes are implemented with some pretty mean metatables.

——

The objects database

objects.save("players[\"Dark Gryphon\"]", player);

player = objects.load("players[\"Dark Gryphon\"]")


The objects database is how almost all data is stored. It will probably be implemented in C. All objects are referenced by a Lua-compliant name. Also, the object is added to parent objects automatically - so I can do:
players = objects.load("players")
player = players["Dark Gryphon"]


Note that the objects database is very limited in what it can save. It can save classes, tables, strings, numbers, booleans, and nil as values, and it can save strings, numbers, booleans, and nil as keys. Specifically, it cannot save functions or userdata.

There is also a problem with pointing to other data - for example, player X has a Dragon Sword in his hand. Therefore, the ptr metatype was created - this works exactly like the original data, except that it can be detected by the objects.save code, which outputs a <ptr>name</ptr> tag. Also, if the data isn't in memory, it will automatically load it from database. Create a ptr by using the function objects.newptr(name[, obj]). Remember to explicitly save anything that is pointed to by a ptr!
03 Jul, 2009, David Haley wrote in the 2nd comment:
Votes: 0
This is interesting stuff and I'm exploring many of the same issues. Is there any news here?

I implemented a (presently single-inheritiance only) class system that also makes heavy use of metatables, which I think makes life a lot easier.

I like the idea of having generic event types that AIs can react to – my main worry is how simple or complex to make those event types. It seems like you might need a fairly complex set of events to be able to both (a) send useful messages to the player and (b) let the AI react accordingly.

This is a 100% Lua base, right? Another thing I'm having all kinds of fun with is poking at the segregation between things on the Lua side and then things on the C++ side…
0.0/2