- Move format_conjunct_list and format_disjunct_list
- Move wesnoth.format (renamed to vformat so as not to conflict with string.format); it's also available as tstr:format()
- Add stringx.trim
- The convenience wrappers of stringx.split now set the remove_empty and strip_space flags
The built-in string module is set as the metatable index for the stringx module, and the stringx module is set as the metatable index for strings, meaning all string and stringx methods are available through (''):method_name.
This also enables direct indexing of strings to get individual characters (ie ('str')[1] and the like), which package.lua already assumed even though it didn't work. Negative indices are supported to, and index from the end of the srring.
New functions:
- stringx.split
- stringx.parenthetical_split
- stringx.map_split
- stringx.escaped_split
- stringx.quoted_split
- stringx.anim_split
- stringx.join
- stringx.join_map
- New functions: wml.find_child, wml.attribute_count, wml.equal, wml.valid
- When converting a Lua table to WML, the engine will no longer accept invalid attributes
- Use of wml.tovconfig in plugin or map generation scripts is deprecated (it already doesn't quite work properly in those contexts but still could've been used as a way to test a table's validity as WML)
The old names still work but are deprecated.
In addition, all the moved functions now accept either a side number or a side userdata as the first parameter.
This reverts commit 51d6402453.
After discussion with @gfgtdf it was determined that this is not a useful feature after all, since it was in fact the default behaviour for the optimized path.
This means that they are now added to the interface module by default in C++, and only duplicated to the Wesnoth module in Lua.
Some additional functions were moved:
- wesnoth.scroll -> wesnoth.interface.scroll
- wesnoth.zoom -> wesnoth.interface.zoom
- wesnoth.get_mouseover_tile -> wesnoth.interface.get_hovered_hex
- wesnoth.color_adjust -> wesnoth.interface.color_adjust
- wesnoth.set_menu_item -> wesnoth.interface.set_menu_item
- wesnoth.clear_menu_item -> wesnoth.interface.clear_menu_item
Added wesnoth.units.get_hovered as an alias of wesnoth.interface.get_displayed_unit
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
This means that they are now added to the units module by default in C++, and only duplicated to the Wesnoth module in Lua.
Some additional functions were moved:
- wesnoth.create_unit -> wesnoth.units.create
- wesnoth.get_units -> wesnoth.units.find
- wesnoth.get_unit -> wesnoth.units.get
Deprecated wesnoth.get_recall_units in favour of wesnoth.get_units, which has gained the ability to match units on the recall list if x="recall" or y="recall" appears in the filter at toplevel.
The wesnoth.units module now acts like a metatable for unit userdata, meaning that any functions (or attributes) added to the module will be visible through any unit.