Commit graph

66 commits

Author SHA1 Message Date
mattsc
705b576c2a data/lua/core.lua: remove trailing white spaces 2019-12-19 07:06:02 -08:00
mattsc
a1de3a0d72 wesnoth.units.find_attack: also return attack index 2019-12-19 07:05:10 -08:00
jostephd
bb583c8e98
Merge pull request #4612 from jostephd/lua-deprecate_api-__index-__newindex-simplify
lua: Simplify the __index and __newindex wrappers in wesnoth.deprecate_api
2019-12-14 14:15:09 +00:00
josteph
1df045fba0 fixup! lua: Simplify the __index and __newindex wrappers in wesnoth.deprecate_api 2019-12-14 14:14:12 +00:00
Celtic Minstrel
e009989ec3 Fix some places that were erroneously calling string.format instead of stringx.vformat after 30240aa7cd
Fixes #4621
2019-12-07 17:21:03 -05:00
Celtic Minstrel
ee40ca2146 Lua uses nil, not null. Oops! 2019-12-07 17:21:03 -05:00
Celtic Minstrel
0b433d7ca1 Implement a Lua strict mode which eliminates all deprecated things
Note: At present the only way to enable this is by editing the core.lua file to add the line "wesnoth.strict = true".
2019-12-04 21:52:47 -05:00
Celtic Minstrel
9ae3be7386 Add stringx functions for parsing ranges 2019-12-04 08:55:17 -05:00
Celtic Minstrel
533206674a Deprecate wesnoth.wml_matches_filter 2019-12-04 00:47:29 -05:00
Celtic Minstrel
7ee7d6d47c Lua: More stuff for the stringx module
- 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
2019-12-04 00:45:36 -05:00
Celtic Minstrel
027be31826 Add wml.interpolate function for vconfig interpolation from a source other than the game variables
Unlike wml.tovconfig, this method works even in the plugin and map generation contexts.
2019-12-02 22:45:06 -05:00
Celtic Minstrel
11a57e0fa7 Move helper.find_attack -> wesnoth.units.find_attack 2019-12-02 22:39:34 -05:00
Celtic Minstrel
732b7942bb Replace all references to deprecated functions in the helper module
(and remove the require if this meant it was no longer used)
2019-12-02 01:10:34 -05:00
Celtic Minstrel
aa5ac6af29 Add stringx module that exposes Wesnoth's split/join functions to Lua
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
2019-12-01 20:25:13 -05:00
Celtic Minstrel
86f66a5825 Lua: Add a few more useful functions to the WML module and make WML table conversion a little more robust
- 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)
2019-12-01 20:25:13 -05:00
josteph
3ea5ee5f70 lua: Simplify the __index and __newindex wrappers in wesnoth.deprecate_api
Should fix one of the two issues discussed in #4584. See https://github.com/wesnoth/wesnoth/issues/4584#issuecomment-560029352
2019-12-01 06:08:33 +00:00
Celtic Minstrel
5a27cd5b1b Also correct the dperecation message regarding the previous commit
[ci skip]
2019-11-29 00:36:47 -05:00
Celtic Minstrel
c7e84f487c Correct old names for some deprecated (renamed) unit functions
Fixes #4608
2019-11-29 00:33:36 -05:00
Celtic Minstrel
859ab37254 Lua: Fix deprecate_api changing the behaviour of tables with an __index metamethod 2019-11-23 14:44:25 -05:00
Celtic Minstrel
930e39422a Lua side proxy now has starting_location member (replaces wesnoth.get_starting_location()) 2019-11-23 14:37:41 -05:00
Celtic Minstrel
153680400d Unify the Lua and WFL interfaces to the movement type
See changelog for details.
2019-11-23 00:59:36 -05:00
jostephd
4b3a7c0800
core.lua: Link to #4584 in a comment near the new warning 2019-11-22 19:19:53 +00:00
Celtic Minstrel
12bb52fd4e Warn if trying to deprecate a table whose metatable is masked 2019-11-17 14:23:58 -05:00
Celtic Minstrel
212a91113c Convert wesnoth.sides to a module and move several functions to it
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.
2019-11-17 11:35:56 -05:00
Celtic Minstrel
c27863b6f5 Alias wesnoth.interface.scroll_to_hex to wesnoth.units.scroll_to 2019-11-16 17:12:27 -05:00
Celtic Minstrel
498a3e98c4 Lua: Flip functions moved to the gui module
This means that they are now added to the gui module by default in C++, and only duplicated to the Wesnoth module in Lua.
2019-11-16 12:57:50 -05:00
Celtic Minstrel
f016ac7183 Lua: Flip functions moved to the interface module, as well as the theme_items table
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
2019-11-16 12:24:31 -05:00
Celtic Minstrel
aaa2dc4ece Rollback possibility of wesnoth.get_units matching recall list units
Now it's renamed to wesnoth.units.find_on_map.

