Commit graph

1093 commits

Author SHA1 Message Date
Celtic Minstrel
7a83817989 [Lua] Remove nonexistent parameter 2024-02-26 13:19:55 -05:00
Celtic Minstrel
3ac99d1d86 [Lua] Fix missing parameter warning when passing empty filter 2024-02-26 13:19:55 -05:00
Celtic Minstrel
7f5c687196 [Lua] Avoid reusing no-longer-needed variables for different meanings
This raises Lua warnings about mismatched types
2024-02-26 13:19:55 -05:00
Celtic Minstrel
a9e4a3cce8 [Lua] Fix call of nonexistent function 2024-02-26 13:19:55 -05:00
Celtic Minstrel
b506010a8f [LuaDoc] Correct some dumb errors 2024-02-13 19:29:21 -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
f9c7336f1a [LuaDoc] Document location_set operators 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
Steve Cotton
6b516e8aa5 Fix deprecation warning when setting [endlevel]end_credits=
Change the Lua implementation to directly call the
non-deprecated function, this is related to 9daa10a9f2.

Clean up the C++ header files by removing the declarations of
functions that were removed in 3c8de46771.

Use [endlevel]end_credits=no in the test scenario (trigger it
by moving to hex 9,3). If you debug with :next_level without
triggering the moveto, "The End" will show; trigger the moveto
first, and it won't show the credits.
2024-02-02 16:04:27 +01:00
Toom
2056be55a3
Support [harm_unit]experience values kill/attack/defend/fight/yes/no (#8231) 2024-01-18 11:32:18 +01:00
gfgtdf
955a8bc445
use game_events.add in on_event.lua (#8082)
use game_events.add in on_event.lua

previously on_event.lua and game_events.add had separate priority lists, so that independent of the priority parameter (which both game_events.add and on_event.lua now support) on_event.lua events were always executed first. 

The set_undoable(true) call is there to match the previous behavior of on_event.lua where events implemented via on_event were undoable by default.
The higher default priority of 0.5 is there to match the previous behavior of on_event.lua where events implemented via on_event.lua were always run before wml events.
2023-12-15 21:28:45 +01:00
Gunter Labes
8b111a2a76 Avoid accessing data of potentially killed unit
Fixes #8019.
2023-11-12 22:12:17 +01: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
857d7e120a Undeprecate on_event() for now 2023-10-14 19:26:36 -04:00
Celtic Minstrel
38ae304725 Move Lua undo API into experimental 2023-10-14 19:26:36 -04:00
Celtic Minstrel
10d67aa82a Implement a new Lua API to the undo system 2023-10-14 19:26:36 -04:00
Jonathan-Kelly
14c7382675
Add range support for [micro_ai]side= (#7853) 2023-08-18 20:04:05 -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
Toom
9f53c4fd11
fail if [kill] contains [filter], re #4316 (#7717) 2023-07-16 19:47:44 +02:00
Gunter Labes
639fb7158e
Remove obsolete comment 2023-06-13 10:46:15 +02:00
Pentarctagon
ad3f1c95b0 Add support for distinct sub-achievements.
This adds support for having up to 28 distinct sub-achievements within a single achievement. This limit exists since wesnoth's layout isn't smart enough to tell a horizontal listbox to actually use its scrollbar instead of forcing a horizontal scrollbar on the whole window.

Additionally this adds the [set_sub_achievement] and [has_sub_achievement] WML tags and their respective lua functions. [has_sub_achievement] is unsafe for use in MP, for the same reasons that [has_achievement] is.
2023-05-17 23:54:16 -05:00
Celtic Minstrel
d4adbdcf91 Fix [clear_variable] not working on a variable name that happens to be a number 2023-05-09 23:10:26 -04:00
Celtic Minstrel
f7fadba928 Fix compatibility path for helper.set_wml_var_metatable 2023-05-07 14:56:55 -04:00
Severin Glöckner
90df947efe stun: chaneg textdomain
other abilities are in wesnoth-help
the dirdctory containing the files is searched for wesnoth-help
2023-04-15 02:40:17 +02:00
Toranks
2de929e026
Typo hander > handler (#7464) 2023-03-20 19:36:52 -05:00
Pentarctagon
e61fca0bf4
Small achievements cleanup (#7368)
* Move logic into lua engine code.
* Don't let use of limit decrease an achievement's progress.
2023-02-09 18:36:45 -06:00
Pentarctagon
18838ecebc Give a better warning when amount isn't a number. 2023-02-05 09:42:35 -06:00
Steve Cotton
0a0263e54f Support [foreach]array=this_item, nested loops using the default name
Since a0ee38a49, the inner this_item was still in scope when the inner loop
writes changed data back to the outer loop's variable, which meant that
changes were silently ignored.

A lot of the changes in wml-flow.lua are just indentation because of the
extra block.
2023-02-05 04:34:23 +01:00
Steve Cotton
49ebbb9709 Make fix_whitespace complain about mixing tabs and spaces
Ensures that files either use tabs for indentation or spaces for indentation,
but don't switch between the two within the same file.

This doesn't fix the whitespace, it's a simple check to flag it up
on the assumption that it's better to use an editor or code formatter
to clean up the file.

Elsewhere in the CI we use the luacheck tool - while that can detect
mixing tabs and spaces in a single line's indent, it doesn't check for
inconsistent indentation within a file.
2023-02-05 02:22:53 +01:00
Pentarctagon
e3bb346b39 Add functionality for achievements to be partially complete.
Instead of being either complete or incomplete, achievements can now specify a value at which they will be considered complete. For such achievements that are not yet complete, a progress bar is added to the achievements dialog showing how close to completion the achievement is.
2023-02-04 15:43:28 -06:00
Celtic Minstrel
cc40d5c55b
Move the Merman Citizen and Brawler units to core (#7323) 2023-01-26 22:45:29 -05:00
Pentarctagon
d1465a9eb9
Add basic achievements functionality. (#7237)
* Add basic achievements functionality.

This reads the mainline achievements.cfg and then all the achievements of each installed add-on.

This is intentionally handled separately from other WML loading so that:
a) All achievements and their status are able to be displayed on the main menu right after Wesnoth starts and regardless of which add-ons are active.
b) Add-ons can add additional achievements to other content, whether UMC or mainline. For example, a modification that adds more achievements for mainline campaigns.

Marking something as achieved is handled by the new [set_achieved] tag and whether an achievement has been completed can be checked via [has_achievement].

There is no attempt to prevent people from manually editing which achievements they've accomplished.

NOTE: These are *not* in any way related to Steam achievements!
2023-01-21 10:32:45 -06:00
Celtic Minstrel
7d5fa80180
WML: Adjust the weapon selection logic for [kill] (#7196)
* WML: Adjust the weapon selection logic for [kill]

The previous logic simply did not make sense, especially for the secondary weapon.
For example, it would ignore the secondary weapon specification if the primary weapon was not found on the secondary unit, which does not make any sense.

The cases that this changes are:
- There is a secondary unit and a primary attack, but no matching attack was found. Previously it would use the default, now it pretends that attack exists.
- There is a secondary attack specified, but no primary attack, either because it was unspecified or because it didn't match any attack on the secondary unit

In both these cases, the animation runs as if a matching attack exists, rather than using no attack and choosing the default animation.

Adjust the log level too.
2022-12-24 16:52:57 +01:00
Celtic Minstrel
6d3dd6a175 Support as_type=weapon in [variable]formula= 2022-12-06 01:52:38 -05:00
Celtic Minstrel
6876695e66 Support as_type=unit in [variable]formula= 2022-11-27 13:12:47 -05:00
Celtic Minstrel
516f043e89 Support name= in [lua] ConditionalWML 2022-11-27 13:10:41 -05:00
Steve Cotton
e3deff8bfd Make undo work again, undeprecate on_event()
Fixes #6898. The issue is that non-WML events added through the new events API
always disable undo with no equivalent of WML's `[allow_undo]`. The long-term
fix is to add a way to do that; however until that's available then listeners
for `moveto` need to use the old `on_event` API. The old `on_event` API can't
be deprecated yet, and this is enforced by our unit tests (the build fails if
there are unexpected deprecation warnings during the tests).

Reverts most of 7e234f8833. Does not revert files
that only listen for non-undoable events such as `die` or `new turn`.

Reverts the deprecation part of #5663's 8cd1332630.
2022-11-19 05:23:30 +01:00
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
Pentarctagon
a5e7986b3e Updates for newer luacheck. 2022-08-06 03:03:17 -05:00
Wedge009
461fd5fff5 Replace deprecated wesnoth.fire_event with wesnoth.game_events.fire. 2022-07-30 16:32:31 +10:00
Celtic Minstrel
0f3d8388df Fix deprecation warning in [kill]
Fixes #6924
2022-07-29 23:37:36 -04:00
Tommy
3127178e17 Add a submerge value to items, to control submerge amount
It defaults to 0, which is no submersion.
2022-07-30 14:56:38 +12:00
Celtic Minstrel
e08451517a Fixup some event deprecations
No functionality change, just documentation
2022-07-26 00:08:00 -04:00