Commit graph

739 commits

Author SHA1 Message Date
Celtic Minstrel
ddcbb4cb50 Add a more convenient way of registering custom saved game data 2018-03-17 17:16:22 -04:00
Celtic Minstrel
68d545c3be Add a couple more WML utility functions 2018-03-17 16:48:06 -04:00
Celtic Minstrel
d4e08359dd Fix missing return in on_event() 2018-03-17 16:48:04 -04:00
Celtic Minstrel
e776635023 Clear up redundancies in helper compatibility and deprecate the array functions 2018-03-17 16:48:03 -04:00
Celtic Minstrel
4b08a40181 Deprecate wesnoth.set_music 2018-03-17 16:48:02 -04:00
Celtic Minstrel
6e4d09d2a5 Bump up a couple of deprecation levels at @vultraz's request 2018-03-17 16:48:01 -04:00
Celtic Minstrel
08ec9017b5 Lua API: Some tweaks of the experimental wml module 2018-03-17 16:48:00 -04:00
Celtic Minstrel
23aac4f72f Cleanup of fef953a48e
- Fix the rabbit AI
- Enable invoke_synced_command to also call (some) built-in commands
  and give an error message in the case of an unknown command
- Remove some unnecessary implementation details
2018-03-17 16:48:00 -04:00
Charles Dang
134353f863 Further cleanup of deprecated Lua API usecases (inc. ones from fef953a)
[ci skip]
2018-03-17 00:41:32 +11:00
gfgtdf
fef953a48e remove ai.synced_command
fixes #1649 . ai.synced_command could easily be used to implement all types of
undeteced cheats so it was removed. As a replacement this commit adds a
[custom_command] synced command that just calls
wesnoth.game_events.on_synced_command which calls a lua handler that
must first be set.
2018-03-16 13:43:05 +01:00
Charles Dang
0103959c36 Cleaned up deprecated API usage in core Lua
[ci skip]
2018-03-13 16:55:36 +11:00
Charles Dang
471c9e876a Addressed a large chunk of the whitespace issues from #2613
[ci skip]
2018-03-09 11:37:00 +11:00
Charles Dang
3489dac642 [heal_unit]: don't play healed animation if no healing is done
[ci skip]

Addresses #2530. Not closing that though, since the behavior might still be tweaked.

The healer will still play their own animation, if applicable (behavior option 2 in
the bug report).
2018-03-05 15:44:42 +11:00
Celtic Minstrel
f4b031b7ac fixup [deprecated_messag] 2018-03-04 22:03:17 -05:00
Celtic Minstrel
aa0a3bebd1 Add suffix= and prefix= operations to [set_variable] 2018-03-04 22:03:16 -05:00
Celtic Minstrel
1e2512a672 Honour the regular deprecation message settings for WML deprecation messages 2018-03-04 21:21:33 -05:00
Celtic Minstrel
5fc9d8d173 Use new deprecated_message() function wherever possible (C++)
This also covers handling of legacy DescriptionWML for [set_menu_item],
and tweaks its handling in the other cases (mainly [multiplayer_side]).

