Commit graph

1093 commits

Author SHA1 Message Date
Celtic Minstrel
7e234f8833 Replace deprecated usages of on_event() 2022-07-18 21:56:42 -04:00
Celtic Minstrel
5a184bbb40 Split wesnoth.game_events.add into multiple functions
Basically this means each of the call modes of the old function is now a separate function.

- add_repeating and add_menu take an ID and a function
- add_wml takes variable substitution setting and a config
- add takes the full options table
2022-07-18 21:56:42 -04:00
Celtic Minstrel
19c62a083e Update [remove_event] to use new API 2022-07-18 21:56:42 -04:00
Celtic Minstrel
8aa2ee74a2 Move the event firing functions to wesnoth.game_events
* These functions take the full event data config as the final argument, rather than just the weapon info subconfigs.
* The [fire_event] tag now supports a [data] tag that can add additional data to the event, for example damage_inflicted. The [primary_attack]  and [secondary_attack] tags are still supported and are not deprecated.
* wesnoth.current.event_context now has a data child which holds the full event data. It still duplicates common info (weapons and damage inflicted) in the same way as before.
2022-07-18 21:56:42 -04:00
Celtic Minstrel
8cd1332630 Enable setting an arbitrary Lua function as an event handler.
Unlike the old wesnoth.game_events.on_event hook and the "convenient" on_event() wrapper for it, this new functionality supports all of the features of WML events, with the sole exception of serialization, since it's not possible to reliably serialize a Lua function.

