From 419d663e15dc332946b56a71c6986b2c60053aa6 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sun, 10 Jan 2021 19:34:08 +0100 Subject: [PATCH] add luacheck workflow --- .github/workflows/luacheck.yml | 18 ++++++++++++++++++ .luacheckrc | 6 +----- cannon.lua | 20 +++++++++++--------- digiline.lua | 4 ++-- util.lua | 8 ++++---- 5 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/luacheck.yml diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml new file mode 100644 index 0000000..f24a4b0 --- /dev/null +++ b/.github/workflows/luacheck.yml @@ -0,0 +1,18 @@ +name: luacheck + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v2.3.4 + - 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 index 2467b80..0a8ecb7 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,8 +1,4 @@ -unused_args = false -allow_defined_top = true - globals = { - "minetest", "spacecannon" } @@ -12,7 +8,7 @@ read_globals = { table = {fields = {"copy", "getn"}}, -- mod deps - "technic", "default", + "technic", "default", "digilines", -- Minetest "minetest", diff --git a/cannon.lua b/cannon.lua index b07306e..8817157 100644 --- a/cannon.lua +++ b/cannon.lua @@ -49,7 +49,7 @@ local register_spacecannon = function(def) if goes_through then local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1) local collided = false - for k, obj in pairs(objs) do + for _, obj in pairs(objs) do if obj:get_luaentity() ~= nil and obj:get_luaentity().name ~= self.name then collided = true obj:punch(self.object, 1.0, { @@ -72,7 +72,7 @@ local register_spacecannon = function(def) end end, - on_activate = function(self, staticdata) + on_activate = function(self) minetest.after(def.timeout, function(me) me.object:remove() @@ -103,7 +103,7 @@ local register_spacecannon = function(def) legacy_facedir_simple = true, mesecons = {effector = { - action_on = function (pos, node) + action_on = function (pos) spacecannon.fire(pos, def.color, def.speed, def.range) end }}, @@ -140,7 +140,7 @@ local register_spacecannon = function(def) spacecannon.update_formspec(meta) end, - technic_run = function(pos, node) + technic_run = function(pos) local meta = minetest.get_meta(pos) local eu_input = meta:get_int("HV_EU_input") local demand = meta:get_int("HV_EU_demand") @@ -159,7 +159,13 @@ local register_spacecannon = function(def) end end, - on_receive_fields = function(pos, formname, fields, sender) + on_receive_fields = function(pos, _, fields, sender) + local playername = sender and sender:get_player_name() or "" + if minetest.is_protected(pos, playername) then + -- only allow protection-owner to fire and configure + return + end + local meta = minetest.get_meta(pos) if fields.fire then @@ -219,7 +225,3 @@ register_spacecannon({ desc = "slow, heavy damage", ingredient = "spacecannon:cannon_yellow" }) - - - - diff --git a/digiline.lua b/digiline.lua index 03f1dd6..3f47e96 100644 --- a/digiline.lua +++ b/digiline.lua @@ -10,7 +10,7 @@ spacecannon.digiline_rules = { {x= 0,y= 1,z= 0},{x= 0,y=-1,z= 0}, -- along y above and below } -spacecannon.digiline_handler_get = function(pos, node, channel, msg) +spacecannon.digiline_handler_get = function(pos, node, channel) local meta = minetest.get_meta(pos) local input = meta:get_int("HV_EU_input") @@ -31,7 +31,7 @@ spacecannon.digiline_handler_get = function(pos, node, channel, msg) digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp) end -spacecannon.digiline_handler_fire = function(pos, node, channel, msg) +spacecannon.digiline_handler_fire = function(pos, node, channel) local meta = minetest.get_meta(pos) -- TODO: Add ability to set "target node" in the msg, and if its within diff --git a/util.lua b/util.lua index 912e58f..3315dc7 100644 --- a/util.lua +++ b/util.lua @@ -27,11 +27,13 @@ spacecannon.update_formspec = function(meta) end end -spacecannon.can_shoot = function(pos) +spacecannon.can_shoot = function() + -- arguments: pos return true end -spacecannon.can_destroy = function(pos) +spacecannon.can_destroy = function() + -- arguments: pos return true end @@ -173,5 +175,3 @@ spacecannon.facedir_to_down_dir = function(facing) {x=1, y=0, z=0}, {x=0, y=1, z=0}})[math.floor(facing/4)] end - -