I added the next_dev_version constant intending to use it, but then
decided not to do so; however I left it in in case someone finds it useful.
2018-03-04 21:21:33 -05:00
Celtic Minstrel
dabf09fce1 Fix deprecation spam
This removes the Lua deprecation_message function in favour of exposing the C++ variant to Lua instead.
It also moves all deprecation messages to a separate logdomain, making them easily enabled en masse.
2018-03-04 21:21:33 -05:00
Celtic Minstrel
29942eec35 Expose side_name attribute to Lua API and [modify_side] 2018-02-18 12:53:00 -05:00
Celtic Minstrel
3440546f2d Some fixes to the Lua deprecation API, and extend it to C++
* Some improvements to the messages
* Don't clobber existing metatables on deprecated subtables
* Fix Lua deprecation messages not even being logged
* Fix deprecation of Lua subtables
* Don't clobber the metatable when deprecating a subtable
2018-02-12 00:09:48 -05:00
Matthias Krüger
dc33cf7ceb pofix: add fixes of previous commits. 2018-02-06 23:03:06 +11:00
Matthias Krüger
b11d3fdcbe fix a bunch of typos found by codespell in data directory.
https://github.com/lucasdemarchi/codespell
2018-02-06 23:03:06 +11:00
Celtic Minstrel
4b58a52140
Shouldn't have the same __metatable for two metatables 2018-02-06 00:15:22 -05:00
Charles Dang
5134033e30 Name __metatable for wml.variables
[ci skip]
2018-02-06 16:10:29 +11:00
Charles Dang
c8abb8d5d9 Add formula= option to [set_variable] (change by @celticminstrel)
[ci skip]
2018-02-02 15:40:44 +11:00
vgaming
728204665c fix code problems found by luacheck (#2388)
fix code problems found by luacheck

Second iteration of the process, now handling data/lua/wml/*.lua

luacheck command used to find bugs:
  luacheck ./*.lua --globals wesnoth wml --codes --ignore 542 213
Additionally, error code 211 (unused variables) could be ignored,
as using underscore convention `_` is controversial in
wesnoth ( see https://github.com/wesnoth/wesnoth/pull/2380#discussion_r162519341 )

Actual bugs found:
* items.lua, access of global `write_name` instead of local `cfg.write_name`
* kill.lua, typo `primary_unit` -> `primary`
* bad code style: global `i` instead of local `i`
  (would conflict with 3-rd party code if it would use global `i`, too)
2018-01-23 13:35:04 -06:00
Charles Dang
da3a0ed7cf Added [lua] conditional tag
Also made conditions fail if they encountered a syntax or runtime error. This seems the
more logical behavior than passing.

WML conditional tags were split into their own Lua file. The one in lua/wml/object.lua
relies on local variables so was left there.
2018-01-22 23:03:16 +11:00
vgaming
8ba6e5f40e fix code problems found by luacheck (#2380)
actual bugs found:
* backwards_compatibility.lua (undeclared global "helper")
* core.lua (use of undeclared global "helper")
* wml_tags.transform_unit had wrong code to deal with recall_cost
* wrong variable name in cave_map_generator
2018-01-20 23:05:58 -05:00
V N
5209271db3 Lua: add variables metatable
The implementation differs from already-existing
wml.variable.proxy in that it does not try to proxy table sub-fields,
and is fast & simple.

Example usage:
wml.variables.test = 123
print(wml.variables.test)
2018-01-19 09:53:06 +11:00
Jyrki Vesterinen
d81f230680 Clear unit death animation after killing the unit
This is another and much better way to fix the unit halo remaining.
2017-12-28 12:02:29 +02:00
Jyrki Vesterinen
f50c7d3f2a Revert "Work around unit halo not disappearing with [kill] animate=yes"
This reverts commit 70b468070b.

As I said in the commit message, the fix is not pretty, and
@CelticMinstrel said in IRC that a different fix would definitely be
better. I'll fix the problem by having an animation automatically
release the unit when done, instead (next commit).
2017-12-28 11:48:12 +02:00
Jyrki Vesterinen
70b468070b Work around unit halo not disappearing with [kill] animate=yes
The problem was that the kill animation retained a reference to the unit.
Triggering a Lua garbage collection (which destroys the animation object)
fixes it, although it's definitely not a pretty fix.

Closes pull request #2313.
2017-12-25 18:35:01 +02:00
Jyrki Vesterinen
e0e59ac463 Fix exception when [harm_unit] is used without an attacking unit
Regression from commit 38e31aa61f.
In particular, it broke WML unit tests.
2017-12-21 20:24:48 +02:00
Gregory A Lundberg
38e31aa61f Do not access non-existent unit
The [kill] tag can run animations. But it can also fire the `last breath` event, which can call [kill]. When we get back to the original [kill], the unit is gone, causing an error attempting to run the animations.

Added a check to ensure the unit is still on the map before we attempt to run the animations.

The Issue also requested that [harm_unit] pass the unit causing the harm into the [kill] tag so that `last breath` could use the secondary (killing) unit available like it does elsewhere.

Closes #2298
2017-12-19 15:05:24 -06:00
Jyrki Vesterinen
f064f50f1b [heal_unit]: Turn on floating text with animate=yes
I also moved the animation to be played *before* healing, which is the same
order as in C++ code. In the previous order, the animation isn't played for
some reason.

Fixes #2295.
2017-12-18 23:28:45 +02:00
Jyrki Vesterinen
d80d47eb8a [heal_unit]: fix wrong value of "hits" parameter
Only "hit", "miss" and "kill" are allowed.
2017-12-18 22:04:35 +02:00
sigurdfdragon
23c23b7a55 WML: Add [show_if] usage in [objectives] subtag [gold_carryover] 2017-11-22 20:27:13 -05:00
gfgtdf
fcf8272abf
fix bug in feeding code
wesnoth.current.event_context might not contain all information if the die event was triggered by wml ([fire_event]), this made wesnoth.get_unit error (invalid argument)
2017-11-11 13:50:35 +01:00
Jyrki Vesterinen
3b5880f5fb Fix #1980: [modify_unit] makes the unit disappear for a frame or two
Regression from commit d40a9e930b.

In that commit I removed a redraw after the death animation of a killed
unit has been played, but just to be safe, I then added a redraw after the
unit has been erased from the map. Turns out it's not a good idea because
[modify_unit] operates by killing and recreating the unit.

This commit simply removes the redraw after erasing. Hopefully we aren't
relying on [kill] triggering a redraw somewhere.

[ci skip]
2017-09-12 21:36:40 +03:00
Jyrki Vesterinen
d40a9e930b Fix [kill]ed units flashing briefly after death animation 2017-09-08 21:54:03 +03:00
Celtic Minstrel
00443dd8a4 Fixup d192d0712393 and move wesnoth.debug() to lua_kernel_base 2017-08-14 13:10:52 -04:00
Celtic Minstrel
c734f56922 Update the DEPRECATED macro and [deprecated_message] ActionWML to understand deprecation levels 2017-08-14 12:36:10 -04:00
Celtic Minstrel
d192f07123 Implement standard deprecation system for Lua API
(as proposed by @DeFender1031)

All existing deprecation messages in the Lua code have been changed to
use the new deprecation system.

The goal is to eventually use an equivalent system for ALL areas of the API.
2017-08-14 12:36:09 -04:00
Smok94
e4552c7a75 [store_unit_defense] tag
Stores in variable the defense of a unit on a particular terrain. If terrain is not specified, the terrain on which the units currently stands is used. (Note: it is a WML defense, so the higher it is, the weaker unit's defense is.)

* StandardUnitFilter
* loc_x, loc_y: x and y of terrain location.
* terrain: alternatively, the character of terrain.
* variable: the name of the variable into which to store the defense. default: "terrain_defense"
2017-07-29 11:34:54 +11:00
gfgtdf
821e27c34f add [cancel_action] implements #1427
this adds a new tag [cancel_action], it currently only has an effect in
move actions. It can be used in enter_hex/exit_hex events to abort the
current movement. It can also be used in moveto events where is
cancels possible following attacks (if the user issued a move+attack
action).

This also changes the behaviour of moveto and enter/exit_hex event so
that they now no longer cancel the movement automatically, also
[allow_undo] no longer has an effect on whether the move is cancelled,
it now only allows undoing of the move.
2017-07-25 21:19:05 +02:00
Celtic Minstrel
9015d9b57d Merge pull request #1806 from wesnoth/wfl_filters
Use WFL formulas instead of Lua for leadership, backstab, and teleport abilities
2017-06-25 00:45:00 -04:00
Gregory A Lundberg
468f07364e Bug in [for] missing step
https://forums.wesnoth.org/viewtopic.php?t=46450 reports a Lua crash if end is given but step is not. The wiki says the default step is 1. Note that if end is negative, the [for] does nothing (per sniity check).
2017-06-21 20:45:21 -05:00
Celtic Minstrel
5109a36b56 Revert use of Lua for teleport, leadership, and backstab 2017-06-18 11:40:15 -04:00
gfgtdf
2498036c4d fixup 70a23cdf83 2017-06-14 13:57:29 +02:00
gfgtdf
70a23cdf83 remove variable substitution from leadership and backstab abilities 2017-06-13 23:22:06 +02:00