Testing WML actions more often without reloading cache
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Testing WML actions more often without reloading cache
WML development feedback loop is quite slow - you need to use F5, build new cache, start scenario again. When only looking to test one specific event or tag there is faster way.
Many WML tags are implemented in Lua now, and because of that Lua has all the tools needed to read and run WML. Note that macros or in general preprocessing of any kind is not supported with this way.
To make use of it create cfg file somewhere in your addon files. Fill it with for example
Then enable debug with :debug and either in Lua console run
You can also test events. When testing event it is useful to remove previous version of event before loading new version.
I hope you find this design useful.
Tags: hotpatching, wml injection, eventloader
Many WML tags are implemented in Lua now, and because of that Lua has all the tools needed to read and run WML. Note that macros or in general preprocessing of any kind is not supported with this way.
To make use of it create cfg file somewhere in your addon files. Fill it with for example
Code: Select all
[message]
message="message loaded during runtime"
[/message]
wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg"))
or run it as :lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/action.cfg"))
after updating path to refer to your file. You can also set it as alias: :alias e=lua wesnoth.require("wml-utils").handle_event_commands(wml.load("~add-ons/EventLoader/event.cfg"))
to then run it as :e
You can also test events. When testing event it is useful to remove previous version of event before loading new version.
Code: Select all
[remove_event]
id=Rav_EventLoader_Event_1
[/remove_event]
[event]
name=side_turn
first_time_only=no
# id is needed to not load multiple versions of event at once and to be able to remove it
id=Rav_EventLoader_Event_1
[lua]
code=<<
wesnoth.message("event 2 loaded")
>>
[/lua]
[/event]
Tags: hotpatching, wml injection, eventloader
Re: Testing WML actions more often without reloading cache
is it limited to WML tags which are already (re/)implemented in lua?
if so then will it ignore tags which are not implemented in lua? will these tags cause runtime error when running in this way or some other visible result?
also in which version of Wesnoth this was added?
author of: Altered Era/Ruleset (AKA "Altera"), latest version is on add-ons servers for BfW 1.16 and 1.14, latest version also still supports BfW 1.12 and 1.10, 1.10 server is stuck with older buggy version)
Re: Testing WML actions more often without reloading cache
This post was created with 1.16.0. It might work with earlier. I expect all ActionWML tags work. It does not matter if they are implemented in Lua or not.
But for example you cant load full [scenario] with this way.
But for example you cant load full [scenario] with this way.
- Celtic_Minstrel
- Developer
- Posts: 2323
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Testing WML actions more often without reloading cache
No. It's limited to ActionWML tags, but it doesn't matter whether they are implemented in Lua.
No.
No, they'll function normally.
Re: Testing WML actions more often without reloading cache
It might be useful to wrap wml.load in
wml.tovconfig
if there is interest to use $ variables.:alias e=lua wesnoth.require("wml-utils").handle_event_commands(wml.tovconfig(wml.load("~add-ons/EventLoader/event.cfg")))