Custom WML access

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
trickitiki
Posts: 8
Joined: May 31st, 2018, 3:14 pm

Custom WML access

Post by trickitiki » November 3rd, 2018, 8:36 am

Hallo. Does API for addons allows to read some random tags? Hmm, wat i'm trying to say... For example, may i create some custom file with proper tag structure but using totally unknown (new) tag names and then read it from script? Thanks.

User avatar
Pentarctagon
Forum Administrator
Posts: 3623
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Custom WML access

Post by Pentarctagon » November 3rd, 2018, 8:49 am

99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

Tad_Carlucci
Developer
Posts: 327
Joined: April 24th, 2016, 4:18 pm

Re: Custom WML access

Post by Tad_Carlucci » November 3rd, 2018, 2:54 pm

This is actually a Lua question. Moved.
I forked real life and now I'm getting merge conflicts.

User avatar
Celtic_Minstrel
Developer
Posts: 1275
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Custom WML access

Post by Celtic_Minstrel » November 9th, 2018, 4:07 am

The answer to this as stated is no. The Lua API provides no direct access to the WML parser. It wouldn't be particularly difficult to add it, though, so I've opened #3696 on the topic.

If what you want is specifically custom tags in scenarios, then what you need is wesnoth.wml_actions, wesnoth.wml_conditions, wesnoth.effects, wesnoth.persistent_tags, or wesnoth.custom_synced_commands, depending on your specific needs.
  • wml_actions defines new tags that can be used as actions within an [event] or [command] tag.
  • wml_conditions defines new tags that can be used as a condition in an [if] or [filter_condition] tag as well as other similar tags.
  • effects defines new valid values of apply_to in an [effect] tag, which can parse the remaining contents of the tag however it wants.
  • persistent_tags defines new tags that are valid directly inside the [scenario] tag; though usually used for saving data in the saved game (which also contains a [scenario] tag internally), tags so defined can also be placed deliberately in a scenario.
  • custom_synced_commands defines custom commands that can be executed by the AI or a [do_command] tag. I'm not sure if this is documented yet, but you can check out an example use in Son of the Black Eye for loading units onto transport ships.
There's also the "global variable" framework documented at PersistenceWML, which does end up creating a WML file with arbitrary tags somewhere in the preferences folder, though I suspect this probably isn't quite what you're looking for.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Post Reply