Skip to content

Commit 49e84e4

Browse files
authored
Add luacheck (#1)
* add luacheck workflow and config * replace 'digiline' with 'digilines' * fix whitespace * fix most variable warnings * piston.lua and movestone.lua have inline ignores for some hard to fix code * increase line length for now
1 parent 0233317 commit 49e84e4

19 files changed

+101
-96
lines changed

.github/workflows/luacheck.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: luacheck
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@master
8+
- name: apt
9+
run: sudo apt-get install -y luarocks
10+
- name: luacheck install
11+
run: luarocks install --local luacheck
12+
- name: luacheck run
13+
run: $HOME/.luarocks/bin/luacheck ./

.luacheckrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
unused_args = false
2+
max_line_length = 300 -- TODO: fix line lengths
3+
4+
globals = {
5+
"minetest",
6+
"digistuff",
7+
"digilines",
8+
}
9+
10+
read_globals = {
11+
-- Builtin
12+
table = {fields = {"copy"}},
13+
14+
"vector",
15+
"ItemStack",
16+
"DIR_DELIM",
17+
18+
-- Mod Deps
19+
"default",
20+
"mesecon",
21+
"screwdriver",
22+
}

camera.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ minetest.register_node("digistuff:camera", {
77
"digistuff_camera_back.png",
88
"digistuff_camera_front.png",
99
},
10-
digiline =
11-
{
10+
digiline = {
1211
receptor = {}
1312
},
1413
_digistuff_channelcopier_fieldname = "channel",
@@ -75,15 +74,14 @@ minetest.register_abm({
7574
local players_found = {}
7675
local objs = minetest.get_objects_inside_radius(spot,radius)
7776
if objs then
78-
local _,obj
7977
for _,obj in ipairs(objs) do
8078
if obj:is_player() then
8179
table.insert(players_found,obj:get_player_name())
8280
found_any = true
8381
end
8482
end
8583
if found_any then
86-
digiline:receptor_send({x=pos.x,y=pos.y-1,z=pos.z}, digiline.rules.default, channel, players_found)
84+
digilines.receptor_send({x=pos.x,y=pos.y-1,z=pos.z}, digilines.rules.default, channel, players_found)
8785
end
8886
end
8987
end

cardreader.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ minetest.register_craftitem("digistuff:card",{
2828
local data = meta:get_string("writedata")
2929
meta:set_int("writepending",0)
3030
meta:set_string("infotext","Ready to Read")
31-
digiline:receptor_send(pos,cardreader_rules,channel,{event = "write",})
31+
digilines.receptor_send(pos,cardreader_rules,channel,{event = "write",})
3232
stackmeta:set_string("data",data)
3333
stackmeta:set_string("description",string.format("Magnetic Card (%s)",meta:get_string("writedescription")))
3434
return stack
3535
else
36-
local channel = meta:get_string("channel")
3736
local data = stackmeta:get_string("data")
38-
digiline:receptor_send(pos,cardreader_rules,channel,{event = "read",data = data,})
37+
digilines.receptor_send(pos,cardreader_rules,channel,{event = "read",data = data,})
3938
end
4039
end,
4140
})

conductors.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ minetest.register_node("digistuff:junctionbox", {
7979
paramtype2 = "facedir",
8080
groups = {cracky = 3},
8181
is_ground_content = false,
82-
paramtype = "light",
8382
drawtype = "nodebox",
8483
node_box = {
8584
type = "fixed",
@@ -124,7 +123,6 @@ minetest.register_node("digistuff:receiver", {
124123
groups = {dig_immediate = 3,not_in_creative_inventory = 1,},
125124
drop = "digilines:wire_std_00000000",
126125
is_ground_content = false,
127-
paramtype = "light",
128126
paramtype2 = "facedir",
129127
walkable = false,
130128
drawtype = "nodebox",
@@ -190,7 +188,6 @@ minetest.register_node("digistuff:vertical_tap", {
190188
paramtype = "light",
191189
groups = {dig_immediate = 3,vertical_digiline = 1,},
192190
is_ground_content = false,
193-
paramtype = "light",
194191
drawtype = "nodebox",
195192
node_box = {
196193
type = "fixed",
@@ -228,7 +225,6 @@ minetest.register_node("digistuff:vertical_bottom", {
228225
paramtype = "light",
229226
groups = {dig_immediate = 3,vertical_digiline = 1,},
230227
is_ground_content = false,
231-
paramtype = "light",
232228
drawtype = "nodebox",
233229
node_box = {
234230
type = "fixed",
@@ -267,7 +263,6 @@ minetest.register_node("digistuff:vertical_middle", {
267263
groups = {dig_immediate = 3,not_in_creative_inventory = 1,vertical_digiline = 1,},
268264
drop = "digistuff:vertical_bottom",
269265
is_ground_content = false,
270-
paramtype = "light",
271266
walkable = false,
272267
drawtype = "nodebox",
273268
node_box = {
@@ -296,7 +291,6 @@ minetest.register_node("digistuff:vertical_top", {
296291
groups = {dig_immediate = 3,not_in_creative_inventory = 1,vertical_digiline = 1,},
297292
drop = "digistuff:vertical_bottom",
298293
is_ground_content = false,
299-
paramtype = "light",
300294
drawtype = "nodebox",
301295
node_box = {
302296
type = "fixed",
@@ -336,7 +330,6 @@ minetest.register_node("digistuff:insulated_straight", {
336330
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple,
337331
groups = {dig_immediate = 3,},
338332
is_ground_content = false,
339-
paramtype = "light",
340333
drawtype = "nodebox",
341334
node_box = {
342335
type = "fixed",
@@ -382,7 +375,6 @@ minetest.register_node("digistuff:insulated_tjunction", {
382375
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple,
383376
groups = {dig_immediate = 3,},
384377
is_ground_content = false,
385-
paramtype = "light",
386378
drawtype = "nodebox",
387379
node_box = {
388380
type = "fixed",
@@ -430,7 +422,6 @@ minetest.register_node("digistuff:insulated_corner", {
430422
on_rotate = minetest.get_modpath("screwdriver") and screwdriver.rotate_simple,
431423
groups = {dig_immediate = 3,},
432424
is_ground_content = false,
433-
paramtype = "light",
434425
drawtype = "nodebox",
435426
node_box = {
436427
type = "fixed",
@@ -475,7 +466,6 @@ minetest.register_node("digistuff:insulated_fourway", {
475466
walkable = false,
476467
groups = {dig_immediate = 3,},
477468
is_ground_content = false,
478-
paramtype = "light",
479469
drawtype = "nodebox",
480470
node_box = {
481471
type = "fixed",

controller.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ local function process_inputs(pos)
3131
local name = players_on_controller[hash]
3232
local player = minetest.get_player_by_name(name)
3333
if not player then
34-
digiline:receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
34+
digilines.receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
3535
minetest.get_meta(pos):set_string("infotext","Digilines Game Controller Ready\n(right-click to use)")
3636
players_on_controller[hash] = nil
3737
return
3838
end
3939
local distance = vector.distance(pos,player:get_pos())
4040
if distance > 1 then
41-
digiline:receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
41+
digilines.receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
4242
minetest.get_meta(pos):set_string("infotext","Digilines Game Controller Ready\n(right-click to use)")
4343
player:set_physics_override({speed = 1,jump = 1,})
4444
players_on_controller[hash] = nil
@@ -61,10 +61,10 @@ local function process_inputs(pos)
6161
last_seen_inputs[name] = inputs
6262
if send_needed then
6363
local channel = meta:get_string("channel")
64-
local inputs = table.copy(inputs)
64+
inputs = table.copy(inputs)
6565
inputs.look_vector = player:get_look_dir()
6666
inputs.name = name
67-
digiline:receptor_send(pos,digiline_rules,channel,inputs)
67+
digilines.receptor_send(pos,digiline_rules,channel,inputs)
6868
end
6969
end
7070

@@ -80,7 +80,7 @@ local function release_player(pos)
8080
meta:set_string("infotext","Digilines Game Controller Ready\n(right-click to use)")
8181
last_seen_inputs[players_on_controller[hash]] = nil
8282
players_on_controller[hash] = nil
83-
digiline:receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
83+
digilines.receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
8484
end
8585

8686
local function trap_player(pos,player)
@@ -181,7 +181,6 @@ minetest.register_node("digistuff:controller_programmed", {
181181
toggle_trap_player(pos,clicker)
182182
end
183183
end,
184-
_digistuff_channelcopier_fieldname = "channel",
185184
digiline = {
186185
receptor = {},
187186
wire = {
@@ -222,7 +221,7 @@ minetest.register_lbm({
222221
action = function(pos)
223222
if not players_on_controller[minetest.hash_node_position(pos)] then
224223
local meta = minetest.get_meta(pos)
225-
digiline:receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
224+
digilines.receptor_send(pos,digiline_rules,meta:get_string("channel"),"player_left")
226225
meta:set_string("infotext","Digilines Game Controller Ready\n(right-click to use)")
227226
end
228227
end,

detector.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ minetest.register_node("digistuff:detector", {
22
tiles = {
33
"digistuff_digidetector.png"
44
},
5-
digiline =
6-
{
5+
digiline = {
76
receptor = {}
87
},
98
groups = {cracky=2},
@@ -40,15 +39,14 @@ minetest.register_abm({
4039
if not radius or not tonumber(radius) or tonumber(radius) < 1 or tonumber(radius) > 10 then radius = 6 end
4140
local objs = minetest.get_objects_inside_radius(pos, radius)
4241
if objs then
43-
local _,obj
4442
for _,obj in ipairs(objs) do
4543
if obj:is_player() then
4644
table.insert(players_found,obj:get_player_name())
4745
found_any = true
4846
end
4947
end
5048
if found_any then
51-
digiline:receptor_send(pos, digiline.rules.default, channel, players_found)
49+
digilines.receptor_send(pos, digilines.rules.default, channel, players_found)
5250
end
5351
end
5452
end

gpu.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ local function rgbtohsv(r,g,b)
2020
r = r/255
2121
g = g/255
2222
b = b/255
23-
max = math.max(r,g,b)
24-
min = math.min(r,g,b)
25-
delta = max-min
23+
local max = math.max(r,g,b)
24+
local min = math.min(r,g,b)
25+
local delta = max-min
2626
local hue = 0
2727
if delta > 0 then
2828
if max == r then
@@ -73,7 +73,7 @@ local function hsvtorgb(h,s,v)
7373
b = c
7474
else
7575
r = c
76-
b = x
76+
b = x
7777
end
7878
r = r+m
7979
g = g+m
@@ -199,7 +199,7 @@ local function runcommand(pos,meta,command)
199199
if string.len(buffer) == 0 then return end
200200
buffer = minetest.deserialize(buffer)
201201
if type(buffer) == "table" then
202-
digiline:receptor_send(pos,digiline.rules.default,command.channel,buffer)
202+
digilines.receptor_send(pos,digilines.rules.default,command.channel,buffer)
203203
end
204204
elseif command.command == "drawrect" then
205205
if type(command.buffer) ~= "number" or type(command.x1) ~= "number" or type(command.y1) ~= "number" or type(command.x2) ~= "number" or type(command.y2) ~= "number" then return end
@@ -400,8 +400,7 @@ minetest.register_node("digistuff:gpu", {
400400
local meta = minetest.get_meta(pos)
401401
if fields.channel then meta:set_string("channel",fields.channel) end
402402
end,
403-
digiline =
404-
{
403+
digiline = {
405404
receptor = {},
406405
effector = {
407406
action = function(pos,node,channel,msg)

ioexpander.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ local ioexp_digiline_send = function(pos)
6565
}
6666
local outstate = explode_port_states(meta:get_int("outstate"))
6767
for k,v in pairs(outstate) do port[k] = port[k] or v end
68-
digiline:receptor_send(pos,digiline.rules.default,channel,port)
68+
digilines.receptor_send(pos,digilines.rules.default,channel,port)
6969
end
7070

7171
local ioexp_handle_digilines = function(pos,node,channel,msg)
@@ -99,7 +99,6 @@ local ioexp_handle_mesecons = function(pos,_,rule,state)
9999
local meta = minetest.get_meta(pos)
100100
local port = ioexp_rule_to_port(rule)
101101
if not port then return end
102-
local meta = minetest.get_meta(pos)
103102
meta:set_int(port.."on",state == "on" and 1 or 0)
104103
ioexp_digiline_send(pos)
105104
end

memory.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,15 @@ minetest.register_node("digistuff:ram", {
4444
local meta = minetest.get_meta(pos)
4545
if fields.channel then meta:set_string("channel",fields.channel) end
4646
end,
47-
digiline =
48-
{
47+
digiline = {
4948
receptor = {},
5049
effector = {
5150
action = function(pos,node,channel,msg)
5251
local meta = minetest.get_meta(pos)
5352
if meta:get_string("channel") ~= channel or type(msg) ~= "table" then return end
5453
if msg.command == "read" then
5554
if type(msg.address) == "number" and msg.address >= 0 and msg.address <= 31 then
56-
digiline:receptor_send(pos,digiline.rules.default,channel,meta:get_string(string.format("data%02i",math.floor(msg.address))))
55+
digilines.receptor_send(pos,digilines.rules.default,channel,meta:get_string(string.format("data%02i",math.floor(msg.address))))
5756
end
5857
elseif msg.command == "write" then
5958
if type(msg.address) == "number" and msg.address >= 0 and msg.address <= 31 and type(msg.data) == "string" then
@@ -137,16 +136,15 @@ minetest.register_node("digistuff:eeprom", {
137136
local meta = minetest.get_meta(pos)
138137
if fields.channel then meta:set_string("channel",fields.channel) end
139138
end,
140-
digiline =
141-
{
139+
digiline = {
142140
receptor = {},
143141
effector = {
144142
action = function(pos,node,channel,msg)
145143
local meta = minetest.get_meta(pos)
146144
if meta:get_string("channel") ~= channel or type(msg) ~= "table" then return end
147145
if msg.command == "read" then
148146
if type(msg.address) == "number" and msg.address >= 0 and msg.address <= 31 then
149-
digiline:receptor_send(pos,digiline.rules.default,channel,meta:get_string(string.format("data%02i",math.floor(msg.address))))
147+
digilines.receptor_send(pos,digilines.rules.default,channel,meta:get_string(string.format("data%02i",math.floor(msg.address))))
150148
end
151149
elseif msg.command == "write" then
152150
if type(msg.address) == "number" and msg.address >= 0 and msg.address <= 31 and type(msg.data) == "string" then

0 commit comments

Comments
 (0)