Commit graph

49 commits

Author SHA1 Message Date
Celtic Minstrel
3387eb2c26 Lua API: Plugins can now execute gamestate code once they are in the game context. 2024-10-07 08:42:42 -04:00
Celtic Minstrel
68105ed4cc Lua API: Add a new plugin module with some useful functions for plugins 2024-10-07 08:42:40 -04:00
newfrenchy83
feef53d4ab
Add an 'alignment' attribute to attacks
This attribute, when set to a valid value of lawful|neutral|chaotic|liminal, will assign to the weapon a different alignment than the unit alignment used by default. This alignment is then used when attacking with this weapon.

The attribute is not accessible from lua so far since the fallback to unit alignment does not work.
2024-09-23 17:11:46 +02: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
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
Toom
06350c9ad8 Update units.lua 2024-09-03 13:37:34 -04:00
gfgtdf
b8c6edc53c
Fix indices in widget.add_item_of_type()/add_item()/remove_items_at() (#8516)
- widget:add_item_of_type() now uses lua 1-based indicies and throws lua errors on wrong indicies. (previously used c++ 0-based indexing, and could lead to assertions when wrong indicies were used, )
- widget:add_item() now has a optional location pos parameter as claimed in the wiki
- the pos and count paraemters in widget:remove_items_at() are now optional and default to removing the last element

With this is matches the behavior of the standart lua functions table.insert and table.remove which is imo what lua writers expect.
2024-09-03 14:17:57 +02:00
Subhraman Sarkar
60640dc8bd Add lua function gui.switch_theme() to allow add-ons to switch themes in the middle of a scenario 2024-08-25 01:56:22 -04:00
Celtic Minstrel
8baf95601d [LuaDoc] Mark filesystem.asset_type as an enumerator 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
e92ee5cb1b [LuaDoc] Document that mapgen wesnoth.map.find[_in_radius] can take a uncompiled filter table.
Also note the split-location, single location, and list overloads for find_in_radius's center and find's in_list.
2024-07-21 19:58:03 -04:00
Celtic Minstrel
7aa5450a41 [Lua] Replace gui.show_inspector's undocumented config parameter with a string parameter that does the same thing.
It's still supported to pass a config, just in case anything relied on that.

This also updates the LuaDoc documentation at the same time.
2024-04-11 23:49:15 -04:00
Celtic Minstrel
d77f9ecbcc [LuaDoc] Use an alias for a sync function and declare every possible call form with @overload instead of specifying optional parameters 2024-02-29 09:16:40 -05:00
Celtic Minstrel
b7f9ccc197 [LuaDoc] Declare terrain_map index-by-location operator
Closes #8479
2024-02-29 09:15:40 -05:00
Celtic Minstrel
a2fdfaa7f7 [LuaDoc] Declare tstring to be concatenatable 2024-02-15 23:16:43 -05:00
Celtic Minstrel
8a42565447 [LuaDoc] Permit GUI widgets to have non-translatable labels, including numbers. 2024-02-13 19:29:21 -05:00
Celtic Minstrel
0bb93d39fc [LuaDoc] Add documentation for the map generator version of wesnoth.paths.find_path 2024-02-13 19:29:21 -05:00
Celtic Minstrel
b506010a8f [LuaDoc] Correct some dumb errors 2024-02-13 19:29:21 -05:00
Celtic Minstrel
12d95bc082 [LuaDoc] Undo handlers do not have a return value 2024-02-13 19:29:20 -05:00
Celtic Minstrel
966e813358 [LuaDoc] Add overload of terrain_mask taking the location as two integer arguments 2024-02-13 19:29:20 -05:00
Celtic Minstrel
877c94ddaa [LuaDoc] Fix hits parameter in animator:add and also accept a number as the text 2024-02-13 19:29:20 -05:00
Celtic Minstrel
d885687380 [LuaDoc] Instead of marking unit fields optional, define to_map and to_recall as taking WML as an alternative to a unit 2024-02-13 19:29:20 -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
dbae630acd [LuaDoc] Accept two-element lists as a location in some places, and 3-element lists as a colour 2024-02-13 19:29:19 -05:00
Celtic Minstrel
1885113264 [LuaDoc] Fix missing return type on format_*_list 2024-02-13 19:29:19 -05:00
Celtic Minstrel
2b05ed7339 [LuaDoc] Fix function signature for wesnoth.game_display 2024-02-07 22:10:33 -05:00
Celtic Minstrel
09c88d2b47 [LuaDoc] Fix typo 2024-02-07 22:10:33 -05:00
Celtic Minstrel
3276b9a36c [LuaDoc] Fix missing and incorrectly optional arguments to gui.widget.remove_items_at 2024-02-07 22:10:33 -05:00
Celtic Minstrel
ba3b00f3df [LuaDoc] Add a type alias for a compiled formula function 2024-02-06 22:21:09 -05:00
Celtic Minstrel
121f0a3cac [LuaDoc] Add unit.loc field 2024-02-06 19:04:02 -05:00
Celtic Minstrel
265aea7da4 [LuaDoc] Document the third element of the location triple returned from paths.find_reach 2024-02-06 19:04:01 -05:00
Celtic Minstrel
3a7bd26067 [LuaDoc] Document ndirs member of a directory listing 2024-02-06 19:04:01 -05:00
Celtic Minstrel
3bf903e2a4 [LuaDoc] Avoid "Missing required fields" warnings by annotating the fields as optional.
This is probably rather unfortunate in the case of the unit fields, as it may now interpret it as meaning the fields can be nil. We'll see if this causes issues.
2024-02-06 19:04:01 -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
2aa7d9357d [LuaDoc] Fix failure to detect that the string type's metatable was overridden
This isn't a generic solution, but at least makes all our built-in stringx methods work.
2024-02-06 19:04:00 -05:00
Celtic Minstrel
10d67aa82a Implement a new Lua API to the undo system 2023-10-14 19:26:36 -04:00
Ivo Julca
5ebc9a790a Implement event priority
For any given event name, events execute in order of decreasing priority.

Priority is a real number, and may be assigned via the `priority` attribute for
the WML [event] tag, or through the Lua APIs:

- wesnoth.game_events.add({priority = number})
- wesnoth.game_events.add_repeating(name, action, [priority])

Note that delayed variable substitution is not currently supported in the WML attribute.
2023-08-11 08:34:43 +02:00
Celtic Minstrel
cbbd34a79e
Add new attacks_used key to [attack] (#7351) 2023-02-04 19:55:04 +01:00
Celtic Minstrel
e482be048b Minor LuaDoc fix 2022-12-28 15:03:53 -05:00
Celtic Minstrel
6c30ef4b20 Document some missing map functions 2022-07-26 00:02:27 -04:00
Celtic Minstrel
22ad4d7137 A few missing details in wesnoth.game_events.add LuaDoc 2022-07-19 02:10:29 -04:00
Celtic Minstrel
8eb7a70a63 Add luadoc for the new event functions 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
Celtic Minstrel
e613010b4b Lua: Document wesnoth.units.teleport and wesnoth.units.create_weapon 2022-07-02 11:22:28 -04:00
Celtic Minstrel
e2875f34b2 Fix a bunch of luadoc errors 2022-06-11 00:15:18 -04:00
Celtic Minstrel
1c13b34bb6 Fix map methods not being detected 2022-06-10 23:47:43 -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
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