Difference between revisions of "UsefulWMLFragments"

From The Battle for Wesnoth Wiki
(Item Tools)
(RPG Tools: set_icon is now implemented)
 
(9 intermediate revisions by 5 users not shown)
Line 2: Line 2:
  
 
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.
 
Most of the things found here are macros (see [[PreprocessorRef]]) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.
 +
 +
Also, when creating or using macros, please remember: Every macro must generate a WML fragment which would be syntactically balanced and correct by itself. Unbalanced macros confuse our maintenance and sanity-checking tools, creating extra work and headaches for the already-overworked WML maintainers.
  
 
'''Note: some of the code here is outdated or otherwise poor. It's not advisable to blindly copy-paste code from here and expect it to work on recent Wesnoth versions or assume that the recent versions don't support a simpler and less hacky way of doing the same thing.'''
 
'''Note: some of the code here is outdated or otherwise poor. It's not advisable to blindly copy-paste code from here and expect it to work on recent Wesnoth versions or assume that the recent versions don't support a simpler and less hacky way of doing the same thing.'''
Line 14: Line 16:
 
=== Logic Structure Macros ===
 
=== Logic Structure Macros ===
 
*[[WML Utilities]]: Macros to assist other macros. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)
 
*[[WML Utilities]]: Macros to assist other macros. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)
 
=== Campaign Tools ===
 
*[[AlternateToDWML]]: Macros for alternate time-of-day schemes, including per-hour time-of-day.
 
  
 
==== RPG Tools ====
 
==== RPG Tools ====
 
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.
 
*[[A Shop Like Thing]]: How to add even more RPG elements to your scenarios.
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY from [[WML Utilities]]), move + exit to recall list, define character dialogue and a "main character", grant unlimited moves.
+
*[[CutsceneWML]]: Fixed MOVE_TO event (uses FIND_NEARBY from [[WML Utilities]]), move + exit to recall list, define character dialogue and a "main character", grant unlimited moves.*
  
 
==== Music Tools ====
 
==== Music Tools ====
Line 29: Line 28:
  
 
==== Item Tools ====
 
==== Item Tools ====
*[[DroppableItem]]: Macros to drop items. Currently only macros for dropping items on unit death including a permenant item that can be picked up, and dropped, multiple times by different units. Also a macro removing objects from units.
+
*[[DroppableItem]]: For placing items on the terrain upon death of a unit.
*[[Removing Items]]: A macro that removes objects from a unit.
 
  
 
==== Map Tools ====
 
==== Map Tools ====
Line 36: Line 34:
  
 
=== Advanced WML ===
 
=== Advanced WML ===
*[[Advanced WML]]: Store Reachable Locations.
+
*[[Advanced Optimisations and Hacks]]: If you're coding something really complex, this might come handy
 
 
=== Templates ===
 
*[[WML Templates]]: Generic campaign, scenario and unit templates. <b>Obsolete; most of these won't work right.</b>
 
  
 
== See Also ==
 
== See Also ==

Latest revision as of 13:27, 13 September 2022

Useful WML Fragments

Most of the things found here are macros (see PreprocessorRef) that must be copied into a scenario file or another file included first by the campaign, and then used in the scenario (or multiplayer map). Remember that a macro cannot be used at a point before it is defined.

Also, when creating or using macros, please remember: Every macro must generate a WML fragment which would be syntactically balanced and correct by itself. Unbalanced macros confuse our maintenance and sanity-checking tools, creating extra work and headaches for the already-overworked WML maintainers.

Note: some of the code here is outdated or otherwise poor. It's not advisable to blindly copy-paste code from here and expect it to work on recent Wesnoth versions or assume that the recent versions don't support a simpler and less hacky way of doing the same thing.

Some things not to do here:

  • Don't add macros that duplicate things in the core macro library.
  • Don't add macros that are trivial syntax shortcuts.
  • Don't add macros that generate unbalanced syntax fragments.

Try to avoid adding pages here. It is better to find a category in which your code fits and add it to that page.

Logic Structure Macros

  • WML Utilities: Macros to assist other macros. Overlay with Filter. Determine Opposite Coordinates. Find nearest hex(es)

RPG Tools

  • A Shop Like Thing: How to add even more RPG elements to your scenarios.
  • CutsceneWML: Fixed MOVE_TO event (uses FIND_NEARBY from WML Utilities), move + exit to recall list, define character dialogue and a "main character", grant unlimited moves.*

Music Tools

  • WML Musical Moods: Groups the Wesnoth music (as of 1.7.x) into "moods" and defines macros for playing randomly songs from these pools and for quickly switching music.

Unit Tools

Item Tools

  • DroppableItem: For placing items on the terrain upon death of a unit.

Map Tools

  • FloodWML: Macros to create a flood of a certain terrain type spreading across the map.

Advanced WML

See Also

This page was last edited on 13 September 2022, at 13:27.