wesnoth.units.find implements the case of finding units on either the map or a recall list.
2019-11-15 22:39:09 -05:00
Celtic Minstrel
6a87f5d48d Remove Lua implementation of wesnoth.units.find_on_recall
Since there's already a native C++ version we might as well just use it.
2019-11-15 22:39:08 -05:00
Celtic Minstrel
977f05d77f Lua: Replace uses of deprecated (moved) unit functions
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
2019-11-15 22:39:08 -05:00
Celtic Minstrel
4dc986f028 Lua: Flip functions moved to the units module
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.
2019-11-15 22:39:08 -05:00
Celtic Minstrel
36dc3200c5 Lua: Flip functions moved to the wml module
This means that they are now added to the WML module by default in C++, and only duplicated to the Wesnoth module in Lua.
2019-11-13 00:40:29 -05:00
josteph
21823d9332 Lua: Fix wesnoth.deprecate_api for the case of deprecating a table that had a metamethod other than __index/__newindex 2019-09-26 12:17:05 +00:00
josteph
56131f14c4 lua: Fix a bug when calling wesnoth.deprecate_api on a table that had a metatable.
The old metatable was used as the metatable of the new element's
metatable, which doesn't make any sense at all.

Fixes #4079
2019-09-26 12:17:05 +00:00
Jyrki Vesterinen
68f3a8e846 Lua fixes 2018-11-16 05:47:28 +02:00
Celtic Minstrel
6d7736e6e6 Deprecate helper.wml_error and move it to wml.error 2018-11-15 21:06:55 -05:00
Celtic Minstrel
8bcf749666 Lua API reorganization: units module deprecations 2018-11-15 21:06:55 -05:00
Celtic Minstrel
7c3fd9a612 Lua API reorganization: units module 2018-11-15 21:06:55 -05:00
Celtic Minstrel
3e79b3bde8 Lua API reorganization: GUI module deprecations 2018-11-15 21:06:55 -05:00
Celtic Minstrel
3ec9ce4b60 Lua API reorganization: GUI module 2018-11-15 21:06:55 -05:00
Celtic Minstrel
55a6c16810 Lua API reorganization: interface module deprecations 2018-11-15 21:06:55 -05:00
Celtic Minstrel
e3e80b4a99 Lua API reorganization: interface module 2018-11-15 21:06:55 -05:00
Celtic Minstrel
20e85aa417 Lua API: Add wml.load and wml.parse functions 2018-11-11 16:01:08 -05:00
mattsc
a0decde7b9 Lua code: replace deprecated wesnoth.get_all_vars() calls
(cherry-picked from commit 64f7ad2560)
2018-10-07 03:21:08 +00:00
mattsc
0e017d9f7c Lua code: replace deprecated wesnoth.set_variable() calls
(cherry-picked from commit ce7faae4f4)
2018-10-07 03:21:07 +00:00
mattsc
76ec65102c Prevent definition of wml.variables to cause deprecation warnings
(cherry-picked from commit 0f157bff27)
2018-10-07 03:21:07 +00:00
mattsc
05d5afa6a9 Lua code: replace deprecated wesnoth.get_variable() calls
(cherry-picked from commit f1764d182f)
2018-10-07 03:21:06 +00:00
Celtic Minstrel
83a6243fb9 Fix incorrect error message when encountering an unknown persistent tag
(cherry-picked from commit d2a8c5bb32)
2018-10-07 03:18:45 +00:00
Celtic Minstrel
5008c72a22
Fixup wml.all_variables 2018-03-18 01:38:39 -04:00
Celtic Minstrel
ddcbb4cb50 Add a more convenient way of registering custom saved game data 2018-03-17 17:16:22 -04:00