Compatibility-breaking WML and Lua syntax changes

The place to post your WML questions and answers.

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.
Post Reply
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Compatibility-breaking WML and Lua syntax changes

Post by Anonymissimus »

This is the thread for changes from 1.10.x to 1.11.x/1.12.x. The thread for changes from 1.8.x to 1.10.x is here.

  • path.length created by [find_path] was renamed to path.hexes to avoid confusion about getting the length of "path" in the usual way (if no path is found, length/hexes is 0, but path.length would still return 1 since the array path isn't empty)
  • Switching difficulty levels during an ongoing campaign can cause all sorts of errors. Either make sure that your campaign supports the new feature or disable it with "allow_difficulty_change=no" in the [campaign] tag. For instance, someone may create a certain unit only on the HARD difficulty. The player switches to NORMAL difficulty and then plays a scenario, whose code now relies on that unit not being around. This could make code which should handle that unit not being executed.
  • [gold][filter_side] and [modify_ai][filter_side] are deprecated, use their new "inline" SSF.
  • [filter_vision] in SUFs:
    • viewing_side= -> side=
    • The behavior for an empty filter changes from "all enemy sides" to "all sides" must see it for a match. You may use the introduced SSF's [enemy_of] or team_name= features. A wmllint patch may be used (see if you know how to do that.
  • [object]duration=level -> [object]duration=scenario
  • The cost of a recruit/recall is now deducted before, not after, the corresponding recruit/recall event. (The deduction is still after the prerecruit/prerecall event, though.)
  • Inactive names and descriptions for abilities and weapon specials now default to the active version. If for some reason you wanted an ability/special to be only displayed when active, you'll need to explicitly set name_inactive to an empty string (nothing after the equals sign).
  • There was an undocumented convention of having the first line of ability / weapon special descriptions be the name of the ability/special followed by a colon. This convention is deprecated; descriptions should now be just descriptions.
  • A small change to [effect]apply_to=defense: when not replacing values, positive numbers always make a unit easier to hit, while negative numbers make it harder to hit. There is no longer a special case due to units having negative defense values (e.g. horsemen in a forest).
  • AI aspects [target], [protect_unit], [protect_location], protect_leader=, protect_leader_radius= are deprecated, use [goal] instead. In addition, [goal]protect_my_unit= is deprecated, use [goal]protect_unit= instead.
  • Removed support for the deprecated "colour=", "debug_border_colour=", and [colour_adjust].
  • Removed support for the deprecated [removeitem].
  • WML variable turn_number is set correctly (to 1) in prestart and start events. Previously, it retained its last value from the previous scenario until after the start event.
  • As the nozoc variant of the unit ellipse is chosen automatically when necessary, ellipse="misc/ellipse-nozoc" has to be removed from unit types.
If your addon doesn't use Lua, just ignore this section.
  • Wesnoth's embedded Lua library was upgraded from Lua 5.1 to Lua 5.2. This means some functions from the standard libraries will no longer work or not as expected. We don't yet know whether there will be any deprecation warnings. Changes are listed here. (Only the "Changes in the Libraries" section is important for add-on authors with Lua scripts in their add-ons.)
  • The following functions are deprecated and will probably be removed before 1.12:
    get_side, get_side_count (use wesnoth.sides)
    get_unit_type_ids, get_unit_type (use wesnoth.unit_types)
    register_wml_action (directly write into wesnoth.wml_actions)
  • The wesnoth.transform_unit() function now preserves hit points instead of healing the transformed unit, and it removes poison if the transformed unit is immune (both of which make it more consistent with wml_actions.transform_unit). If a full heal is desired, a call to wesnoth.transform_unit() can be followed with a statement like unit.hitpoints = unit.max_hitpoints.
Please let's keep the thread clean. If you have moderator powers, you are welcome to edit/update this post for new changes.

EDIT: Added 3 items to the WML list. -zookeeper
Added 1 item to the WML list. - aquileia
Post Reply