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
assets export-ignore
scripts export-ignore
*.js export-ignore
bin export-ignore
docs 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_short_max = 20
-- check if mods exists and build tables
for k, mob_mod in ipairs(spawners_mobs.ENABLED_MODS) do
local modpath = minetest.get_modpath(mob_mod)
-- list of mobs and their info
if (modpath) then
for j, mob in ipairs(spawners_mobs.MOBS_PROPS[mob_mod]) do
local mob_egg
function spawners_mobs.register_spawners()
-- check if mods exists and build tables
for k, mob_mod in ipairs(spawners_mobs.ENABLED_MODS) do
local modpath = minetest.get_modpath(mob_mod)
-- list of mobs and their info
if (modpath) then
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
-- if mob_mod == 'mobs' and not (mobs.mod == 'redo') then goto continue end
-- 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
table.insert(spawners_mobs.mob_tables,
{
name = mob.name,
mod_prefix = mob_mod,
egg_name_custom = mob.egg_name_custom,
dummy_size = mob.dummy_size,
dummy_offset = mob.dummy_offset,
dummy_mesh = mob.dummy_mesh,
dummy_texture = mob.dummy_texture,
night_only = mob.night_only,
sound_custom = mob.sound_custom
}
)
-- use custom egg or create a default egg
if mob.egg_name_custom ~= '' then
mob_egg = mob.egg_name_custom
else
mob_egg = mob_mod .. ':' .. mob.name
table.insert(spawners_mobs.mob_tables,
{
name = mob.name,
mod_prefix = mob_mod,
egg_name_custom = mob.egg_name_custom,
dummy_size = mob.dummy_size,
dummy_offset = mob.dummy_offset,
dummy_mesh = mob.dummy_mesh,
dummy_texture = mob.dummy_texture,
night_only = mob.night_only,
sound_custom = mob.sound_custom
}
)
-- use custom egg or create a default egg
if mob.egg_name_custom ~= '' then
mob_egg = mob.egg_name_custom
else
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
-- 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

View File

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

View File

@ -39,4 +39,4 @@ end
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]')