Skip to content

Commit

Permalink
Add luacheck workflow and fix warnings (#1)
Browse files Browse the repository at this point in the history
* Add luacheck workflow and fix warnings

* xyz

Co-authored-by: OgelGames <[email protected]>

* Update .luacheckrc

Co-authored-by: OgelGames <[email protected]>

* Update chisel.lua

Co-authored-by: OgelGames <[email protected]>

---------

Co-authored-by: OgelGames <[email protected]>
  • Loading branch information
Niklp09 and OgelGames authored Apr 22, 2024
1 parent 38d4908 commit 354f003
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/luacheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: luacheck
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Luacheck
uses: lunarmodules/luacheck@master
23 changes: 7 additions & 16 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
unused_args = false
allow_defined_top = false

globals = {
"minetest",
"jonez",
"stairs",
"xpanes"
"jonez",
}

read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},

-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings",

-- MTG
"default", "sfinv", "creative",
"minetest",
"default",
"i3",
"stairs",
"unified_inventory",
"xpanes",
}
20 changes: 7 additions & 13 deletions chisel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ jonez.chisel.register_chiselable_stair_and_slab = function(node_subname, group_s
end

local function chisel_interact(player, pointed_thing, is_right_click)
if not player then return end
if pointed_thing.type ~= "node" then
return
end

local pos = pointed_thing.under
local is_sneak = player and player:get_player_control().sneak or false
local player_name = player and player:get_player_name()

-- A true player is required
if not player_name then
return
end
local is_sneak = player:get_player_control().sneak
local player_name = player:get_player_name()

-- Check for node protection
if minetest.is_protected(pos, player_name) then
Expand Down Expand Up @@ -91,24 +87,22 @@ local function chisel_interact(player, pointed_thing, is_right_click)
else
if is_sneak then
-- Backward cycle mode
for k,v in pairs(group) do
for _,v in pairs(group) do
if v == node_name then break end
new_style = k
new_node_name = v
end

if new_node_name == nil then
-- Not found? Go for the last element
for k,v in pairs(group) do
new_style = k
for _,v in pairs(group) do
new_node_name = v
end
end
else
-- Forward cycle mode
new_style , new_node_name = next(group,style)
new_node_name = select(2, next(group, style))
if new_node_name == nil then
new_style , new_node_name = next(group)
new_node_name = select(2, next(group))
end
end
end
Expand Down

0 comments on commit 354f003

Please sign in to comment.