[crossfire] Client-side scripting

Nicolas Weeger (Laposte) nicolas.weeger at laposte.net
Sat Aug 26 12:27:52 CDT 2006


Hello.

I would like to enhance client-side scripting with a LUA engine, and before 
potentially applying my changes I'd like to discuss that, and reply to 
objections.
Note I don't plan on trashing current scripting system, just on adding 
things :)


My rationale is to have at least one common scripting language for all clients 
versions (those using the common library, at least).

My choice of LUA was based on the following requirements:
* small footprint - we don't want client to grow really too big
* no external dependencies required once client is built - imo it's ok to 
require to install Python for running a server, but it isn't nice to do that 
for the client.
* available on many platforms - LUA seems portable enough
* some base libraries - LUA has enough for the uses I see (string, files, ...)
* syntax not too exotic (ok, that's totally subjective, but i don't feel like 
doing scripts in LISP ^_-)

LUA also offers an object layer, to write player.hp instead of gethp() hp or 
something like that.


I'm sure it isn't the only language matching that :)
Simply LUA is the one I used.


My implementation choice is to rely on function names to know what to call.
For instance a script having an "event_stats" function will have it called 
each time the client gets some stats from the server. Script is responsible 
to check what changed.
Scripts will have all player's information, including inventory, items on 
ground and visible faces on map, available already (global objects).
As current scripting, it'll be possible to watch commands sent by the player, 
and received from the server.


My current proof-of-concept has the basic things ready: player info, 
inventory, ground. The rest isn't hard to do (maybe to debug), but since it 
takes some time I'd rather wait i'm sure there won't be an angry mob trying 
to trash me if I commit :)


Nicolas



More information about the crossfire mailing list