diff --git a/.gitattributes b/.gitattributes index f67a22f..058bff5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,7 @@ .* export-ignore assets export-ignore -scripts export-ignore +*.js export-ignore bin export-ignore docs export-ignore types export-ignore diff --git a/spawners_mobs/api.lua b/spawners_mobs/api.lua index 6414a3c..6296c64 100644 --- a/spawners_mobs/api.lua +++ b/spawners_mobs/api.lua @@ -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 diff --git a/spawners_mobs/config.lua b/spawners_mobs/config.lua index 6952fbf..4d26f0a 100644 --- a/spawners_mobs/config.lua +++ b/spawners_mobs/config.lua @@ -254,3 +254,5 @@ if minetest.get_modpath('mobs') ~= nil then } } end + +spawners_mobs.register_spawners() diff --git a/spawners_mobs/init.lua b/spawners_mobs/init.lua index 7baa220..0ace6a9 100644 --- a/spawners_mobs/init.lua +++ b/spawners_mobs/init.lua @@ -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]')