Commit graph

15 commits

Author SHA1 Message Date
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
Celtic Minstrel
2c040ecaa7 Lua: Fix console pretty-print output not showing zero or negative keys in tables 2021-09-04 22:20:28 -04:00
Celtic Minstrel
d66e957e1d Fix ilua's strict mode 2019-12-07 14:48:55 -05:00
Celtic Minstrel
981fa93a40 Make ilua output iterable userdata as tables
This means anything with __len and __pairs metamethods.
2019-11-17 14:23:59 -05:00
Celtic Minstrel
ece5490fd9 Improve ilua's table output for tables that have both an array part and additional keys
Previously for such tables it would just show the array part and ignore the rest.
2019-11-17 14:23:59 -05:00
Celtic Minstrel
d53ac4b496 Fix ilua not honouring __tostring functions for tables
This gives ilua full access to the debug module so that it can determine whether the table's metatable contains __tostring
2019-11-17 14:23:59 -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
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
Celtic Minstrel
2f15a08b78 Add a Lua file for things to be automatically loaded by the engine in all contexts 2017-05-04 20:17:00 -04:00
Chris Beck
748f872091 lua: make it easier to disable strict mode global variables
After this commit, the "strict mode" lua variable errors may be
disabled with

  ilua.strict = false

and reenabled with

  ilua.strict = true

There will typically be no noticeable performance difference from
previously to this commit.

This is a bit simpler than the other methods described which
include using pcall or resetting the metatable of _G.
2015-01-05 14:58:09 -05:00
Chris Beck
017050df70 ilua: eliminate the "_" holds last executed command feature
the ilua `_pretty_print` feature has the property that it sets _
to be what was printed, as an interpreter feature so that _
represents the results of the previous expression. However it
appears that this may conflict with some parts of our api, for
instance the _ is used to hold the return value of
wesnoth.textdomain in the lua implementation of [harm_unit].

Note that there is no actual bug that I have observed, I merely
anticipate that this _ feature won't be compatible with our
established gettext conventions.
2014-12-26 00:06:05 -05:00
Chris Beck
3740b24b28 fixup ilua _pretty_print function
had some global vs local problems after making this a module loaded
with require rather than a dofile script
2014-11-23 18:33:50 -05:00
Chris Beck
a65d168317 enable "strict mode" in wesnoth lua
Enables an ilua feature called "strict mode" in all of our lua
environments. This change causes lua to report an error if a global
variable is used before it is assigned. The benefits of this are:
- Improved maintainability of lua-based add-ons, since you get
better error reporting in case of a typo.
- Improved behavior of the lua interpreter console, since mistyped
or gibberish lines resolve to an error rather than "nil", which
the console treats as a legal return value.

It is possible to disable this or work around it in individual
scripts. For more info see release notes.
2014-11-22 15:19:19 -05:00
Chris Beck
ba4276ea31 add "ilua" helper functions for lua interpreter 2014-11-21 22:22:43 -05:00