Skip to content

Commit 419d663

Browse files
add luacheck workflow
1 parent 3475d4d commit 419d663

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

.github/workflows/luacheck.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: luacheck
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 10
10+
11+
steps:
12+
- uses: actions/checkout@v2.3.4
13+
- name: apt
14+
run: sudo apt-get install -y luarocks
15+
- name: luacheck install
16+
run: luarocks install --local luacheck
17+
- name: luacheck run
18+
run: $HOME/.luarocks/bin/luacheck ./

.luacheckrc

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
unused_args = false
2-
allow_defined_top = true
3-
41
globals = {
5-
"minetest",
62
"spacecannon"
73
}
84

@@ -12,7 +8,7 @@ read_globals = {
128
table = {fields = {"copy", "getn"}},
139

1410
-- mod deps
15-
"technic", "default",
11+
"technic", "default", "digilines",
1612

1713
-- Minetest
1814
"minetest",

cannon.lua

+11-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ local register_spacecannon = function(def)
4949
if goes_through then
5050
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
5151
local collided = false
52-
for k, obj in pairs(objs) do
52+
for _, obj in pairs(objs) do
5353
if obj:get_luaentity() ~= nil and obj:get_luaentity().name ~= self.name then
5454
collided = true
5555
obj:punch(self.object, 1.0, {
@@ -72,7 +72,7 @@ local register_spacecannon = function(def)
7272
end
7373
end,
7474

75-
on_activate = function(self, staticdata)
75+
on_activate = function(self)
7676
minetest.after(def.timeout,
7777
function(me)
7878
me.object:remove()
@@ -103,7 +103,7 @@ local register_spacecannon = function(def)
103103
legacy_facedir_simple = true,
104104

105105
mesecons = {effector = {
106-
action_on = function (pos, node)
106+
action_on = function (pos)
107107
spacecannon.fire(pos, def.color, def.speed, def.range)
108108
end
109109
}},
@@ -140,7 +140,7 @@ local register_spacecannon = function(def)
140140
spacecannon.update_formspec(meta)
141141
end,
142142

143-
technic_run = function(pos, node)
143+
technic_run = function(pos)
144144
local meta = minetest.get_meta(pos)
145145
local eu_input = meta:get_int("HV_EU_input")
146146
local demand = meta:get_int("HV_EU_demand")
@@ -159,7 +159,13 @@ local register_spacecannon = function(def)
159159
end
160160
end,
161161

162-
on_receive_fields = function(pos, formname, fields, sender)
162+
on_receive_fields = function(pos, _, fields, sender)
163+
local playername = sender and sender:get_player_name() or ""
164+
if minetest.is_protected(pos, playername) then
165+
-- only allow protection-owner to fire and configure
166+
return
167+
end
168+
163169
local meta = minetest.get_meta(pos)
164170

165171
if fields.fire then
@@ -219,7 +225,3 @@ register_spacecannon({
219225
desc = "slow, heavy damage",
220226
ingredient = "spacecannon:cannon_yellow"
221227
})
222-
223-
224-
225-

digiline.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spacecannon.digiline_rules = {
1010
{x= 0,y= 1,z= 0},{x= 0,y=-1,z= 0}, -- along y above and below
1111
}
1212

13-
spacecannon.digiline_handler_get = function(pos, node, channel, msg)
13+
spacecannon.digiline_handler_get = function(pos, node, channel)
1414
local meta = minetest.get_meta(pos)
1515

1616
local input = meta:get_int("HV_EU_input")
@@ -31,7 +31,7 @@ spacecannon.digiline_handler_get = function(pos, node, channel, msg)
3131
digilines.receptor_send(pos, spacecannon.digiline_rules, channel, resp)
3232
end
3333

34-
spacecannon.digiline_handler_fire = function(pos, node, channel, msg)
34+
spacecannon.digiline_handler_fire = function(pos, node, channel)
3535
local meta = minetest.get_meta(pos)
3636

3737
-- TODO: Add ability to set "target node" in the msg, and if its within

util.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ spacecannon.update_formspec = function(meta)
2727
end
2828
end
2929

30-
spacecannon.can_shoot = function(pos)
30+
spacecannon.can_shoot = function()
31+
-- arguments: pos
3132
return true
3233
end
3334

34-
spacecannon.can_destroy = function(pos)
35+
spacecannon.can_destroy = function()
36+
-- arguments: pos
3537
return true
3638
end
3739

@@ -173,5 +175,3 @@ spacecannon.facedir_to_down_dir = function(facing)
173175
{x=1, y=0, z=0},
174176
{x=0, y=1, z=0}})[math.floor(facing/4)]
175177
end
176-
177-

0 commit comments

Comments
 (0)