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)
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.
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
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)
I chose 2560x1440 as the size over 1920x1080 simply because when I tried both sizes at compression levels that produced a similar quality result, the difference in filesize was negligible.
As players who haven't figured out certain strategies might have too much
trouble beating the third repetition. Also waiting until the fourth
repetition may be too long and have players question what's going on.
Bug was that a troll on 4,21 could move through the avoid area to attack
player at 11,22 which is a likely occurrence. Expanding the avoid area
further seems inappropriate as troll avoidance is more likely to be noticed.
New implementation ensures only player will trigger the wose, maintains
proper look to the player, no longer interferes with trolls attacking, and
simplifies code.
This reverts commit 70b468070b71616aa3663088b6ad171391d0c4f0.
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).
He's been a silver-crowned hero until this scenario, and in
the final scenario he's still loyal with dialogue if he dies,
so make him easily visible to the player.
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.
Note that this still doesn't allow the --upload
functionality to work. After this fix,
wesnoth still complaints about unordered WML.
It is believed that this is a separate issue though,
happened because of the latest simple_wml changes.
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
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.
NE and SE base/standing frames. Defending and pincer-ing animations for both NE- and SE-facing frames. Stinger animation for SE-facing frames. Portrait replaced.