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)
[objectives] now supports delayed_variable_substitution=yes, which means that any
$variables or [insert_tag] are processed when the objectives are shown, rather than
when they are set.
In addition, if $|variable syntax is used to delay substitution of a specific variable,
the variable will now be substituted when the objectives are shown, rather than
being left unsubstituted.
This is set up that there will be no newlines at the end of any section, unless you have
only a summary key, which no one would do. However, there will be a newline at the top of
the dialog if you don't have a win objective, but no one would do that either.
Note that because of newlines not showing up properly on Windows, this won't be viable
on that platform.
No deprecation needed since it defaulted to the 'default
objectives' already. They are used for a side in case that that side
doesn't have side specific objctives set. Use a SSF which matches
no sides or all sides to set the default objectives, if a subset
of all sides match, the side specific objectives for these are set.
In multiplayer, scenarios have default objectives sent from the host
to the other clients as [scenario]objectives= t_string, and this doesn't
know about silent= but must be shown anyway.
thonsew: The lua interface is not your playground. This is not the way
I want the lua files or its C++ interface to be modified. You are
invited to talk with me on IRC.
some of the main reasons:
-Your revisions contain lots of unneccessary changes, some of which
break existing lua or wml without a reason. Do you ever look at the
diffs?
-Your revisions pack a lot of unrelated stuff together into one.
2011-09-21T21:44:58Z!thonsew@yahoo.com makes sense in some parts and is what you should have
done in the first place.
1. Created a t_token metatable along with support code for indexing,
garbage collection, tostring, tonumber, comparison and concatenation.
2. Adjusted string comparison and lookup in lua code to work with
either t_token or string.
This addresses in part bug #18631, bug #18695. Before this lua was
treating all t_token as either tstrings or strings.