From dc6cc0b04a859c64ef1840c93bff023fa377ad28 Mon Sep 17 00:00:00 2001 From: David Leal Date: Sat, 16 Jan 2021 02:59:19 -0600 Subject: [PATCH] [LuaCheck]: Various changes and improvements (#65) * Add GitHub workflow * Fix LuaCheck warnings * Add build status badge on README.md --- .github/workflows/build.yml | 11 +++++++++++ .luacheckrc | 1 + README.md | 2 ++ internal.lua | 8 ++++---- inventory.lua | 2 +- lcd.lua | 11 +++++++---- 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..817e409 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,11 @@ +on: [push, pull_request] +name: build +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: lint + uses: Roang-zero1/factorio-mod-luacheck@master + with: + luacheckrc_url: "" diff --git a/.luacheckrc b/.luacheckrc index b356748..909b894 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -7,6 +7,7 @@ read_globals = { "pipeworks", "dump", "VoxelArea", + "ItemStack", } globals = { diff --git a/README.md b/README.md index 2d29282..a6c1405 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Digilines ========== +[![Build status](https://github.com/minetest-mods/digilines/workflows/build/badge.svg)](https://github.com/minetest-mods/digilines/actions) + - The minetest counterpart for bus systems like i2c, SPI, RS232, USB - - Minetest 5.0.0+ is required to use this mod. diff --git a/internal.lua b/internal.lua index 05c93fa..c9860b6 100644 --- a/internal.lua +++ b/internal.lua @@ -92,7 +92,7 @@ function digilines.transmit(pos, channel, msg, checked) return end checked[checkedID] = true - + digilines.vm_begin() local queue = queue_new() queue_enqueue(queue, pos) @@ -112,9 +112,9 @@ function digilines.transmit(pos, channel, msg, checked) for _, rule in ipairs(rules) do local nextPos = digilines.addPosRule(curPos, rule) if digilines.rules_link(curPos, nextPos) then - local checkedID = minetest.hash_node_position(nextPos) - if not checked[checkedID] then - checked[checkedID] = true + local checkedID2 = minetest.hash_node_position(nextPos) + if not checked[checkedID2] then + checked[checkedID2] = true queue_enqueue(queue, nextPos) end end diff --git a/inventory.lua b/inventory.lua index 86b1536..8af786f 100644 --- a/inventory.lua +++ b/inventory.lua @@ -229,7 +229,7 @@ minetest.register_node("digilines:chest", { last_inventory_take_index = index return stack:get_count() end, - on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + on_metadata_inventory_move = function(pos, _, from_index, _, to_index, count, player) -- See what would happen if we were to move the items back from in the -- opposite direction. In the event of a normal move, this must -- succeed, because a normal move subtracts some items from the from diff --git a/lcd.lua b/lcd.lua index ee3abf2..88b8e47 100644 --- a/lcd.lua +++ b/lcd.lua @@ -240,7 +240,7 @@ local prepare_writing = function(pos) if entity then set_texture(entity) rotate_text(pos) - end + end end local spawn_entity = function(pos) @@ -292,12 +292,12 @@ minetest.register_node("digilines:lcd", { end, on_construct = reset_meta, on_destruct = clearscreen, - on_punch = function(pos, node, puncher, pointed_thing) + on_punch = function(pos, _, puncher, _) if minetest.is_player(puncher) then spawn_entity(pos) end end, - on_rotate = function(pos, node, user, mode, new_param2) + on_rotate = function(pos, _, _, mode, new_param2) if mode ~= screwdriver.ROTATE_FACE then return false end @@ -340,7 +340,10 @@ minetest.register_craft({ output = "digilines:lcd 2", recipe = { {"default:steel_ingot", "digilines:wire_std_00000000", "default:steel_ingot"}, - {"mesecons_lightstone:lightstone_green_off","mesecons_lightstone:lightstone_green_off","mesecons_lightstone:lightstone_green_off"}, + {"mesecons_lightstone:lightstone_green_off", + "mesecons_lightstone:lightstone_green_off", + "mesecons_lightstone:lightstone_green_off"}, + {"default:glass","default:glass","default:glass"} } })