Commit graph

25 commits

Author SHA1 Message Date
Severin Glöckner
640c08b7f5 Lua: crash peacefully with [move_unit]
If there is an issue with to_x or to_y, such as a missmatching number of values, or none,
then the function is aborted by the 2nd/3rd wml.error statement.

At that place, current_unit:extract() was already called, so the function
would not only fail, but also remove the unit.

This commit unstores the unit prior to aborting.
The alternative of extracting the unit later would break the tests,
as it is then still using the hex, which is then not available to pathfinding.
2022-10-26 23:32:10 -05:00
Severin Glöckner
a748126b75 Lua: don't trigger unit placed events by WML tags
If the last argument to the C++ function ( game_lua_kernel::intf_put_unit )
is false, event's won't be fired.

closes #5158
2022-10-26 23:32:10 -05:00
Wedge009
461fd5fff5 Replace deprecated wesnoth.fire_event with wesnoth.game_events.fire. 2022-07-30 16:32:31 +10:00
Pentarctagon
370d03ccb7 Fix luacheck warnings and add to CI.
Note the `exclude_files` in .luacheckrc should be deleted once the eventual Ubuntu 22.04 base image has an updated luacheck that supports lua 5.4.
2021-11-28 14:26:02 -06:00
Celtic Minstrel
91f6bf93a4 Fix a broken deprecation and replace some deprecated uses
Fixes #5877
2021-06-20 00:59:59 -04:00
Celtic Minstrel
7f162cbd24 Lua: Rename find_vacant_tile to find_vacant_hex for naming consistency 2021-06-19 17:09:31 -04:00
Hejnewar
16c8fcc49c Remove remaining uses of wesnoth.special_locations 2021-05-10 11:26:12 +02:00
Pentarctagon
d203b061f9
Whitespace cleanup of lua files. 2021-04-25 15:11:09 -05:00
Celtic Minstrel
a2d7a26365
Fix several Lua issues, mostly unintentional globals (#5587) 2021-03-06 17:01:53 -05: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
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
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
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
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
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
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
3735b9c4f2 Add [move_unit]clear_shroud= as an attempt to clear shroud as the unit moves (untested)
(cherry-picked from commit b062b19e10)
2018-10-07 03:19:06 +00:00
Celtic Minstrel
c5b5bdda70 Allow [move_unit]dir= to perform relative movements
(cherry-picked from commit 68b33cf6bd)
2018-10-07 03:19:06 +00:00
Celtic Minstrel
4ce00c6b6c Allow [move_unit]to_location to take a list of waypoints
(cherry-picked from commit 622db9d08b)
2018-10-07 03:19:06 +00:00
Celtic Minstrel
c023f7b222 Fix typo in 1dd411a84e
(cherry-picked from commit 4427ee1936)
2018-10-07 03:18:18 +00:00
Celtic Minstrel
02b6987158 Support to_location in [move_unit]
(cherry-picked from commit 1dd411a84e)
2018-10-07 03:18:13 +00:00
Charles Dang
0103959c36 Cleaned up deprecated API usage in core Lua
[ci skip]
2018-03-13 16:55:36 +11:00
Celtic Minstrel
e1233fd0f2 Split several of the larger WML tags into their own file 2017-05-03 02:43:22 -04:00