Commit graph

1122 commits

Author SHA1 Message Date
Elvish_Hunter
bfcbe279a2 [harm_unit]: replaced .__cfg.level with .level in unit objects 2020-10-12 20:57:21 +02:00
Elvish_Hunter
61f7fe4749 [harm_unit]: fixed damage calculation for 1.15.x liminal alignment 2020-10-12 20:53:22 +02:00
gfgtdf
116687c983
fix #5184 [modify_unit]profile 2020-10-04 03:06:33 +02:00
Celtic Minstrel
251e6c3f7a Apply the deprecation standard to the new GUI2 API
This also removes backwards-compatibility.lua altogether.
It's no longer correct in the general case to add backwards compatibility code to this file, so removing it entirely avoids situations where compatibility code is incorrectly added there.

In the C++, this removes the commented-out old GUI2 API entries, and
adds show_dialog to the gui module directly instead of moving it in core.lua
2020-09-27 16:44:28 -04:00
gfgtdf
ebc65c9b00
fix [micro_ai] when called from lua
fixes #5134
2020-09-07 18:10:41 +02:00
gfgtdf
661fc1d8ef refactoor lua gui2 callback code
this refactors the lua gui2 callback c++ implementation
Now the callback infrastructure also supports different
types of callbacks for a single widget. Furthermore
it also supports multiple open gui2 dialogs at the same time.

This now also makes the widget parameter of widget.find
manditory.
2020-09-03 22:08:53 +02:00
gfgtdf
90a5930f21 new lua gui2 widget userdata
lua now has a widget userdata that can be used
to set/get widgets properties as one would
expect, a lot of the set/get_dialog_xy function
were converted into modifiable properties of
the widget userdata. This in particular allows
us to get rid of the strange 'path to widget'
type of arguments of gui2 functions.

It currently generates lot of compiler wanrings,
I will fix this in a later commit.

One of the main advantage is that it makes it
much easier to add new api, previously a lot
of functions where overused, probably because
that was just easier than creatign a new
function. For example set_dialog_value returned
multiple value of listbox objects. (the
compatibility path doesn't support this
particular feature yet but i don't think it is
important, it probably wasn't even used at all,
since it also wasn't documented).

This also adds some new features, like an 'add_item'
function to add an item to a listbox, a 'type'
property of widgets to query the type of a
widget and a 'item_count' property to count the
number of children in an item.

Im still not 100% sure about the
property /function names, in particular:

1) i might rename 'items' to 'elements' or
   'children' in some functions. Not sure yet
2) I might rename the 'value' property to
   'value_compat' to make clear that its only
   supposed to be used by the
   backwards_compat.lua code.

A next step in improving this api might be
to introduce a (reusable!) 'window' userdata
so that the implementaion of wesnoth.show_dialog
would become:
```
function wesnoth.show_dialog(wml, preshow, postshow)
  local dialog = gui.create_dialog(wml)
  preshow(dialog)
  local res = dialog:show()
  postshow(dialog)
  return res
end
```

However this is currently not really possble
since the pure existance of a gui2::window
object blocks the gui1 code (the main game view)
from receiving events. So we clearly cannot luas
gc take ownership of gui2::window objects.
2020-09-03 22:08:53 +02:00
gfgtdf
2a5ba5ace7 add wesnoth.interface.get_items
returns all items on a locations, this allows is to
remove quite a bit of code in the dropping.lua file
of world conquest since that can now just use items.lua
instead
2020-08-26 14:52:07 +02:00
gfgtdf
3df569ae74
fix missing chunk name in [lua] tags with no name= attribute
reported here https://forums.wesnoth.org/viewtopic.php?p=656867#p656867
2020-07-29 18:52:41 +02:00
Gunter Labes
9d673fac2a
Fix typo in deprecation message 2020-04-21 11:13:36 +02:00
Pentarctagon
a0d787d08e
Fix typo in deprecation message. 2020-04-19 11:58:22 -05:00
Pentarctagon
9a0b95f9a0 Separate unit test results from scenario victory/defeat.
This adds an additional `test_result` attribute to [endlevel], intended for use with the automated unit tests. This allows for the unit tests to differentiate a pass/fail result separately from scenario victory or defeat, which allows for more accurately determining the outcome of a test as well as addresses the potential, for example, for a scenario to be expect to pass because of the {SUCCEED} macro but instead passes because the scenario ended as a victory through some other method.