This commit also divorces menu items from the event that they trigger. The undocumented wesnoth.interface.set_menu_item function no longer adds an event for the menu item; the caller needs to separately register an event using the new functionality.
2022-07-18 21:56:42 -04:00
Tommy
8144c06389
Add new [screen_fade] WML action (#6864)
* Add new [screen_fade] WML action

It takes (for now) the arguments:
 * red, green, blue = values between 0 and 255
 * alpha = value between 0 and 255
 * duration = time in ms over which to fade

The game display is faded to the given colour over the duration.
It will be left with an overlay of that colour and alpha until
a screen_fade to 0 alpha is performed.
2022-07-15 09:32:19 -04:00
larry_the_cow
8d91bc69a2 [harm_unit] fix secondary_attack animation 2022-06-27 23:17:31 -04:00
Celtic Minstrel
1af084515f Exclude deprecated things from dir() 2022-06-20 20:54:28 -04:00
Celtic Minstrel
d104a81269 Lua API: Make the WML module dir-friendly 2022-06-20 20:54:28 -04:00
Celtic Minstrel
e2875f34b2 Fix a bunch of luadoc errors 2022-06-11 00:15:18 -04:00
Celtic Minstrel
e635161957 fix wesnoth.type giving an error on tables or userdata without a metatable 2022-06-10 23:31:41 -04:00
Celtic Minstrel
a76aa9bddc
Add wesnoth.interface.add_floating_label as a replacement for wesnoth.print (#5837)
This returns a label handle which allows you to remove, reposition, or replace the label later.

In addition to all the features of wesnoth.print, you can now specify where the label appears onscreen, as well as a fadeout time separate from the duration.

You can also anchor the text to an edge or corner instead of centering in on the screen,
specify the maximum width it can occupy as an absolute width or a percentage,
and specify a background colour and transparency.

It includes a demo scenario that demonstrates many of the capabilities of the API.
To play the demo scenario, run with -toverlay_text_demo or select it from the in-game test list.
2022-04-10 13:00:29 -04:00
Celtic Minstrel
14865d0afd Lua: Fix incorrect check for string type 2022-02-17 13:49:01 -05:00
Celtic Minstrel
e518fe622b Lua: Fix a deprecation warning in the hex reference API 2022-02-17 13:48:58 -05:00
Celtic Minstrel
e1300e29b0
Lua API: Add inline documentation for pretty much everything and convert existing docs (#6483)
The new format is EmmyLua-based and can be used with (at least) Visual Studio Code.
2022-02-17 13:43:31 -05:00
Elvish_Hunter
608a2bf85e Improved variable setting in [heal_unit] and [harm_unit] 2022-01-16 13:13:52 +01:00
Steve Cotton
eacf26a2a8 Fix [store_unit]'s stored coordinates for recalls
Units on the recall list might have x,y coordinates that are on the map, which
therefore need to be replaced with "recall,recall" within [store_unit]. The
existing code created a temporary variable, changed the coordinates, and then
returned the unchanged original instead of the temporary.

Add a new test that `[put_to_recall_list]` followed by `[modify_unit]`
doesn't move the unit back to the map.

(cherry picked from commit 096d8aba14)
2022-01-12 06:57:35 +01:00
Steve Cotton
2afc7f80bd Fixup 5b18f2df4 (trailing whitespace) 2022-01-09 07:35:39 +01:00
Elvish_Hunter
5b18f2df4c Fixed broken gui.get_user_choice() 2022-01-08 22:29:56 +01:00
Luther
bff219d41f
Expand the reduce function to both fold and reduce (#6337) 2021-12-04 17:46:12 -05: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
Steve Cotton
69ee817955
Remove the fast path of [modify_unit] (#6223)
Always use the "slow path", because it stores and unstores the unit, triggering
the desired side effects of unstoring a unit.

Fixes issue #5133, and tests that with the new unit test.

Fixes bug #4978, that changing the facing wasn't updating the display.

This corresponds to 1.16's commit 13c5d8a96e,
that commit merely disabled the fast path to be a minimal change.
2021-11-05 21:39:38 +01:00
Celtic Minstrel
73983c7032 Lua: Fix nil-safety issues in location_set
Fixes #6231

(cherry picked from commit 1f32466782)
2021-10-29 11:56:43 +11:00
Celtic Minstrel
4ab4b64ed7 Fix color_adjust requiring all keys
Fixes #6191
2021-10-18 03:07:25 +02:00
Celtic Minstrel
98b91c9d0f AI: [micro_ai]side= can now take a list
Closes #6023
2021-09-04 22:20:28 -04:00
Celtic Minstrel
ff6894cee8 Lua API: Add a wesnoth.type() function
This checks both the Lua type and the metatable type to return a single unified result.
2021-09-04 22:20:28 -04:00
Celtic Minstrel
e9465fa03e Lua API: Add alternative version of map function to be used on arrays 2021-09-04 22:20:28 -04:00
Celtic Minstrel
b22c3b595c Lua API: Fix functional.map returning the wrong answer if used on a table that contains numeric keys but is not strictly an array 2021-09-04 22:20:28 -04:00
Celtic Minstrel
bedc25fb56 Lua API: location_set:to_pairs now returns named tuples 2021-09-04 22:20:28 -04:00
Celtic Minstrel
35fce3fa3b Lua API: Fix an error in the terrain hex API
Attempting to access a non-string key was an error.
2021-09-04 22:20:28 -04:00
Celtic Minstrel
4837452dd7 Lua API: Add new location_set function to convert to or from a Lua map
This enables a location set to be passed to map functions in the functional module.
2021-09-04 22:20:28 -04:00
Celtic Minstrel
440dbbd0ad Lua API: The value function is now optional in functional.choose[_map]
By default, the functions now use the value taken directly from the map or array.
In addition, if a string or other non-functional value is passed, it's used as a key on the value.
2021-09-04 22:20:28 -04:00
Celtic Minstrel
2c040ecaa7 Lua: Fix console pretty-print output not showing zero or negative keys in tables 2021-09-04 22:20:28 -04:00
Celtic Minstrel
9daa10a9f2
Lua: Fix deprecated end_text references in core 2021-08-23 09:22:08 -04:00
Celtic Minstrel
23bfa4c896 fix whitespace 2021-07-30 19:22:57 -04:00
Celtic Minstrel
44da16d66a Lua API: Use the new location_set complement in the place_shroud deprecation wrapper 2021-07-30 19:22:57 -04:00
Celtic Minstrel
300b4492b8 Lua API: Ensure unit test assertions specify a message string 2021-07-30 19:22:57 -04:00
Celtic Minstrel
08e3a31979 Lua API: When creating a location set from triples, also support tables with x, y, and value keys 2021-07-30 19:22:57 -04:00
Celtic Minstrel
c59c3b9273 Lua API: Use a named tuple when converting a location set to triples 2021-07-30 19:22:57 -04:00
Celtic Minstrel
7d7b58e31e Lua API: Add an absolute complement option to location_set
- ls:invert(w,h,[border_size]) takes an absolute complement as if the map were the given size
- ls:invert(map) takes an absolute complement relative to the specified map
- ~ls is only available in the game kernel and takes an absolute complement relative to the real map
2021-07-30 19:22:57 -04:00
Celtic Minstrel
eb1bd1af6c Lua API: Add wesnoth.map.filter_tags for the mapgen kernel
This was supposed to be added for 1.16, but it was forgotten; anyone wishing to use it in 1.16 will have to copy it from World Conquest.
2021-07-30 19:22:57 -04:00
Celtic Minstrel
5951a63d3e Lua API: Fix wesnoth.map.find(filter, unit) ignoring the unit 2021-07-30 19:22:57 -04:00
Celtic Minstrel
858f37e20e Lua API: Fix the deprecation wrappers for place_shroud and remove_shroud
- The "all" special case moved to place_shroud, as it should be
- Shroud data string handling fixed

Fixes #5885
2021-07-30 19:22:57 -04:00
Celtic Minstrel
30a3619202 Lua API: Fix bug in wesnoth.map.iter_adjacent
Fixes #5972
2021-07-30 19:22:57 -04:00
Celtic Minstrel
5f450542f5 WFL/Lua: Add lerp and clamp functions 2021-07-30 19:22:57 -04:00
Celtic Minstrel
284f7149e3 WML API: [story]title= is now optional even in ActionWML
Make it default to the scenario name, as it would for scenario-level [story].
2021-07-13 14:10:07 -04:00
Celtic Minstrel
82a98fd96e Lua API: Revive mp_settings.active_mods and mp_settings.era_id
These were removed without deprecation in 0efd35acbc
This adds them back as deprecated.

Fixes #5941
2021-07-13 14:10:07 -04:00
Celtic Minstrel
aed779fb6a Lua API: Deprecate the helper.lua module itself 2021-07-07 01:32:05 -04:00
Celtic Minstrel
4ec60b99d9 Lua: Update all mainline references to the helper module 2021-07-07 01:32:05 -04:00
Celtic Minstrel
8b05449bbc Lua API: Deprecate helper.set_wml_action_metatable
wml.fire now supports the same syntax - both of the following work:

- wml.fire("message", {message = "Hello World"})
- wml.fire.message{message = "Hello World"}
2021-07-07 01:32:05 -04:00