[crossfire] Client-side LUA support

Nicolas Weeger nicolas.weeger at laposte.net
Sat Feb 10 12:27:47 CST 2007


Hello.

I just committed to trunk patch #1560052: LUA client-side support, which has 
been sitting there for some time.

From the description:

Support is basic for now: scripts can intercept user
commands, emit messages and commands, and react to stat
change (hp, gr, ...). Look at example file to see how
it works. Function to react to stats change is
'event_stats'.

When running, the LUA script has access to three variables:
* player: contains the player's sp, hp, gr, food (as
player.sp)
* ground: array containing the items on the spot the
player is
* inv: array containing the player's inventory
and 2 functions:
* cfdraw: write a message to player (red only for now)
* cfissue: simulates player sending a command. Use is
generall cfissue( 1, 1, "xxx" ), for isntance cfissue(
1, 1, "apply bed of reality" )


known issues:
* will only work with LUA 5.0.2, NOT 5.1 (init
functions changed, check the commented functions)
* you can load the same file multiple times




As a side note, number of C-defined functions is checked by the code itself, 
and can vary, so compatibility (adding color to cfdraw) isn't an issue.

If some autoconf wizard could add a conditional switch to enable/disable that 
script, that would be great :)
(for now it's always built)

Nicolas
-- 
http://nicolas.weeger.free.fr [Petit site d'images, de textes, de code, bref 
de l'aléatoire !]



More information about the crossfire mailing list