Lint
calls selene
- supports luanti globals by default
- allows calling a globals that are the name of mods dep’d on
- allows extra globals listed in
globalsunder[linter], e.g.globals = ["mylib"] - configured by
[linter]in flint.toml
Fixes
some lints can be fixed automatically, handled by flint lint --write. run flint lint --write (or flint modernize) to apply the fixes, then report what’s left. lints set to allow, in the config or by a filter comment, aren’t fixed.
some deprecated functions are replaced by something added in a newer engine. the mod’s min_minetest_version decides what happens, which is the highest min_minetest_version in the conf of the mod and of any modpack or game it’s in:
- at least the version the replacement was added in: the lint is reported and fixable
- lower: the lint isn’t reported, as the mod supports engines without the replacement
- not set: the mod might support every version, like ContentDB assumes, so the lint is reported with a note to set
min_minetest_version, but not fixed
Luanti lints
flint adds its own lints on top of selene’s. they’re configured the same way, in [linter.lints] and [linter.config].
| lint | default | description |
|---|---|---|
luanti_legacy_physics_override | deny | player:set_physics_override(speed, jump, gravity) instead of a table, e.g. player:set_physics_override({ speed = 1.5 }). fixable, unless the last argument is a call or ... |
luanti_deprecated_env | deny | core.env or minetest.env, on its own or with anything after it. its methods are functions on core, e.g. core.get_node(pos) instead of core.env:get_node(pos). fixable when something follows env |
luanti_minetest_global | warn | the minetest global instead of core, e.g. core.log("hi") instead of minetest.log("hi"). fixable, unless the file has a local named core |
luanti_minetest_domain | warn | a minetest.net domain in a string or comment, e.g. https://content.minetest.net, use luanti.org. fixable, keeping any subdomain, e.g. https://content.luanti.org. the package’s other text files are checked too, see package lints |
luanti_missing_settingtype | warn | a mod reads its own setting, e.g. core.settings:get("mymod.speed"), that isn’t in settingtypes.txt. only settings named modname.* or modname_* with a literal name are checked, since others may belong to the engine or other mods. the settingtypes.txt of the mod and any modpack or game it’s in count |
luanti_unclosed_voxelmanip | warn | a VoxelManip from core.get_voxel_manip() or VoxelManip() in a local that’s never close()d, e.g. vm:close(). only checks that close() is called somewhere, not on every location. skipped when the VoxelManip is used as anything but vm:method(), e.g. passed, returned, stored or reassigned, as something else may close it. the core engine mapgen VoxelManip isn’t checked. close() was added in 5.13, so it isn’t reported when the mod’s min_minetest_version is lower |
luanti_deprecated_register_on_auth_fail | warn | core.register_on_auth_fail, use core.register_on_authplayer and check is_success |
luanti_deprecated_setting_get_pos | warn | core.setting_get_pos(name), use core.settings:get_pos(name), added in 5.11. fixable where it’s called, when the mod’s min_minetest_version is at least 5.11 |
luanti_legacy_get_value_noise | warn | core.get_value_noise(seeddiff, octaves, persistence, spread), pass a noiseparams table |
luanti_deprecated_get_perlin | warn | core.get_perlin, renamed to core.get_value_noise in 5.12. fixable when the mod’s min_minetest_version is at least 5.12 |
luanti_deprecated_get_mapgen_params | warn | core.get_mapgen_params(), use core.get_mapgen_setting(name) |
luanti_deprecated_set_mapgen_params | warn | core.set_mapgen_params(params), use core.set_mapgen_setting(name, value, override) |
luanti_deprecated_get_node_group | warn | core.get_node_group(name, group), use core.get_item_group(name, group). fixable |
luanti_deprecated_get_entity_name | warn | obj:get_entity_name(), use obj:get_luaentity().name |
luanti_deprecated_get_player_velocity | warn | player:get_player_velocity(), use player:get_velocity(), which works on players since 5.4. fixable when the mod’s min_minetest_version is at least 5.4 |
luanti_deprecated_add_player_velocity | warn | player:add_player_velocity(vel), use player:add_velocity(vel), which works on players since 5.4. fixable when the mod’s min_minetest_version is at least 5.4 |
luanti_deprecated_get_look_pitch | warn | player:get_look_pitch(), use player:get_look_vertical() |
luanti_deprecated_get_look_yaw | warn | player:get_look_yaw(), use player:get_look_horizontal() |
luanti_deprecated_set_look_pitch | warn | player:set_look_pitch(radians), use player:set_look_vertical(radians). fixable |
luanti_deprecated_set_look_yaw | warn | player:set_look_yaw(radians), use player:set_look_horizontal(radians). fixable |
luanti_deprecated_object_alias | warn | the old names of object methods, aliases since 0.4.16: getpos, setpos, moveto, getvelocity, setvelocity, getacceleration, setacceleration, getyaw, setyaw, settexturemod and setsprite, e.g. obj:set_pos(pos) instead of obj:setpos(pos). fixable |
luanti_deprecated_player_attribute | warn | player:set_attribute(key, value) and player:get_attribute(key), use player:get_meta(), added in 5.0. its get_string returns "" rather than nil for a missing key |
luanti_deprecated_itemstack_metadata | warn | stack:get_metadata() and stack:set_metadata(value), use stack:get_meta(), e.g. stack:get_meta():get_string("") |
luanti_deprecated_setting | warn | core.setting_get, setting_set, setting_getbool, setting_setbool and setting_save, use core.settings:get(name) and the rest, and core.settings:write() for setting_save. fixable where it’s called |
luanti_legacy_particle_arguments | warn | core.add_particle and core.add_particlespawner with positional arguments, pass a definition table |
luanti_legacy_set_sky | warn | player:set_sky(bgcolor, type, textures, clouds), pass a sky parameters table, added in 5.2 |
luanti_deprecated_vector_new | warn | vector.new(), use vector.zero(), and vector.new(v), use vector.copy(v), both added in 5.5. vector.new() is fixable when the mod’s min_minetest_version is at least 5.5. vector.new(v) isn’t, as vector.copy(nil) errors where vector.new(nil) didn’t |
luanti_removed_nodeupdate | deny | the nodeupdate(pos) and nodeupdate_single(pos) globals, removed in 5.0, use core.check_for_falling(pos) and core.check_single_for_falling(pos). fixable |
luanti_deprecated_hud_elem_type | warn | hud_elem_type in a table, e.g. a HUD definition, use type, added in 5.9. fixable when the mod’s min_minetest_version is at least 5.9 and the table has no type |
luanti_removed_tile_images | deny | tile_images and special_materials in a table, ignored since 5.6, use tiles and special_tiles. fixable, unless the table has the new name too |
luanti_deprecated_texture_alpha | warn | in a node definition, alpha, or use_texture_alpha = true or false, use use_texture_alpha = "opaque", "clip" or "blend", added in 5.4. fixable when the mod’s min_minetest_version is at least 5.4: alpha other than 255 becomes "blend", and true becomes "clip" for the normal drawtype or "blend" for any other drawtype written as a string |
luanti_deprecated_entity_properties | warn | object properties, e.g. visual or textures, at the top of an entity definition, move them into initial_properties |
luanti_deprecated_get_sky | warn | player:get_sky() without true, and player:get_sky_color(), use player:get_sky(true), added in 5.6, e.g. player:get_sky(true).sky_color |
luanti_deprecated_bone_position | warn | obj:set_bone_position(bone, position, rotation) and obj:get_bone_position(bone), use obj:set_bone_override(bone, override) and obj:get_bone_override(bone), added in 5.9. overrides take rotations in radians, not degrees |
luanti_deprecated_perlin_noise | warn | core.get_perlin_map, PerlinNoise and PerlinNoiseMap, renamed core.get_value_noise_map, ValueNoise and ValueNoiseMap in 5.12. fixable when the mod’s min_minetest_version is at least 5.12 |
luanti_deprecated_particle_fields | warn | vel and acc in a particle definition, use velocity and acceleration. fixable, unless the table has the new name too |
luanti_deprecated_tile_image | warn | image in a tile of a node definition, e.g. tiles = { { image = "a.png" } }, use name. fixable, unless the tile has name too |
luanti_registration_prefix | deny | an item, entity or LBM name that doesn’t start with the mod’s name and :, or with : to register under another name, or that has characters other than letters, digits and _ after the prefix, e.g. core.register_node("othermod:stone", def). the engine errors on these. only names written as strings are checked |
luanti_missing_file | deny | dofile, core.register_async_dofile or core.register_mapgen_script of a file in the mod that doesn’t exist, or only exists with different upper and lower case, which works on Windows but nowhere else. see missing files for which paths are followed |
luanti_lua51_compat | warn | LuaJIT extensions that break when Luanti is built with Lua 5.1: goto and labels, the \x, \z and \u{...} escapes, LL, ULL and i number suffixes, xpcall with arguments for the function, and require of LuaJIT modules like ffi. functions Lua 5.1 lacks, like table.unpack, are reported by selene’s incorrect_standard_library_use. bit and string.pack are fine, Luanti provides them on both |
node, entity and particle definitions are only recognized when the table is written straight into core.register_node, core.override_item, core.register_entity or core.add_particle. a method lint is skipped in a file that defines a function or field of that name itself, e.g. function mob:getpos(), as it belongs to something other than an engine object.
Missing files
the path has to be the mod’s own folder joined with strings. core.get_modpath of the mod’s name or of core.get_current_modname(), DIR_DELIM, and locals or fields like mymod.path assigned once in the same file are followed, e.g.
local modpath = core.get_modpath(core.get_current_modname())
dofile(modpath .. "/src/items.lua")paths built from anything else are skipped, as are paths the file also opens with io.open, e.g. to check whether an optional file exists first.
Package lints
these check a package’s files rather than its Lua, for the package being linted and the mods and modpacks inside it. the package type is detected from its files:
| type | detected by | conf file |
|---|---|---|
| game | game.conf | game.conf |
| modpack | modpack.conf or modpack.txt | modpack.conf |
| mod | mod.conf or init.lua | mod.conf |
| texture pack | texture_pack.conf | texture_pack.conf |
| lint | default | description |
|---|---|---|
luanti_missing_mod_conf | warn | a mod without a mod.conf. the fix creates one with name set to the folder name |
luanti_legacy_modpack_txt | warn | modpack.txt. the fix replaces it with modpack.conf |
luanti_legacy_description_txt | warn | description.txt. the fix moves it into description of the conf file |
luanti_legacy_depends_txt | warn | a mod’s depends.txt. the fix moves it into depends and optional_depends of mod.conf |
luanti_legacy_tr_translation | warn | locale/*.tr translations. the fix converts them to gettext locale/*.po |
luanti_legacy_b3d_model | warn | a mod’s models/**/*.b3d. the fix converts them to glTF .glb like flint convert, and replaces "name.b3d" strings with "name.glb" in the Lua of the mod, or of the game or modpack it’s in. see below for when it’s fixable |
luanti_legacy_x_model | warn | a mod’s models/**/*.x, fixed the same way as luanti_legacy_b3d_model |
luanti_minetest_domain | warn | a minetest.net domain in the package’s text files other than Lua, e.g. mod.conf, settingtypes.txt, README.md, .po files or LICENSE. hidden files and folders are skipped. the fix replaces it with luanti.org. it’s the same lint as the Luanti lint for Lua, so one setting covers both |
luanti_junk_file | warn | a file Luanti never loads that would end up in ContentDB releases, as it isn’t export-ignored in .gitattributes: OS files like Thumbs.db, desktop.ini, .DS_Store and ._*, backups like *~, *.bak and *.swp, image and model projects like *.blend, *.xcf, *.psd, *.kra and *.svg, audio other than .ogg and audio projects like *.wav and *.aup3, and archives like *.zip. .gitignored files and hidden folders are skipped, and the .gitattributes files from the repository’s root down are read. the fix adds a rule like *.xcf export-ignore to the .gitattributes of the game or modpack being linted, or of the mod, and doesn’t delete anything |
if an old file doesn’t match what’s already in the conf file or .po, it can’t be fixed and nothing is changed. these can’t be changed by filter comments, only in [linter.lints].
b3d and x models
a .b3d or .x model is only fixed when nothing else needs to change for it to look the same:
- the
min_minetest_versionof the mod, or of the modpack or game it’s in, is at least5.10, the first to load glTF - it’s animated, or only entities use it. static
.b3dand.xnode meshes use 1 unit per node, but glTF 10, while entities use 10 for both. it counts as only used by entities when its name is always passed straight toregister_entity,set_properties,register_mob,register_modelorset_model(e.g.player_api.set_model), in a table or not. otherwise convert it withflint convertand multiply the node’svisual_scaleby 10 - it converts without warnings about something Luanti would show differently. keyframes before frame 1, repeated or out of order are fine, as the conversion does what Luanti does with them
- its file name is in the Lua code as a string, e.g.
mesh = "mymod_mob.b3d". names built in code, likename .. ".b3d", can’t be changed - there’s no
.glbor.gltfof the same name yet
mods outside the package using the model need to change its name themselves.
Filter comments
change the severity of lints for part of a file with allow, warn or deny:
-- flint: allow(unused_variable)
local function unused() end
local a = 1 -- flint: allow(unused_variable, shadowing)
--# flint: allow(undefined_variable)- a comment covers the statement it’s in front of, on the same line as, or inside of. a comment before a function covers the whole function
- when filters overlap, the innermost one wins
--#covers the whole file, and must come before any code- selene’s
-- selene: allow(...)comments work the same way, and cover Luanti lints too - filters for lints that don’t exist and misplaced
--#filters are reported asinvalid_lint_filter