From dcc46a9c6bc2e89dd30a30be8e3480a2542cfbf0 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Mon, 10 Feb 2020 10:47:36 +0100 Subject: [PATCH] luacheck and fixes --- .github/workflows/luacheck.yml | 17 +++++++++++++++++ .luacheckrc | 20 ++++++++++++++++++++ teleport.lua | 19 +++++++++++++------ 3 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/luacheck.yml create mode 100644 .luacheckrc diff --git a/.github/workflows/luacheck.yml b/.github/workflows/luacheck.yml new file mode 100644 index 0000000..a03fe92 --- /dev/null +++ b/.github/workflows/luacheck.yml @@ -0,0 +1,17 @@ +name: luacheck + +on: [push] + +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..ca33553 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,20 @@ +unused_args = false +allow_defined_top = true + +globals = { + "telemosaic" +} + +read_globals = { + -- Stdlib + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + -- Minetest + "minetest", + "vector", "ItemStack", + "dump", + + -- Deps + "default" +} diff --git a/teleport.lua b/teleport.lua index 364063a..c408293 100644 --- a/teleport.lua +++ b/teleport.lua @@ -81,7 +81,10 @@ local function extender_place(placepos, placer, itemstack, pointed_thing) else local count = math.ceil(dist - (C.beacon_range + extended)) - minetest.chat_send_player(placer:get_player_name(), "You still need to add extensions for "..count.." nodes" ) + minetest.chat_send_player( + placer:get_player_name(), + "You still need to add extensions for "..count.." nodes" + ) end end @@ -158,7 +161,7 @@ end -- teleports the player with given telemosaic pos function do_teleport(pos, player) - + -- prevent teleport spamming local player_name = player:get_player_name() if recent_teleports[player_name] then @@ -221,15 +224,15 @@ function do_teleport(pos, player) texture = "telemosaic_particle_arrival.png", glow = 15, }) - + -- prevent teleport spamming recent_teleports[player_name] = true - minetest.after(1, + minetest.after(1, function(name) recent_teleports[name] = nil end, player_name) - else + -- else -- beacon is in error, one way or another. -- but don't swap it out - we won't get it back otherwise! end @@ -403,7 +406,11 @@ for num, strength in ipairs(strengths) do string.format('telemosaic_extender_%s.png^[colorize:%s', strength, c.value), }, paramtype = 'light', - groups = { cracky = 2, [string.format('telemosaic_extender_%s', strength)] = 1, not_in_creative_inventory = 1 }, + groups = { + cracky = 2, + [string.format('telemosaic_extender_%s', strength)] = 1, + not_in_creative_inventory = 1 + }, after_place_node = extender_place, after_dig_node = extender_dig, })