// Called when a connection is made
on connection(conn)
{
conn.sendDialogOk("Welcome to BUNNY WORLD!");
local char = null;
while ( char == null )
{
local name = conn.promptText("Select your character name: ('quit' to cancel)");
//local name = "Fred";
if ( name == "quit" )
{
conn.sendText("server: Goodbye!");
conn.disconnect();
return;
}
char = LoadCharacter(name, conn);
// Success?
if ( char != null )
break;
// No: report failure and try again
conn.sendText("Sorry, you can't have the name '" + name + "'");
}
RegisterNewCharacter(conn, char);
}
// Called when ch is created
on create_character(ch, conn)
{
ch.setHp(100);
ch.setMaxHp(100);
//// Prompt the player for an avatar
//ch.setAvatar( conn.promptText("Pick an avatar:") );
// Default the character to a duck - they're sent to the avatar picking room
ch.setAvatar( "duck.gif" );
// OK, all done, woot woot
}
// Called when ch first spawns
on spawn_player(ch)
{
// Stick the character in the default starting room
local room = GetRoom("BunnyWorld/AvatarRoom");
ch.moveToRoom(room);
}
on takeoff(ch)
{
local planet = ch.promptPlanetId();
ch.moveToPlanet( GetPlanet(planet) );
}
A linked list works fine, just need to store the nesting level in each token, so when an if check is false you skip tokens till the level drops back to the current level. Instead of skipping tokens you can add a pointer to the next valid token, which would create a tree. If you know the number of tokens in advance (or as part of the optimization process) it's probably faster to use an array, and for additional speed you can use index numbers instead of pointers to jump ahead.
I think you may be getting ahead to the final output, which could be a bytecode stream. In some simple languages, like assembler, nothing more than a simple transform is required. Most higher level languages, require more complex parsing and the intermediate representation of an AST is much more flexible and amenable to analysis of the code.
COOL is a cleaned up better version of MOO. I guess you might call it MOO 2.0 ColdC would be MOO 3.5 COOL is probably as functional as LPC, but without all the nice supporting library routines that LPMuds have built up over the years. I don't know how they'd compare to Lola.