Add a .luacheckrc and some code style changes

This commit is contained in:
HybridDog 2021-03-07 11:39:10 +01:00
parent 8c4e8bdf3c
commit d7bbd42677
2 changed files with 21 additions and 8 deletions

13
.luacheckrc Normal file
View File

@ -0,0 +1,13 @@
read_globals = {
-- Defined by Minetest
"vector", "PseudoRandom", "VoxelArea",
minetest = {
fields = {
chatcommands = {
read_only = false,
other_fields = true
}
},
other_fields = true
}
}

View File

@ -47,29 +47,29 @@ local function find_item(name, pname)
-- collect information about them and put it to priority
local maxwant = 0
local data = {}
for _,name in pairs(possible_names) do
for _,item_name in pairs(possible_names) do
local want = 0
if minetest.get_item_group(name, "not_in_creative_inventory") == 0
and minetest.registered_items[name].description then
if minetest.get_item_group(item_name, "not_in_creative_inventory") == 0
and minetest.registered_items[item_name].description then
want = want+4
end
if minetest.registered_nodes[name] then
if minetest.registered_nodes[item_name] then
want = want+2
if string.sub(name, 1,7) ~= "stairs:" then
if string.sub(item_name, 1,7) ~= "stairs:" then
want = want+1
end
end
maxwant = math.max(maxwant, want)
if want == maxwant then
data[name] = want
data[item_name] = want
end
end
-- collect possible ones
possible_names,n = {},1
for name,want in pairs(data) do
for item_name,want in pairs(data) do
if want == maxwant then
possible_names[n] = name
possible_names[n] = item_name
n = n+1
end
end