From 49baa55bd6873b07084b73d2834f6fec29deecb7 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Thu, 5 Mar 2020 15:49:45 +0100 Subject: [PATCH] luacheck, workflow and badge --- .github/workflows/luacheck.yml | 17 +++++++++++++++++ .luacheckrc | 25 +++++++++++++++++++++++++ README.md | 2 ++ admin.lua | 6 +++--- doors_chest.lua | 12 ++++++------ init.lua | 2 +- pvp.lua | 4 +--- 7 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/luacheck.yml create mode 100644 .luacheckrc diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml new file mode 100644 index 0000000..d00f53a --- /dev/null +++ b/.github/workflows/luacheck.yml @@ -0,0 +1,17 @@ +name: luacheck + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: apt + run: sudo apt-get install -y luarocks + - name: luacheck install + run: luarocks install --local luacheck + - name: luacheck run + run: $HOME/.luarocks/bin/luacheck ./ diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..a5b19ab --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,25 @@ +unused = false + +globals = { + "minetest", + "default", + "protector", + "register_door", + "register_trapdoor" +} + +read_globals = { + -- Stdlib + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + -- Minetest + "vector", "ItemStack", + "dump", "VoxelArea", + + -- deps + "intllib", + "mesecon", + "screwdriver", + "lucky_block" +} diff --git a/README.md b/README.md index a652302..939c035 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ Protector Redo mod [protect] +![](https://github.com/S-S-X/protector/workflows/luacheck/badge.svg) + Protector redo for minetest is a mod that protects a players builds by placing a block that stops other players from digging or placing blocks in that area. diff --git a/admin.lua b/admin.lua index a6a4964..78ba00c 100644 --- a/admin.lua +++ b/admin.lua @@ -119,12 +119,12 @@ minetest.register_chatcommand("protector_show", { func = function(name, param) local player = minetest.get_player_by_name(name) - local pos = player:get_pos() + local ppos = player:get_pos() -- find the protector nodes local pos = minetest.find_nodes_in_area( - {x = pos.x - r, y = pos.y - r, z = pos.z - r}, - {x = pos.x + r, y = pos.y + r, z = pos.z + r}, + {x = ppos.x - r, y = ppos.y - r, z = ppos.z - r}, + {x = ppos.x + r, y = ppos.y + r, z = ppos.z + r}, {"protector:protect", "protector:protect2"}) local meta, owner diff --git a/doors_chest.lua b/doors_chest.lua index 60d0197..0f8b350 100644 --- a/doors_chest.lua +++ b/doors_chest.lua @@ -87,9 +87,9 @@ function register_door(name, def) local tt = def.tiles_top local tb = def.tiles_bottom - local function after_dig_node(pos, name, digger) + local function after_dig_node(pos, node_name, digger) local node = minetest.get_node(pos) - if node.name == name then + if node.name == node_name then minetest.node_dig(pos, node, digger) end end @@ -340,7 +340,7 @@ end -- Protected Steel Door -local name = "protector:door_steel" +name = "protector:door_steel" register_door(name, { description = S("Protected Steel Door"), @@ -382,9 +382,9 @@ end ----trapdoor---- -function register_trapdoor(name, def) - local name_closed = name - local name_opened = name.."_open" +function register_trapdoor(node_name, def) + local name_closed = node_name + local name_opened = node_name.."_open" def.on_rightclick = function (pos, node, clicker, itemstack, pointed_thing) if minetest.is_protected(pos, clicker:get_player_name()) then diff --git a/init.lua b/init.lua index eb95024..6af648a 100644 --- a/init.lua +++ b/init.lua @@ -217,7 +217,7 @@ protector.can_dig = function(r, pos, digger, onlyowner, infolevel) end -- find the protector nodes - local pos = minetest.find_nodes_in_area( + pos = minetest.find_nodes_in_area( {x = pos.x - r, y = pos.y - r, z = pos.z - r}, {x = pos.x + r, y = pos.y + r, z = pos.z + r}, {"protector:protect", "protector:protect2"}) diff --git a/pvp.lua b/pvp.lua index 0efb62a..1e15f93 100644 --- a/pvp.lua +++ b/pvp.lua @@ -48,9 +48,7 @@ and minetest.settings:get_bool("protector_pvp") then -- get time of day local tod = minetest.get_timeofday() or 0 - if tod > 0.2 and tod < 0.8 then - -- - else + if tod <= 0.2 or tod >= 0.8 then return false end end