diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..1a65401 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,35 @@ +unused_args = false +allow_defined_top = true + +exclude_files = { + "mods/default", + "mods/ctf_pvp_engine", + "mods/shooter", + "mods/wield3d", + "mods/treasurer", +} + + +globals = { + "crafting", "vector", "table", "minetest", + "worldedit", "ctf", "ctf_flag", "ctf_colors", + "hudkit", "default", "treasurer", "ChatCmdBuilder", +} + +read_globals = { + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + "dump", "DIR_DELIM", + "sfinv", "creative", + "irc", + "VoxelArea", "ItemStack", + "Settings", + "prometheus", "hb", + + + -- Testing + "describe", + "it", + "assert", +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..077e778 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: generic +sudo: false +addons: + apt: + packages: + - luarocks +before_install: + - luarocks install --local luacheck +script: +- $HOME/.luarocks/bin/luacheck --no-color . +notifications: + email: false diff --git a/mods/afkkick/init.lua b/mods/afkkick/init.lua index 57ddec8..0c04bda 100644 --- a/mods/afkkick/init.lua +++ b/mods/afkkick/init.lua @@ -51,7 +51,7 @@ minetest.register_globalstep(function(dtime) --Warn player if he/she has less than WARN_TIME seconds to move or be kicked if players[playerName]["lastAction"] + MAX_INACTIVE_TIME - WARN_TIME < currGameTime then - minetest.chat_send_player(playerName, minetest.colorize(#FF8C00,"Warning, you have " .. tostring(players[playerName]["lastAction"] + MAX_INACTIVE_TIME - currGameTime) .. " seconds to move or be kicked")) + minetest.chat_send_player(playerName, minetest.colorize("#FF8C00", "Warning, you have " .. tostring(players[playerName]["lastAction"] + MAX_INACTIVE_TIME - currGameTime) .. " seconds to move or be kicked")) end end diff --git a/mods/chatplus/api.lua b/mods/chatplus/api.lua index 9461e4e..1d963dd 100644 --- a/mods/chatplus/api.lua +++ b/mods/chatplus/api.lua @@ -138,9 +138,9 @@ end minetest.after(30*60, cp_tick) function chatplus.poke(name,player) - local function check(name,value) - if not chatplus.players[name][value] then - chatplus.players[name][value] = {} + local function check(name2, value) + if not chatplus.players[name2][value] then + chatplus.players[name2][value] = {} end end if not chatplus.players[name] then diff --git a/mods/chatplus/init.lua b/mods/chatplus/init.lua index 3eb2238..81a03dd 100644 --- a/mods/chatplus/init.lua +++ b/mods/chatplus/init.lua @@ -93,13 +93,13 @@ minetest.registered_chatcommands["msg"].func = function(name, param) if not sendto then return false, "Invalid usage, see /help msg." end - if not core.get_player_by_name(sendto) then + if not minetest.get_player_by_name(sendto) then return false, "The player " .. sendto .. " is not online." end - core.log("action", "PM from " .. name .. " to " .. sendto + minetest.log("action", "PM from " .. name .. " to " .. sendto .. ": " .. message) - core.chat_send_player(sendto, minetest.colorize("#00FF55", + minetest.chat_send_player(sendto, minetest.colorize("#00FF55", "PM from " .. name .. ": " .. message)) return true, "Message sent." end diff --git a/mods/ctf_bounties/init.lua b/mods/ctf_bounties/init.lua index 2c96cb0..d563837 100644 --- a/mods/ctf_bounties/init.lua +++ b/mods/ctf_bounties/init.lua @@ -24,6 +24,16 @@ local function bounty_player(target) bountied_player = target + -- Score * K/D + -- bounty_score = -----------, or 500 (whichever is lesser) + -- 10000 + + local pstat, _ = ctf_stats.player(target) + bounty_score = (pstat.score * (pstat.kills / pstat.deaths)) / 10000 + if bounty_score > 500 then + bounty_score = 500 + end + minetest.after(0.1, announce_all) end @@ -31,7 +41,7 @@ local function bounty_find_new_target() local players = {} for _, player in pairs(minetest.get_connected_players()) do local name = player:get_player_name() - local pstat, mstat = ctf_stats.player(name) + local pstat, _ = ctf_stats.player(name) pstat.name = name pstat.color = nil if pstat.score > 1000 and pstat.kills > pstat.deaths * 1.5 then @@ -41,14 +51,6 @@ local function bounty_find_new_target() if #players > 0 then bounty_player(players[math.random(1, #players)].name) - - -- Score * K/D - -- bounty_score = -----------, or 500 (whichever is lesser) - -- 10000 - bounty_score = (pstat.score * (pstat.kills / pstat.deaths)) / 10000 - if bounty_score > 500 then - bounty_score = 500 - end end minetest.after(math.random(500, 1000), bounty_find_new_target) diff --git a/mods/ctf_disable_save/init.lua b/mods/ctf_disable_save/init.lua index 6f70d5b..fb7b8c8 100644 --- a/mods/ctf_disable_save/init.lua +++ b/mods/ctf_disable_save/init.lua @@ -1,5 +1,5 @@ ctf.save = function() for i = 1, #ctf.registered_on_save do - local res = ctf.registered_on_save[i]() + ctf.registered_on_save[i]() end end diff --git a/mods/ctf_events/init.lua b/mods/ctf_events/init.lua index 0c13ba4..f789aae 100644 --- a/mods/ctf_events/init.lua +++ b/mods/ctf_events/init.lua @@ -38,7 +38,7 @@ function ctf_events.update_row(i, player, name, tplayer, evt) -- One if evt.one then - local tone_text, tone_hex = ctf_colors.get_color(evt.one, ctf.player(evt.one)) + local _, tone_hex = ctf_colors.get_color(evt.one, ctf.player(evt.one)) if hud:exists(player, idx) then hud:change(player, idx, "text", evt.one) hud:change(player, idx, "number", tone_hex) @@ -60,7 +60,7 @@ function ctf_events.update_row(i, player, name, tplayer, evt) -- Two if evt.two then - local ttwo_text, ttwo_hex = ctf_colors.get_color(evt.two, ctf.player(evt.two)) + local _, ttwo_hex = ctf_colors.get_color(evt.two, ctf.player(evt.two)) if hud:exists(player, idx2) then hud:change(player, idx2, "text", evt.two) hud:change(player, idx2, "number", ttwo_hex) diff --git a/mods/ctf_map/barrier.lua b/mods/ctf_map/barrier.lua index ead90a6..7acfbdf 100644 --- a/mods/ctf_map/barrier.lua +++ b/mods/ctf_map/barrier.lua @@ -4,8 +4,8 @@ local c_glass = minetest.get_content_id("ctf_map:ind_glass") local c_glass_red = minetest.get_content_id("ctf_map:ind_glass_red") local c_map_ignore = minetest.get_content_id("ctf_map:ignore") local c_actual_st = minetest.get_content_id("default:stone") -local c_water = minetest.get_content_id("default:water_source") -local c_water_f = minetest.get_content_id("default:water_flowing") +-- local c_water = minetest.get_content_id("default:water_source") +-- local c_water_f = minetest.get_content_id("default:water_flowing") local c_air = minetest.get_content_id("air") function ctf_map.remove_middle_barrier() @@ -118,14 +118,16 @@ function ctf_map.place_outer_barrier(center, r, h) print("Placing left wall") -- Left - local x = center.x - r - for z = minp.z, maxp.z do - for y = minp.y, maxp.y do - local vi = a:index(x, y, z) - if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then - data[vi] = c_glass - else - data[vi] = c_stone + do + local x = center.x - r + for z = minp.z, maxp.z do + for y = minp.y, maxp.y do + local vi = a:index(x, y, z) + if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then + data[vi] = c_glass + else + data[vi] = c_stone + end end end end @@ -133,14 +135,16 @@ function ctf_map.place_outer_barrier(center, r, h) print("Placing right wall") -- Right - local x = center.x + r - for z = minp.z, maxp.z do - for y = minp.y, maxp.y do - local vi = a:index(x, y, z) - if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then - data[vi] = c_glass - else - data[vi] = c_stone + do + local x = center.x + r + for z = minp.z, maxp.z do + for y = minp.y, maxp.y do + local vi = a:index(x, y, z) + if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then + data[vi] = c_glass + else + data[vi] = c_stone + end end end end @@ -148,14 +152,16 @@ function ctf_map.place_outer_barrier(center, r, h) print("Placing front wall") -- Front - local z = center.z - r - for x = minp.x, maxp.x do - for y = minp.y, maxp.y do - local vi = a:index(x, y, z) - if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then - data[vi] = c_glass - else - data[vi] = c_stone + do + local z = center.z - r + for x = minp.x, maxp.x do + for y = minp.y, maxp.y do + local vi = a:index(x, y, z) + if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then + data[vi] = c_glass + else + data[vi] = c_stone + end end end end @@ -163,14 +169,16 @@ function ctf_map.place_outer_barrier(center, r, h) print("Placing back wall") -- Back - local z = center.z + r - for x = minp.x, maxp.x do - for y = minp.y, maxp.y do - local vi = a:index(x, y, z) - if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then - data[vi] = c_glass - else - data[vi] = c_stone + do + local z = center.z + r + for x = minp.x, maxp.x do + for y = minp.y, maxp.y do + local vi = a:index(x, y, z) + if data[vi] == c_air or data[vi] == c_glass or data[vi] == c_map_ignore then + data[vi] = c_glass + else + data[vi] = c_stone + end end end end diff --git a/mods/ctf_map/map_maker.lua b/mods/ctf_map/map_maker.lua index 0e67e8a..91b90bd 100644 --- a/mods/ctf_map/map_maker.lua +++ b/mods/ctf_map/map_maker.lua @@ -54,6 +54,12 @@ minetest.register_node("ctf_map:flag", { end, }) +local randint = math.random(100) +local barrier_r = 110 +local mapname = "ctf_" .. randint +local maptitle = "Untitled Map " .. randint +local mapauthor = nil +local center_barrier_rot = 0 local center = { x = 0, y = 0, z = 0, r = 115, h = 140 } local function to_2pos() return { @@ -130,13 +136,6 @@ local function get_flag_status() end end - -local randint = math.random(100) -local barrier_r = 110 -local mapname = "ctf_" .. randint -local maptitle = "Untitled Map " .. randint -local mapauthor = nil -local center_barrier_rot = 1 local function show_gui(name) mapauthor = mapauthor or name diff --git a/mods/ctf_map/schem_map.lua b/mods/ctf_map/schem_map.lua index 7f3b032..8f13ff0 100644 --- a/mods/ctf_map/schem_map.lua +++ b/mods/ctf_map/schem_map.lua @@ -120,11 +120,6 @@ function ctf_match.load_map_meta(idx, name) map.teams[tname] = { color = tcolor, pos = vector.add(offset, tpos), - chests = { - from = chests1, - to = chests2, - n = tonumber(meta:get("team." .. i .. ".num_chests") or "23"), - }, } i = i + 1 @@ -200,8 +195,6 @@ ctf_match.register_on_new_match(function() end) function ctf_match.create_teams() - local number = ctf.setting("match.teams") - for key, value in pairs(ctf_map.map.teams) do local name = key local color = value.color diff --git a/mods/ctf_match/vote.lua b/mods/ctf_match/vote.lua index dc27025..c8a10b5 100644 --- a/mods/ctf_match/vote.lua +++ b/mods/ctf_match/vote.lua @@ -33,8 +33,8 @@ function ctf_match.vote_next(name, params) end end, - on_vote = function(self, name, value) - minetest.chat_send_all(name .. " voted " .. value .. " to '" .. + on_vote = function(self, voter, value) + minetest.chat_send_all(voter .. " voted " .. value .. " to '" .. self.description .. "'") end }) @@ -51,9 +51,9 @@ minetest.register_chatcommand("vote", { minetest.register_on_chat_message(function(name, msg) if msg == "/vote_next" and minetest.check_player_privs(name, {interact=true, vote_starter=true}) then - local suc, msg = ctf_match.vote_next(name) - if msg then - minetest.chat_send_player(name, msg) + local _, vmsg = ctf_match.vote_next(name) + if vmsg then + minetest.chat_send_player(name, vmsg) end return true end diff --git a/mods/ctf_metrics/init.lua b/mods/ctf_metrics/init.lua index 4ba4c9d..4d72e10 100644 --- a/mods/ctf_metrics/init.lua +++ b/mods/ctf_metrics/init.lua @@ -15,7 +15,7 @@ local function step() local avg = 0 if #minetest.get_connected_players() > 0 then for _, player in pairs(minetest.get_connected_players()) do - local total, match = ctf_stats.player(player:get_player_name()) + local total, _ = ctf_stats.player(player:get_player_name()) sum = sum + total.score end avg = sum / #minetest.get_connected_players() diff --git a/mods/ctf_stats/gui.lua b/mods/ctf_stats/gui.lua index 282f008..079070f 100644 --- a/mods/ctf_stats/gui.lua +++ b/mods/ctf_stats/gui.lua @@ -72,7 +72,6 @@ function ctf_stats.get_html(title, players) for i = 1, #players do local pstat = players[i] - local color = pstat.color or "#ffffff" local kd = pstat.kills if pstat.deaths > 0 then kd = kd / pstat.deaths diff --git a/mods/ctf_stats/init.lua b/mods/ctf_stats/init.lua index ef032a1..151a1cb 100644 --- a/mods/ctf_stats/init.lua +++ b/mods/ctf_stats/init.lua @@ -181,7 +181,7 @@ end) ctf_flag.register_on_precapture(function(name, flag) local tplayer = ctf.player(name) - local main, match = ctf_stats.player(name) + local main, _ = ctf_stats.player(name) if main then main.wins[tplayer.team] = main.wins[tplayer.team] + 1 ctf.needs_save = true diff --git a/mods/ctf_team_base/api.lua b/mods/ctf_team_base/api.lua index aace73f..f07d83c 100644 --- a/mods/ctf_team_base/api.lua +++ b/mods/ctf_team_base/api.lua @@ -13,9 +13,9 @@ function ctf_team_base.place(color, pos) for y = pos.y, pos.y + 3 do for x = pos.x - 3, pos.x + 3 do for z = pos.z - 3, pos.z + 3 do - local pos = {x=x, y=y, z=z} - if minetest.get_node(pos).name == "default:tree" then - minetest.set_node(pos, {name="air"}) + local pos2 = {x=x, y=y, z=z} + if minetest.get_node(pos2).name == "default:tree" then + minetest.set_node(pos2, {name="air"}) end end end @@ -28,13 +28,13 @@ function ctf_team_base.place(color, pos) dz = -2 chest.param2 = minetest.dir_to_facedir({x=0,y=0,z=-1}) end - local pos = { + local pos3 = { x = pos.x, y = pos.y, z = pos.z + dz } - minetest.set_node(pos, chest) - local inv = minetest.get_meta(pos):get_inventory() + minetest.set_node(pos3, chest) + local inv = minetest.get_meta(pos3):get_inventory() inv:add_item("main", ItemStack("default:cobble 99")) inv:add_item("main", ItemStack("default:cobble 99")) inv:add_item("main", ItemStack("default:cobble 99")) diff --git a/mods/ctf_team_base/chest.lua b/mods/ctf_team_base/chest.lua index 8642879..f6b28a2 100644 --- a/mods/ctf_team_base/chest.lua +++ b/mods/ctf_team_base/chest.lua @@ -90,7 +90,6 @@ for _, chest_color in pairs(colors) do allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - local meta = minetest.get_meta(pos) if chest_color ~= ctf.player(player:get_player_name()).team then minetest.chat_send_player(player:get_player_name(), "You're not on team " .. chest_color) return 0 @@ -125,7 +124,6 @@ for _, chest_color in pairs(colors) do end end, allow_metadata_inventory_take = function(pos, listname, index, stack, player) - local meta = minetest.get_meta(pos) if chest_color ~= ctf.player(player:get_player_name()).team then minetest.chat_send_player(player:get_player_name(), "You're not on team " .. chest_color) return 0 diff --git a/mods/ctf_userlimit/init.lua b/mods/ctf_userlimit/init.lua index 3fa8280..56e07ee 100644 --- a/mods/ctf_userlimit/init.lua +++ b/mods/ctf_userlimit/init.lua @@ -1,6 +1,6 @@ if minetest.register_can_bypass_userlimit then minetest.register_can_bypass_userlimit(function(name, ip) - local pstat, discard = ctf_stats.player_or_nil(name) + local pstat, _ = ctf_stats.player_or_nil(name) local actual_max_users = tonumber(minetest.settings:get("max_users")) + tonumber(minetest.settings:get("max_extra_users") or "10") local req_score = tonumber(minetest.settings:get("userlimit_bypass_required_score") or "10000") diff --git a/mods/dropondie/init.lua b/mods/dropondie/init.lua index 397034b..6abf131 100644 --- a/mods/dropondie/init.lua +++ b/mods/dropondie/init.lua @@ -15,7 +15,7 @@ local function drop(pos, itemstack) end end - local obj = core.add_item(pos, it) + local obj = minetest.add_item(pos, it) if obj then obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)}) diff --git a/mods/email/init.lua b/mods/email/init.lua index f15ff26..d63c81e 100644 --- a/mods/email/init.lua +++ b/mods/email/init.lua @@ -79,15 +79,14 @@ end) function email.get_formspec(name) local inbox = email.get_inbox(name) - local fs = "vertlabel[0,0;Your Inbox]" - - function row(fs, c1, date, from, msg) + local function row(fs, c1, date, from, msg) date = minetest.formspec_escape(date) from = minetest.formspec_escape(from) msg = minetest.formspec_escape(msg) return fs .. ",#d0d0d0," .. table.concat({date, c1, from, msg}, ",") end + local fs = "vertlabel[0,0;Your Inbox]" fs = fs .. "tablecolumns[color;text;color;text;text]" fs = fs .. "tableoptions[highlight=#ffffff33]" fs = fs .. "table[0.5,0;11.25,7;inbox;" @@ -138,8 +137,6 @@ function email.show_inbox(name, text_mode) return true, "Opened inbox!" end - - return true end if minetest.global_exists("sfinv") then diff --git a/mods/furnace/init.lua b/mods/furnace/init.lua index 197ab8c..65afff2 100644 --- a/mods/furnace/init.lua +++ b/mods/furnace/init.lua @@ -51,12 +51,6 @@ end -- Node callback functions that are the same for active and inactive furnace -- -local function can_dig(pos, player) - local meta = minetest.get_meta(pos); - local inv = meta:get_inventory() - return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src") -end - local function allow_metadata_inventory_put(pos, listname, index, stack, player) if minetest.is_protected(pos, player:get_player_name()) then return 0 diff --git a/mods/killme/init.lua b/mods/killme/init.lua index 9b67475..ff5ed15 100644 --- a/mods/killme/init.lua +++ b/mods/killme/init.lua @@ -7,7 +7,7 @@ minetest.register_chatcommand("killme", { player:set_hp(0) return true else - for _, callback in pairs(core.registered_on_respawnplayers) do + for _, callback in pairs(minetest.registered_on_respawnplayers) do if callback(player) then return true end diff --git a/mods/playertag/api.lua b/mods/playertag/api.lua index 2bef512..4804871 100644 --- a/mods/playertag/api.lua +++ b/mods/playertag/api.lua @@ -44,7 +44,7 @@ local function remove_entity_tag(player) local tag = nametags[player:get_player_name()] if tag then tag:remove() - tag = nil + nametags[player:get_player_name()] = nil end end diff --git a/mods/report/init.lua b/mods/report/init.lua index 9824c60..bbd61db 100644 --- a/mods/report/init.lua +++ b/mods/report/init.lua @@ -64,7 +64,8 @@ minetest.register_chatcommand("report", { local toname = player:get_player_name() if minetest.check_player_privs(toname, {kick = true, ban = true}) then table.insert(mods, toname) - minetest.chat_send_player(toname, minetest.colorize(#FFFF00,"-!- " .. name .. " reported: " .. param)) + minetest.chat_send_player(toname, minetest.colorize("#FFFF00", + "-!- " .. name .. " reported: " .. param)) end end diff --git a/mods/respawn_immunity/init.lua b/mods/respawn_immunity/init.lua index b6480e1..98789ab 100644 --- a/mods/respawn_immunity/init.lua +++ b/mods/respawn_immunity/init.lua @@ -45,7 +45,8 @@ minetest.register_on_punchplayer(function(player, hitter, if hitter and respawn_immunity.is_immune(hitter) then minetest.chat_send_player(hitter:get_player_name(), - minetest.colorize(#FF8C00,"Your immunity has ended because you attacked a player")) + minetest.colorize("#FF8C00", + "Your immunity has ended because you attacked a player")) immune_players[hitter:get_player_name()] = nil respawn_immunity.update_effects(hitter) end diff --git a/mods/sprint/init.lua b/mods/sprint/init.lua index 2c85c1a..7ba812c 100644 --- a/mods/sprint/init.lua +++ b/mods/sprint/init.lua @@ -24,7 +24,6 @@ else end local players = {} -local staminaHud = {} local function setSprinting(player, info, sprinting) if info.sprinting ~= sprinting then diff --git a/mods/tsm_chests/init.lua b/mods/tsm_chests/init.lua index f49dd98..87b6a81 100755 --- a/mods/tsm_chests/init.lua +++ b/mods/tsm_chests/init.lua @@ -85,7 +85,6 @@ local t_max = 7 -- maximum amount of treasures found in a chest local water_level = tonumber(minetest.setting_get("water_level")) local get_node = minetest.get_node -local env = minetest.env local function findGroundLevel(pos, y_min, y_max) local ground = nil @@ -153,9 +152,9 @@ local function placeChest(pos, chest_pos, ground, nn) -- Get treasure local treasure_amount = math.ceil(math.random(t_min, t_max)) - local height = math.abs(h_min) - math.abs(h_max) - local y_norm = (ground+1) - h_min - local scale = 1 - (y_norm/height) + -- local height = math.abs(h_min) - math.abs(h_max) + -- local y_norm = (ground+1) - h_min + -- local scale = 1 - (y_norm/height) local minp = 0 --scale*4 -- minimal preciousness: 0..4 local maxp = 10 --scale*4+2.1 -- maximum preciousness: 2.1..6.1 local treasures = treasurer.select_random_treasures(treasure_amount, minp, maxp) diff --git a/mods/vote/init.lua b/mods/vote/init.lua index f8977e0..fd51883 100644 --- a/mods/vote/init.lua +++ b/mods/vote/init.lua @@ -341,8 +341,8 @@ if set == nil or minetest.is_yes(set) then end end, - on_vote = function(self, name, value) - minetest.chat_send_all(name .. " voted " .. value .. " to '" .. + on_vote = function(self, voter, value) + minetest.chat_send_all(voter .. " voted " .. value .. " to '" .. self.description .. "'") end })