Add luacheck and fix warnings

This commit is contained in:
Niklp 2023-11-26 17:58:57 +01:00 committed by SmallJoker
parent 53669f6fad
commit 5480f4c9df
5 changed files with 86 additions and 76 deletions

10
.github/workflows/luacheck.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: luacheck
on: [push, pull_request]
jobs:
luacheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Luacheck
uses: lunarmodules/luacheck@master

12
.luacheckrc Normal file
View File

@ -0,0 +1,12 @@
unused_args = false
max_line_length = 150
read_globals = {
"minetest",
"vector",
"ItemStack",
"default",
"tnt",
"mcl_sounds",
"mcl_explosions"
}

View File

@ -56,12 +56,6 @@ local crossbow_range = tonumber(minetest.settings:get("torch_bomb_base_crossbow_
local enable_crossbows = minetest.settings:get_bool("torch_bomb_enable_crossbows", true)
local torch_bow_uses = tonumber(minetest.settings:get("torch_bomb_base_crossbow_uses")) or 30
-- Detect creative mod
local creative_mod = minetest.get_modpath("creative")
-- Cache creative mode setting as fallback if creative mod not present
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
-- 12 torches grenade
local ico1 = {
vector.new(0.000000, -1.000000, 0.000000),
@ -336,7 +330,6 @@ local function embed_torch(target, placer, pos)
torch_def_on_place(ItemStack(torch_item), placer, target)
local target_pos = target.above
local dir_back = vector.normalize(vector.subtract(pos, target_pos))
local vel_back = vector.multiply(dir_back, 10)
minetest.add_particlespawner({
amount = math.random(1,6),
time = 0.1,
@ -706,17 +699,13 @@ if enable_grenade then
local lua_entity = obj:get_luaentity()
lua_entity.player_name = user:get_player_name()
minetest.sound_play({name="tnt_ignite"},
{
pos=player_pos,
object = object,
minetest.sound_play({name="tnt_ignite"}, {
pos = player_pos,
gain = 1.0,
max_hear_distance = 32,
},
true)
}, true)
if not ((creative_mod and creative.is_enabled_for(user:get_player_name())) or
creative_mode_cache) then
if not minetest.is_creative_enabled(user:get_player_name()) then
itemstack:set_count(itemstack:get_count() - 1)
end
@ -773,7 +762,7 @@ end
----------------------------------------------------------------------
-- Torch crossbows
local function register_torch_bow(name, desc, material, image, torch_bow_range, torch_bow_uses)
local function register_torch_bow(name, desc, material, image, torch_bow_range, local_torch_bow_uses)
minetest.register_tool("torch_bomb:torch_crossbow_" .. name, {
description = S("@1 Torch Crossbow", desc),
inventory_image = image,
@ -794,10 +783,9 @@ local function register_torch_bow(name, desc, material, image, torch_bow_range,
return
end
if not ((creative_mod and creative.is_enabled_for(user:get_player_name())) or
creative_mode_cache) then
if not minetest.is_creative_enabled(user:get_player_name()) then
inv:remove_item("main", {name=torch_item, count=1})
itemstack:add_wear(65535/(torch_bow_uses-1))
itemstack:add_wear(65535/(local_torch_bow_uses-1))
end
local dir = user:get_look_dir()

View File

@ -1,4 +1,4 @@
name = torch_bomb
description = Place torches throughout your entire surroundings with a torch bomb
depends =
optional_depends = mcl_core, mcl_sounds, mcl_explosions, mcl_tnt, default, tnt, creative, farming
min_minetest_version = 5.3.0