WML Optimizations
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.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
WML Optimizations
Hi all, so I came across a post when I was looking up LUA vs WML. I came across the term WML Optimizations and I was just wondering what are some things you can do optimize your wml to help make loading and running things a little smoother.
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: WML Optimizations
If a particular feature needs optimizing, it will often be reworked in later versions of Wesnoth; so a major trick is to have a good knowledge of the mainline campaigns, and to look at the 1.14 and 1.15 campaign WML for doing what you intend to do.
The Wiki's UsefulWMLFragments has many outdated examples, along with comments about what made them obsolete. The changelog entries for development versions (1.11.x, 1.13.x) give some hints about the new features available in 1.12.x and 1.14.x.
The Wiki's UsefulWMLFragments has many outdated examples, along with comments about what made them obsolete. The changelog entries for development versions (1.11.x, 1.13.x) give some hints about the new features available in 1.12.x and 1.14.x.
Re: WML Optimizations
It depends on your use case a lot. For first loading time it helps to have single-file addon instead of many files.
It is also useful to review your preprocessed WML and check if there are large duplicated fragments which should not be there.
Usually loops are faster in Lua.
It is also useful to review your preprocessed WML and check if there are large duplicated fragments which should not be there.
Usually loops are faster in Lua.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: WML Optimizations
I actually didn't know that.... I have my current add-on loading at least 25-30 cfgs... probably closer to 50...
im not sure i quite follow preprocessed. Could you explain a little about that? Currently i have a lot of things loading in the prestart even and if you click too much then wesnoth will crash. is it something along those lines? Also do duplicated events slow things down? because i have a lot of turn counters going for various purposes and instead of searching through over 15k lines of wml that ive been scripting for this addon over the last 2 years, i just make a new one...
yea i think i want to start learning lua but i just keep getting confused everytime i look at it in files or try to read the wiki on it...
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: WML Optimizations
First point is not important until it gets to thousands of files.
You can find wesnoth cache folder, and unpack the files until you find your addon. It is close enough to what you would get by preprocessing it yourself with wesnoth -p.
You can find wesnoth cache folder, and unpack the files until you find your addon. It is close enough to what you would get by preprocessing it yourself with wesnoth -p.
- LordAwsomeness
- Posts: 203
- Joined: August 12th, 2013, 2:20 pm
- Location: U.S.A.
Re: WML Optimizations
As in literally thousands of files? Or figuratively?
What's preprocessing?
- Been playing Wesnoth since 2004 and the 1.0.x versions.
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
- Creator of Undead Invasion MP Scenario Pack.
- Creator of Valeria MP Adventure
- Creator of LA_RPG ERA
Re: WML Optimizations
Literally thousands, it provided massive benefit for ageless some years ago. Nowadays I do not bother with it, I asked for higher time limit instead.
Effect is that wesnoth only needs to read one file instead of thousands - each file access takes time.
Preprocessing is expanding macros and files into one WML document. In https://github.com/wesnoth/wesnoth/issues/4698 I have basic guide how to preprocess addon.
Effect is that wesnoth only needs to read one file instead of thousands - each file access takes time.
Preprocessing is expanding macros and files into one WML document. In https://github.com/wesnoth/wesnoth/issues/4698 I have basic guide how to preprocess addon.