Additional unit tests which were the original motivation for this change are also added as part of this.  They test, as much as possible, that events are executed at all, and are then also executed in the expected order.
2020-04-07 16:45:34 -05:00
doofus-01
182a7bb602
Units - Dunefolk - Falconer branch of Skirmisher line (#4779)
* Units - Dunefolk - first draft at Falconer branch of skirmisher

* Dunefolk - revision to Falconer line

* Units - dunefolk - some progress on falconer standing animation

* Units - dunefolk - attack animations for falconer

* Units - dunefolk - defense and melee (partial) attack anims

* units - dunefolk - WIP lvl3 falconer

* units - dunefolk - revise falconer

* units - dunefolk - animation work on Falconer line

* units - dunefolk - falconer ability diversion revised to affect enemy chance-to-hit. Animation filter/trigger not yet resolved

* units/abilities - dunefolk falconer diversion ability-related animations mechanism

* units - dunefolk - sky_hunter animation frames

* dunefolk/abilities - fix diversion animations to work on die event

* abilities - schema validation induced correction

* abilities - diversion animations - attempt to fix case of undo movement

* units - dunefolk - finish some cosmetic issues for Falconer line

* units - dunefolk - wmlindent

* use on_undo over select in diversionability

undoing can only change the 'diversion' state if the original action also did,
so there is no reason to check it in all 'select' events.

* fixup

* minor clean-up

Co-authored-by: gfgtdf <daniel.gfgtdf@gmail.com>
2020-03-23 17:59:53 -07:00
Gunter Labes
5699db6117
Typo fix 2020-03-11 11:10:03 +01:00
gfgtdf
cd75931f7f
don't call error() on invalid toplevel tag
this code handles wesnoth.persistent_tags which is used by all addons. The previous behviour would mean that an addon that uses wesnoth.persistent_tags wrongly would also break other code that uses wesnoth.persistent_tags like the [item] implementation.
2020-03-08 00:04:25 +01:00
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
Celtic Minstrel
55fa2759a1 Fix the test_move_unit_in_circle test
Just needed to extract the unit earlier, so that it wouldn't be counted as blocking itself

Closes #4635
2019-12-14 12:12:29 -05: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
b8759f8c19 Add some additional cases to the move_unit test, and fix a few issues that they revealed
One of the cases fails due to something in find_vacant_tile - perhaps someone else can figure out how to fix this?

If nothing else, setting check_passability=no in the [move_unit] should do it, but I'd prefer not to have to do that...
2019-12-10 21:16:06 -05:00
Celtic Minstrel
cbd88814c3 Fix #4622 2019-12-09 22:12:39 -05:00
Celtic Minstrel
c366998021 Fix an issue with items and location sets
Fixes #4621
2019-12-07 17:21:03 -05: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
d66e957e1d Fix ilua's strict mode 2019-12-07 14:48:55 -05:00
Celtic Minstrel
29e11e7914 Lua functional library: make reduce accept an operator name in place of a function, add zip 2019-12-07 13:52:49 -05:00
Steve Cotton
4e92cc46ad Fix move_unit's parsing of to_x and to_y (fixes the unit-test timeout)
Also extend the unit test to at least check the end result of comma-separated
values, as there was previously nothing testing the effect of providing more
than one value.
2019-12-07 18:41:32 +01: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
7a1390adf7 Remove "wml-utils" require from files that no longer use it 2019-12-04 08:48:53 -05:00
Celtic Minstrel
f2f35cbd38 Fix broken [move_units]dir= 2019-12-04 08:46:22 -05:00
Celtic Minstrel
d9b5e3c4df Replace uses of wml_utils.split with stringx.split 2019-12-04 08:46:04 -05:00
Celtic Minstrel
31467d29d7 Deprecate wml_utils.split in favour of stringx.split 2019-12-04 08:09:51 -05:00
Celtic Minstrel
34cce96a58 Deprecate wml_utils.parenthetical_split in favour of stringx.split
There were no uses of this function in core Lua files.
2019-12-04 08:07:15 -05:00
Celtic Minstrel
4eb043bb16 Deprecate wml_utils.trim in favour of stringx.trim and update all use cases 2019-12-04 00:53:59 -05:00
Celtic Minstrel
e81a0377b0 Update uses of moved format functions 2019-12-04 00:50:00 -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
d5c1c9734f Fix the deprecated helper.set_wml_tag_metatable using a non-existent core table 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
74e004c265 Use a location set in the implementation of the item functions and WML tags 2019-12-01 22:30:31 -05:00
Celtic Minstrel
4b9f5d4485 Extend the location_set module to support set operators, custom index operators, and a tostring metamethod
Also adds set difference and symmetric difference functions, and a clone function.
2019-12-01 22:29:49 -05:00
Celtic Minstrel
9da5d4adfd fixup! Declare wesnoth.interface.remove_overlay directly instead of declaring it local and then assigning it
Missed updating the deprecation line and used the wrong new name
2019-12-01 21:50:56 -05:00
Celtic Minstrel
57bb4224b0 Declare wesnoth.interface.remove_overlay directly instead of declaring it local and then assigning it 2019-12-01 20:25:47 -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