fix spawners mobs registration

This commit is contained in:
Juraj Vajda 2023-04-24 11:55:32 -04:00
parent c8f25738ac
commit 9317290a50
4 changed files with 46 additions and 42 deletions

2
.gitattributes vendored
View File

@ -2,7 +2,7 @@
.* export-ignore .* export-ignore
assets export-ignore assets export-ignore
scripts export-ignore *.js export-ignore
bin export-ignore bin export-ignore
docs export-ignore docs export-ignore
types export-ignore types export-ignore

View File

@ -27,49 +27,51 @@ local enable_particles = minetest.settings:get_bool('enable_particles')
local tick_max = 30 local tick_max = 30
local tick_short_max = 20 local tick_short_max = 20
-- check if mods exists and build tables function spawners_mobs.register_spawners()
for k, mob_mod in ipairs(spawners_mobs.ENABLED_MODS) do -- check if mods exists and build tables
local modpath = minetest.get_modpath(mob_mod) for k, mob_mod in ipairs(spawners_mobs.ENABLED_MODS) do
-- list of mobs and their info local modpath = minetest.get_modpath(mob_mod)
if (modpath) then -- list of mobs and their info
for j, mob in ipairs(spawners_mobs.MOBS_PROPS[mob_mod]) do if (modpath) then
local mob_egg for j, mob in ipairs(spawners_mobs.MOBS_PROPS[mob_mod]) do
local mob_egg
-- disabled extra check for mobs redo due to incompatibility with Lua 5.1, this method is available from Lua 5.2 -- disabled extra check for mobs redo due to incompatibility with Lua 5.1, this method is available from Lua 5.2
-- if mob_mod == 'mobs' and not (mobs.mod == 'redo') then goto continue end -- if mob_mod == 'mobs' and not (mobs.mod == 'redo') then goto continue end
table.insert(spawners_mobs.mob_tables, table.insert(spawners_mobs.mob_tables,
{ {
name = mob.name, name = mob.name,
mod_prefix = mob_mod, mod_prefix = mob_mod,
egg_name_custom = mob.egg_name_custom, egg_name_custom = mob.egg_name_custom,
dummy_size = mob.dummy_size, dummy_size = mob.dummy_size,
dummy_offset = mob.dummy_offset, dummy_offset = mob.dummy_offset,
dummy_mesh = mob.dummy_mesh, dummy_mesh = mob.dummy_mesh,
dummy_texture = mob.dummy_texture, dummy_texture = mob.dummy_texture,
night_only = mob.night_only, night_only = mob.night_only,
sound_custom = mob.sound_custom sound_custom = mob.sound_custom
} }
) )
-- use custom egg or create a default egg -- use custom egg or create a default egg
if mob.egg_name_custom ~= '' then if mob.egg_name_custom ~= '' then
mob_egg = mob.egg_name_custom mob_egg = mob.egg_name_custom
else else
mob_egg = mob_mod .. ':' .. mob.name mob_egg = mob_mod .. ':' .. mob.name
end
-- recipes
minetest.register_craft({
output = 'spawners_mobs:' .. mob_mod .. '_' .. mob.name .. '_spawner',
recipe = {
{ 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{ 'xpanes:bar_flat', mob_egg, 'xpanes:bar_flat' },
{ 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
}
})
-- Lua > 5.1
-- ::continue::
end end
-- recipes
minetest.register_craft({
output = 'spawners_mobs:' .. mob_mod .. '_' .. mob.name .. '_spawner',
recipe = {
{ 'default:diamondblock', 'fire:flint_and_steel', 'default:diamondblock' },
{ 'xpanes:bar_flat', mob_egg, 'xpanes:bar_flat' },
{ 'default:diamondblock', 'xpanes:bar_flat', 'default:diamondblock' },
}
})
-- Lua > 5.1
-- ::continue::
end end
end end
end end

View File

@ -254,3 +254,5 @@ if minetest.get_modpath('mobs') ~= nil then
} }
} }
end end
spawners_mobs.register_spawners()

View File

@ -39,4 +39,4 @@ end
local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000 local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
print ('[Mod] Spawners Mobs Loaded. [' .. mod_end_time .. 's]') print('[Mod] Spawners Mobs Loaded. [' .. mod_end_time .. 's]')