1
0
mirror of https://codeberg.org/tenplus1/mobs_monster.git synced 2025-07-08 19:30:19 +02:00

tweak and tidy code

This commit is contained in:
tenplus1
2024-08-10 14:39:51 +01:00
parent ad470a4ad2
commit 5c956edfe3
13 changed files with 330 additions and 380 deletions

View File

@ -1,4 +1,4 @@
-- Translation support
local S = minetest.get_translator("mobs_monster")
-- Lava Flan by Zeg9 (additional textures by JurajVajda)
@ -79,8 +79,8 @@ mobs:register_mob("mobs_monster:lava_flan", {
mobs:effect(pos, 40, "fire_basic_flame.png", 2, 3, 2, 5, 10, nil)
local nods = minetest.find_nodes_in_area(
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y, z = pos.z}, "air")
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y, z = pos.z}, "air")
-- place flame if position empty and flame exists
if nods and #nods > 0
@ -96,27 +96,29 @@ mobs:register_mob("mobs_monster:lava_flan", {
glow = 10
})
-- where to spawn
if not mobs.custom_spawn_monster then
mobs:spawn({
name = "mobs_monster:lava_flan",
nodes = {"default:lava_source"},
chance = 1500,
active_object_count = 1,
max_height = 0
})
mobs:spawn({
name = "mobs_monster:lava_flan",
nodes = {"default:lava_source"},
chance = 1500,
active_object_count = 1,
max_height = 0
})
end
-- spawn egg
-- add spawn egg
mobs:register_egg("mobs_monster:lava_flan", S("Lava Flan"), "default_lava.png", 1)
-- compatibility for old mobs mod
-- compatibility alias, only needed for servers who used the old mobs mod
mobs:alias_mob("mobs:lava_flan", "mobs_monster:lava_flan")
-- lava orb
minetest.register_craftitem(":mobs:lava_orb", {
description = S("Lava orb"),
inventory_image = "zmobs_lava_orb.png",
@ -131,8 +133,7 @@ minetest.register_craft({
burntime = 80
})
-- Lava Pick (digs and smelts at same time)
-- backup and replace old function
local old_handle_node_drops = minetest.handle_node_drops
@ -151,10 +152,7 @@ function minetest.handle_node_drops(pos, drops, digger)
while not stack:is_empty() do
local output, decremented_input = minetest.get_craft_result({
method = "cooking",
width = 1,
items = {stack}
})
method = "cooking", width = 1, items = {stack}})
if output.item:is_empty() then
table.insert_all(hot_drops, decremented_input.items)
@ -187,6 +185,8 @@ function minetest.handle_node_drops(pos, drops, digger)
return old_handle_node_drops(pos, drops, digger)
end
-- lava pick, smelts nodes when you dig
minetest.register_tool(":mobs:pick_lava", {
description = S("Lava Pickaxe"),
inventory_image = "mobs_pick_lava.png",
@ -195,9 +195,7 @@ minetest.register_tool(":mobs:pick_lava", {
max_drop_level = 3,
groupcaps = {
cracky = {
times = {[1] = 1.80, [2] = 0.80, [3] = 0.40},
uses = 40,
maxlevel = 3
times = {[1] = 1.80, [2] = 0.80, [3] = 0.40}, uses = 40, maxlevel = 3
}
},
damage_groups = {fleshy = 6, fire = 1},
@ -206,6 +204,8 @@ minetest.register_tool(":mobs:pick_lava", {
light_source = 14
})
-- recipe
minetest.register_craft({
output = "mobs:pick_lava",
recipe = {
@ -215,16 +215,16 @@ minetest.register_craft({
}
})
-- Add [toolranks] mod support if found
-- Add [toolranks] mod support
if minetest.get_modpath("toolranks") then
minetest.override_item("mobs:pick_lava", {
original_description = "Lava Pickaxe",
description = toolranks.create_description("Lava Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("mobs:pick_lava", {
original_description = "Lava Pickaxe",
description = toolranks.create_description("Lava Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
end
-- obsidian flan
mobs:register_mob("mobs_monster:obsidian_flan", {
@ -243,14 +243,10 @@ mobs:register_mob("mobs_monster:obsidian_flan", {
collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.8, 0.3},
visual = "mesh",
mesh = "zmobs_lava_flan.x",
textures = {
{"mobs_obsidian_flan.png"}
},
textures = {{"mobs_obsidian_flan.png"}},
blood_texture = "default_obsidian.png",
makes_footstep_sound = true,
sounds = {
random = "mobs_lavaflan"
},
sounds = {random = "mobs_lavaflan"},
walk_velocity = 0.1,
run_velocity = 0.5,
jump = false,
@ -265,28 +261,22 @@ mobs:register_mob("mobs_monster:obsidian_flan", {
fire_damage = 0,
light_damage = 0,
animation = {
speed_normal = 15,
speed_run = 15,
stand_start = 0,
stand_end = 8,
walk_start = 10,
walk_end = 18,
run_start = 20,
run_end = 28,
punch_start = 20,
punch_end = 28
speed_normal = 15, speed_run = 15,
stand_start = 0, stand_end = 8,
walk_start = 10, walk_end = 18,
run_start = 20, run_end = 28,
punch_start = 20, punch_end = 28
}
})
-- add spawn egg
-- spawn egg
mobs:register_egg("mobs_monster:obsidian_flan", S("Obsidian Flan"),
"default_obsidian.png", 1)
-- obsidian arrow and grief setting check
local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
-- mese arrow (weapon)
mobs:register_arrow("mobs_monster:obsidian_arrow", {
visual = "sprite",
visual_size = {x = 0.5, y = 0.5},
@ -294,6 +284,7 @@ mobs:register_arrow("mobs_monster:obsidian_arrow", {
velocity = 6,
hit_player = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
@ -301,6 +292,7 @@ mobs:register_arrow("mobs_monster:obsidian_arrow", {
end,
hit_mob = function(self, player)
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = 8},
@ -317,9 +309,7 @@ mobs:register_arrow("mobs_monster:obsidian_arrow", {
local radius = 1
local def = node and minetest.registered_nodes[node.name]
if not def then
return
end
if not def then return end
if def and def.tiles and def.tiles[1] then
texture = def.tiles[1]