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 9c79d39..1ba992d 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 46a385a..300e127 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