Hi,

After being summoned on #wesnoth-dev a few days ago, I decided to take
a look at the forums and I noticed the "Why not LUA?" topic there. I
did get to experiment with Lua when reimplementing the server of TMW.
(All the NPCs/quests of this MMORPG are now coded in Lua, as its
coroutines make it trivial for non-coders to avoid state machines.)
While Wesnoth does not require coroutines, the Lua language was
sufficiently welcomed by TMW designers so that I feel Wesnoth could
benefit from it too. Due to some social/political events today, I was
stuck at home a part of the day, so I decided to give it a try.

See https://gna.org/patch/index.php?1120 for a proof of concept.

This patch implements a [lua] tag that can used as an event action.

What is working:
- firing WML events from Lua,
- translation/localization of strings in Lua code.

What I haven't tested:
- loading a savegame containing Lua; not sure how garbled the embedded
code will get.

What is missing:
- a way to query about things, e.g. the unit at a given position,
- a way to have persistent data across save/load and to share
variables between Lua and WML (there is already a way in fact since
communications work both ways between Lua and WML, but it is too ugly
for words),
- lots of actions other than just firing events (which means either
copy-pasting game_events.cpp or factoring the code),
- other places where to put Lua code, for instance inside filters.

I intend to work a bit more on the patch, in particular the "query"
and "variable sharing" parts. But I wouldn't mind some early feedback
on the approach of embedding Lua code inside WML.

Best regards,

Guillaume

_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to