add .luacheckrc and fix common issues

This commit is contained in:
Thomas Rudin 2019-11-23 20:24:43 +01:00
parent 09e6576f13
commit 7bc00cb731
3 changed files with 143 additions and 96 deletions

22
.luacheckrc Normal file
View File

@ -0,0 +1,22 @@
globals = {
"horror"
}
read_globals = {
-- Stdlib
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Minetest
"vector", "ItemStack",
"dump", "VoxelArea",
-- deps
"minetest",
"default",
"tnt",
"bucket",
"stairs",
"mobs"
}

View File

@ -77,8 +77,8 @@ minetest.register_globalstep(function()
end) end)
--dark setting --dark setting
dark = true local dark = true
dark_dark = true local dark_dark = true
--new style, set to false for the nodebox candle and candlestick --new style, set to false for the nodebox candle and candlestick
local new_style = true local new_style = true
@ -88,7 +88,7 @@ horror = {}
--Vignette overlay from Vignette mod by TriBlade9(license MIT) --Vignette overlay from Vignette mod by TriBlade9(license MIT)
--permanent dawn --permanent dawn
if dark == true then if dark then
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
minetest.after(0,function() minetest.after(0,function()
player:override_day_night_ratio(0.41) player:override_day_night_ratio(0.41)
@ -123,7 +123,10 @@ minetest.register_on_joinplayer(function(player)
minetest.after(50, function() minetest.after(50, function()
if player ~= nil then if player ~= nil then
local playerpos = player:getpos() local playerpos = player:getpos()
tnt.boom({x=playerpos.x, y=playerpos.y+1, z=playerpos.z}, {damage_radius=5,radius=4,ignore_protection=false, disable_playerdamage=false}) tnt.boom(
{x=playerpos.x, y=playerpos.y+1, z=playerpos.z},
{damage_radius=5,radius=4,ignore_protection=false, disable_playerdamage=false}
)
end end
end) end)
end end
@ -168,7 +171,7 @@ minetest.register_node("horror:blood_flowing", {
liquidtype = "flowing", liquidtype = "flowing",
liquid_alternative_flowing = "horror:blood_flowing", liquid_alternative_flowing = "horror:blood_flowing",
liquid_alternative_source = "horror:bloodsource", liquid_alternative_source = "horror:bloodsource",
liquid_viscosity = WATER_VISC, liquid_viscosity = 1,
freezemelt = "default:snow", freezemelt = "default:snow",
post_effect_color = {a=70, r=200, g=70, b=70}, post_effect_color = {a=70, r=200, g=70, b=70},
groups = {liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1}, groups = {liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1},
@ -200,7 +203,7 @@ minetest.register_node("horror:bloodsource", {
liquidtype = "source", liquidtype = "source",
liquid_alternative_flowing = "horror:blood_flowing", liquid_alternative_flowing = "horror:blood_flowing",
liquid_alternative_source = "horror:bloodsource", liquid_alternative_source = "horror:bloodsource",
liquid_viscosity = WATER_VISC, liquid_viscosity = 1,
freezemelt = "default:ice", freezemelt = "default:ice",
post_effect_color = {a=70, r=200, g=70, b=70}, post_effect_color = {a=70, r=200, g=70, b=70},
groups = {liquid=3, puts_out_fire=1, freezes=1} groups = {liquid=3, puts_out_fire=1, freezes=1}
@ -380,16 +383,31 @@ end
--ABMs --ABMs
local punch_entities = {}
punch_entities["horror:ghost"] = true
punch_entities["horror:centipede"] = true
punch_entities["horror:spider"] = true
punch_entities["horror:demon"] = true
punch_entities["horror:pinky"] = true
punch_entities["horror:skull"] = true
punch_entities["horror:mancubus"] = true
punch_entities["horror:manticore"] = true
punch_entities["horror:shadow"] = true
punch_entities["horror:cacodemon"] = true
punch_entities["horror:mogall"] = true
punch_entities["creatures:zombie"] = true
minetest.register_abm({ minetest.register_abm({
nodenames = {"horror:sunorb", "horror:gloworb"}, nodenames = {"horror:sunorb", "horror:gloworb"},
interval = 5, interval = 5,
chance = 1, chance = 1,
action = function(pos) action = function(pos)
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 5) local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 5)
for k, obj in pairs(objs) do for _, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then if obj:get_luaentity() ~= nil then
local ent = obj:get_luaentity().name local ent = obj:get_luaentity().name
if ent == "horror:ghost" or ent == "horror:centipede" or ent == "horror:spider" or ent == "horror:demon" or ent == "horror:pinky" or ent == "horror:skull" or ent == "horror:mancubus" or ent == "horror:manticore" or ent == "horror:shadow" or ent == "horror:cacodemon" or ent == "horror:mogall" or ent == "creatures:zombie" then if punch_entities[ent] then
obj:punch(obj, 0.5, { obj:punch(obj, 0.5, {
full_punch_interval=0.5, full_punch_interval=0.5,
damage_groups={fleshy=4}, damage_groups={fleshy=4},
@ -414,7 +432,7 @@ minetest.register_abm({
nodenames = {"horror:fire"}, nodenames = {"horror:fire"},
interval = 1, interval = 1,
chance = 2, chance = 2,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 30, amount = 30,
time = 4, time = 4,
@ -448,7 +466,7 @@ minetest.register_abm({
nodenames = {"horror:lantern"}, nodenames = {"horror:lantern"},
interval = 1, interval = 1,
chance = 2, chance = 2,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 10, amount = 10,
time = 4, time = 4,
@ -472,7 +490,7 @@ minetest.register_abm({
nodenames = {"horror:fountain"}, nodenames = {"horror:fountain"},
interval = 1, interval = 1,
chance = 2, chance = 2,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 59, amount = 59,
time = 4, time = 4,
@ -497,7 +515,7 @@ minetest.register_abm({
nodenames = {"horror:flames"}, nodenames = {"horror:flames"},
interval = 3, interval = 3,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 70, amount = 70,
time = 4, time = 4,
@ -522,7 +540,7 @@ minetest.register_abm({
nodenames = {"horror:head"}, nodenames = {"horror:head"},
interval = 2, interval = 2,
chance = 5, chance = 5,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 2, amount = 2,
time = 4, time = 4,
@ -547,7 +565,7 @@ minetest.register_abm({
nodenames = {"horror:clock"}, nodenames = {"horror:clock"},
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos)
minetest.sound_play("clock", minetest.sound_play("clock",
{gain = 3, max_hear_distance = 1, loop = false}) {gain = 3, max_hear_distance = 1, loop = false})
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
@ -574,7 +592,7 @@ minetest.register_abm({
nodenames = {"horror:roach_spawner"}, nodenames = {"horror:roach_spawner"},
interval = 2, interval = 2,
chance = 2, chance = 2,
action = function(pos, node) action = function(pos)
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 10, amount = 10,
time = 4, time = 4,
@ -598,28 +616,29 @@ minetest.register_abm({
nodenames = {"horror:cactus"}, nodenames = {"horror:cactus"},
interval = 10, interval = 10,
chance = 150, chance = 150,
action = function(pos, node) action = function(pos)
local num = math.random(1,4) local num = math.random(1,4)
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" or minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "horror:cactus" then if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" or
minetest.env:set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="horror:cactus"}) minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "horror:cactus" then
minetest.env:remove_node(pos) minetest.env:set_node({x=pos.x, y=pos.y-1, z=pos.z}, {name="horror:cactus"})
minetest.env:remove_node(pos)
end end
if num == 1 then if num == 1 then
if minetest.get_node({x=pos.x-2, y=pos.y, z=pos.z}).name == "air" then if minetest.get_node({x=pos.x-2, y=pos.y, z=pos.z}).name == "air" then
minetest.env:set_node({x=pos.x-2, y=pos.y, z=pos.z}, {name="horror:cactus"}) minetest.env:set_node({x=pos.x-2, y=pos.y, z=pos.z}, {name="horror:cactus"})
end end
elseif num == 2 then elseif num == 2 then
if minetest.get_node({x=pos.x+2, y=pos.y, z=pos.z}).name == "air" then if minetest.get_node({x=pos.x+2, y=pos.y, z=pos.z}).name == "air" then
minetest.env:set_node({x=pos.x+2, y=pos.y, z=pos.z}, {name="horror:cactus"}) minetest.env:set_node({x=pos.x+2, y=pos.y, z=pos.z}, {name="horror:cactus"})
end end
elseif num == 3 then elseif num == 3 then
if minetest.get_node({x=pos.x, y=pos.y, z=pos.z-2}).name == "air" then if minetest.get_node({x=pos.x, y=pos.y, z=pos.z-2}).name == "air" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z-2}, {name="horror:cactus"}) minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z-2}, {name="horror:cactus"})
end end
elseif num == 4 then elseif num == 4 then
if minetest.get_node({x=pos.x, y=pos.y, z=pos.z+2}).name == "air" then if minetest.get_node({x=pos.x, y=pos.y, z=pos.z+2}).name == "air" then
minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z+2}, {name="horror:cactus"}) minetest.env:set_node({x=pos.x, y=pos.y, z=pos.z+2}, {name="horror:cactus"})
end end
end end
end end
}) })
@ -698,7 +717,7 @@ minetest.register_node("horror:sunorb", {
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2} fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
}, },
groups = {cracky=3,dig_immediate=3}, groups = {cracky=3,dig_immediate=3},
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer)
if placer:is_player() then if placer:is_player() then
minetest.set_node(pos, {name="horror:sunorb", param2=1}) minetest.set_node(pos, {name="horror:sunorb", param2=1})
end end
@ -765,7 +784,7 @@ minetest.register_node("horror:portal", {
type = "wallmounted", type = "wallmounted",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5} fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}
}, },
on_construct = function(pos, node, _) on_construct = function(pos)
minetest.after(1, function() minetest.after(1, function()
minetest.env:add_entity(pos, "horror:pinky") minetest.env:add_entity(pos, "horror:pinky")
minetest.remove_node(pos) minetest.remove_node(pos)
@ -1488,7 +1507,7 @@ minetest.register_node("horror:radio", {
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=1}, groups = {oddly_breakable_by_hand=1},
on_rightclick = function(pos) on_rightclick = function()
minetest.sound_play("Undersea_Garden", minetest.sound_play("Undersea_Garden",
{gain = 0.5, max_hear_distance = 1, loop = false}) {gain = 0.5, max_hear_distance = 1, loop = false})
end, end,

View File

@ -22,7 +22,7 @@ mobs:register_arrow("horror:fireball", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self)
self.object:remove() self.object:remove()
end, end,
}) })
@ -49,7 +49,7 @@ mobs:register_arrow("horror:fireball_2", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self)
self.object:remove() self.object:remove()
end, end,
}) })
@ -79,7 +79,7 @@ mobs:register_arrow("horror:fireball_3", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(_, pos)
mobs:explosion(pos, 1, 1, 1) mobs:explosion(pos, 1, 1, 1)
end, end,
}) })
@ -106,7 +106,7 @@ mobs:register_arrow("horror:rocket", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(_, pos)
mobs:explosion(pos, 2, 1, 1) mobs:explosion(pos, 2, 1, 1)
end, end,
}) })
@ -134,7 +134,7 @@ mobs:register_arrow("horror:fireball_3", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self)
self.object:remove() self.object:remove()
end, end,
}) })
@ -161,7 +161,7 @@ mobs:register_arrow("horror:rocket", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self)
self.object:remove() self.object:remove()
end, end,
}) })
@ -189,7 +189,7 @@ mobs:register_arrow("horror:fireball_4", {
}, nil) }, nil)
end, end,
hit_node = function(self, pos, node) hit_node = function(self)
self.object:remove() self.object:remove()
end, end,
}) })
@ -331,7 +331,7 @@ mobs:register_mob("horror:centipede_head", {
-- get head position and define a few temp variables -- get head position and define a few temp variables
local pos = self.object:getpos() local pos = self.object:getpos()
local obj, obj2, ent local obj, obj2, obj3, obj4, obj5, obj6, ent
-- add body and make it follow head -- add body and make it follow head
obj = minetest.add_entity({x=pos.x+1, y=pos.y, z=pos.z}, "horror:centipede_body") obj = minetest.add_entity({x=pos.x+1, y=pos.y, z=pos.z}, "horror:centipede_body")
@ -471,7 +471,7 @@ mobs:register_mob("horror:ghost", {
on_rightclick = function(self, clicker) on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item():get_name() local item = clicker:get_wielded_item():get_name()
if item == "horror:ring" then if item == "horror:ring" then
pos = self.object:getpos() local pos = self.object:getpos()
local obj = minetest.env:add_entity(pos, "horror:ghost_friendly") local obj = minetest.env:add_entity(pos, "horror:ghost_friendly")
local ghost = obj:get_luaentity() local ghost = obj:get_luaentity()
ghost.tamed = true ghost.tamed = true
@ -551,7 +551,10 @@ mobs:register_mob("horror:ghost_friendly", {
}, },
}) })
mobs:register_spawn("horror:ghost", {"default:snowblock","default:sand", "default:dirt_with_snow"}, 20, 0, 15000, 2, 31000) mobs:register_spawn("horror:ghost",
{"default:snowblock","default:sand", "default:dirt_with_snow"},
20, 0, 15000, 2, 31000
)
mobs:register_egg("horror:ghost", "Ghost", "default_snow.png", 1) mobs:register_egg("horror:ghost", "Ghost", "default_snow.png", 1)
@ -747,7 +750,7 @@ mobs:register_mob("horror:skull", {
fly = true, fly = true,
do_custom = function(self) do_custom = function(self)
local apos = self.object:getpos() local apos = self.object:getpos()
local part = minetest.add_particlespawner( minetest.add_particlespawner(
12, --amount 12, --amount
0.3, --time 0.3, --time
{x=apos.x-0.3, y=apos.y+0.6, z=apos.z-0.3}, --minpos {x=apos.x-0.3, y=apos.y+0.6, z=apos.z-0.3}, --minpos
@ -925,7 +928,7 @@ mobs:register_mob("horror:shadow", {
view_range = 30, view_range = 30,
do_custom = function(self) do_custom = function(self)
local apos = self.object:getpos() local apos = self.object:getpos()
local part = minetest.add_particlespawner( minetest.add_particlespawner(
1, --amount 1, --amount
0.3, --time 0.3, --time
{x=apos.x-0.3, y=apos.y+0.3, z=apos.z-0.3}, --minpos {x=apos.x-0.3, y=apos.y+0.3, z=apos.z-0.3}, --minpos
@ -987,7 +990,7 @@ mobs:register_mob("horror:mothman", {
fly = true, fly = true,
do_custom = function(self) do_custom = function(self)
local apos = self.object:getpos() local apos = self.object:getpos()
local part = minetest.add_particlespawner( minetest.add_particlespawner(
1, --amount 1, --amount
0.3, --time 0.3, --time
{x=apos.x-0.3, y=apos.y-0.3, z=apos.z-0.3}, --minpos {x=apos.x-0.3, y=apos.y-0.3, z=apos.z-0.3}, --minpos
@ -1184,7 +1187,10 @@ mobs:register_mob("horror:werewolf", {
}, },
}) })
mobs:register_spawn("horror:werewolf", {"default:dirt_with_grass","horror:mud","default:gravel"}, 20, 0, 35000, 2, 31000) mobs:register_spawn("horror:werewolf",
{"default:dirt_with_grass","horror:mud","default:gravel"},
20, 0, 35000, 2, 31000
)
mobs:register_egg("horror:werewolf", "Werewolf", "default_gravel.png", 1) mobs:register_egg("horror:werewolf", "Werewolf", "default_gravel.png", 1)