Commit graph

121 commits

Author SHA1 Message Date
Celtic Minstrel
ab022c09ae Lua API: Add unit:rebuild
Fixes #9314
2024-09-15 15:27:39 -04:00
Celtic Minstrel
6d8a17aa8d Lua API: Add mathx.lerp_index and wesnoth.game_config.palettes 2024-09-15 15:27:39 -04:00
Celtic Minstrel
fc86cb0b93 WFL: Add replace_all, starts_with, and ends_with string functions.
The latter two are also added to the Lua stringx module.
2024-09-15 15:27:39 -04:00
Celtic Minstrel
2a26a68025 Some updates to Lua map location operations
* Rename the vector operations to hex_vector (to emphasize that they are NOT standard vector ops) and document them as official API
* Add new get_hexes_at_radius, which returns an unfilled ring (as opposed to get_hexes_in_radius which returns a filled circle)
* Expose the new cubic coordinate conversions
2024-09-15 15:27:39 -04:00
Celtic Minstrel
8baf95601d [LuaDoc] Mark filesystem.asset_type as an enumerator 2024-08-13 08:54:04 -04:00
Celtic Minstrel
faaeaadaa1 [Lua] Avoid missing field warning by reversing the order of the check 2024-08-13 08:54:04 -04:00
Celtic Minstrel
542581916f [Lua] Suppress some diagnostics and also recommend suppressing certain diagnostics globally 2024-08-13 08:54:04 -04:00
Celtic Minstrel
a9948d3fff [Lua.MapGen] Accept both comma-separated lists and arrays for f.adjacent 2024-07-21 19:58:03 -04:00
Celtic Minstrel
19f3682bdf [Lua.Mapgen] Add a few more ways to pass a location set to f.find_in
These may be less efficient in some cases, and there's even a couple of degenerate cases, but it's definitely easier to use like this.

This also adds an example of the original method, using a string to reference a separate list.
2024-07-21 19:58:03 -04:00
Celtic Minstrel
a72ec39f79 [Lua] Make f.is_loc work either with a location object or with separate x,y parameters 2024-07-21 19:58:03 -04:00
Celtic Minstrel
95bfd07286 [Lua.MapGen] Exposed previously-unused wesnoth.map.filter_tags.onborder filter since it seems useful 2024-07-21 19:58:03 -04:00
Celtic Minstrel
ab008161f1 [Lua.MapGen] Add wesnoth.map.filter_tags.formula that takes a WFL formula to match against locations 2024-07-21 19:58:03 -04:00
Celtic Minstrel
f5c4f2e841 [Lua] Update obsolete usage of [1],[2] to refer to a tag's name and contents 2024-05-19 12:54:35 -04:00
Celtic Minstrel
d734bfb9e2 [Lua] Make wesnoth.read_location return its result in standard named tuple format 2024-04-11 23:48:21 -04:00
Celtic Minstrel
bb3c95ebbc [Lua] Remove nonexistent parameter 2024-02-26 13:24:38 -05:00
Celtic Minstrel
4b5a8e25e8 [LuaDoc] Suppress some diagnostics 2024-02-13 19:29:21 -05:00
Celtic Minstrel
6145c48d35 [LuaDoc] Fix incorrect declaration of unit.variables and side.variables - make them consistent with wml.variables 2024-02-13 19:29:20 -05:00
Celtic Minstrel
e644613cae [LuaDoc] mathx.random_choice can return nil if the input list is empty 2024-02-06 19:04:02 -05:00
Celtic Minstrel
a38e67da45 [LuaDoc] Title is optional for alert/confirm 2024-02-06 19:04:02 -05:00
Celtic Minstrel
c7741907c2 [LuaDoc] Fix several errors in the inline documentation 2024-02-06 19:04:00 -05:00
Celtic Minstrel
5a51a309a4 [LuaDoc] Fix several minor errors in the specification of API 2024-02-06 19:04:00 -05:00
Celtic Minstrel
e3b3d08c3f Make wesnoth.allow_undo still work, even though it was explicitly internal and not meant to be used.
Fixes #8018
2023-11-04 22:40:18 -04:00
Celtic Minstrel
9183ee6791 Move the other game_events deprecations into the game_events file 2023-10-15 17:43:22 -04:00
Celtic Minstrel
38ae304725 Move Lua undo API into experimental 2023-10-14 19:26:36 -04:00
Celtic Minstrel
d05bc6e444
Update filesystem.lua (typo) 2023-07-23 11:58:21 -04:00
Celtic Minstrel
46ac2ff1de
Update filesystem.lua
The new include_file directive uses the "scenarios" directory as the asset type, so add it to `filesystem.asset_type`.
2023-07-23 11:58:02 -04:00
Toranks
2de929e026
Typo hander > handler (#7464) 2023-03-20 19:36:52 -05:00
Celtic Minstrel
e08451517a Fixup some event deprecations
No functionality change, just documentation
2022-07-26 00:08:00 -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
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
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
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
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
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
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
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
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