diff --git a/README.md b/README.md index ad8e116f..7a2ce71c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m * mobiles/aggressive/ * [mobs_goblins][] ([CC-BY-SA / CC-BY / CC0][lic.mobs_goblins]) -- version: [a346f85 Git][ver.mobs_goblins] *2015-09-12* ([patched][patch.mobs_goblins]) * [mobs_monster][] ([MIT][lic.mobs_monster]) -- version: [f6d0e01 Git][ver.mobs_monster] *2017-04-27* - * [sneeker][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0]) -- version: [9d7c566 Git][ver.sneeker] *2017-05-28* + * [sneeker][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0]) -- version: [d336800 Git][ver.sneeker] *2017-05-29* * [spidermob][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa3.0] / [MIT][lic.mit] / [WTFPL][lic.spidermob] / [Unlicense][lic.unlicense]) -- version [c72d2ff Git][ver.spidermob] *2016-08-14* ([patched][patch.spidermob]) * mobiles/engine/ * mobiles/general/ @@ -462,7 +462,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.rainbow_ore]: https://github.com/FsxShader2012/rainbow_ore/tree/6e77693 [ver.signs_lib]: https://github.com/minetest-mods/signs_lib/tree/2c36937 [ver.simple_protection]: https://github.com/SmallJoker/simple_protection/tree/23c024f -[ver.sneeker]: https://github.com/AntumDeluge/mtmod-sneeker/tree/9d7c566 +[ver.sneeker]: https://github.com/AntumDeluge/mtmod-sneeker/tree/d336800 [ver.snowdrift]: https://github.com/paramat/snowdrift/tree/fcb0537 [ver.spawneggs]: https://github.com/thefamilygrog66/spawneggs/tree/4650370 [ver.spectator_mode]: https://github.com/minetest-mods/spectator_mode/tree/7d68bec diff --git a/mods/mobiles/aggressive/sneeker/init.lua b/mods/mobiles/aggressive/sneeker/init.lua index cf7dfe4f..2633ffc6 100644 --- a/mods/mobiles/aggressive/sneeker/init.lua +++ b/mods/mobiles/aggressive/sneeker/init.lua @@ -14,6 +14,9 @@ end dofile(sneeker.modpath .. '/settings.lua') dofile(sneeker.modpath .. '/functions.lua') +sneeker.mob_name = sneeker.modname .. ':' .. sneeker.modname +sneeker.spawnegg_name = sneeker.modname .. ':spawnegg' + if log_mods then sneeker.log('Spawn cap: ' .. tostring(sneeker.spawn_cap)) end @@ -342,18 +345,18 @@ def.get_staticdata = function(self) }) end -minetest.register_entity('sneeker:sneeker',def) +minetest.register_entity(sneeker.mob_name, def) if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then - minetest.register_craftitem('sneeker:spawnegg',{ + minetest.register_craftitem(sneeker.spawnegg_name, { description = 'Sneeker Spawn Egg', inventory_image = 'sneeker_spawnegg.png', stack_max = 64, - on_place = function(itemstack,placer,pointed_thing) + on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type == 'node' then local pos = pointed_thing.above pos.y = pos.y+1 - minetest.add_entity(pos,'sneeker:sneeker') + minetest.add_entity(pos, sneeker.mob_name) if not minetest.setting_getbool('creative_mode') then itemstack:take_item() end @@ -363,12 +366,12 @@ if minetest.get_modpath('spawneggs') and minetest.get_modpath('tnt') then }) minetest.register_craft({ - output = 'sneeker:spawnegg', + output = sneeker.spawnegg_name, type = 'shapeless', recipe = { 'spawneggs:egg', 'tnt:tnt', }, }) - minetest.register_alias('spawneggs:sneeker', 'sneeker:spawnegg') + minetest.register_alias('spawneggs:sneeker', sneeker.spawnegg_name) end diff --git a/mods/mobiles/aggressive/sneeker/settings.lua b/mods/mobiles/aggressive/sneeker/settings.lua index ec64b9c7..1f69f861 100644 --- a/mods/mobiles/aggressive/sneeker/settings.lua +++ b/mods/mobiles/aggressive/sneeker/settings.lua @@ -2,4 +2,4 @@ sneeker.debug = minetest.setting_get('sneeker.debug') or false -sneeker.spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 50 +sneeker.spawn_cap = minetest.setting_get('sneeker.spawn_cap') or 25 diff --git a/mods/mobiles/aggressive/sneeker/settingtypes.txt b/mods/mobiles/aggressive/sneeker/settingtypes.txt index 607737ca..9aeb756b 100644 --- a/mods/mobiles/aggressive/sneeker/settingtypes.txt +++ b/mods/mobiles/aggressive/sneeker/settingtypes.txt @@ -2,7 +2,7 @@ sneeker.debug (Log debug output) bool false # Sets maximum number of spawns that can exist in world. -sneeker.spawn_cap (Maximum spawns) int 50 +sneeker.spawn_cap (Maximum spawns) int 25 # Sets possibility for spawn. sneeker.spawn_chance (Spawn chance) int 18000 diff --git a/mods/mobiles/aggressive/sneeker/spawn.lua b/mods/mobiles/aggressive/sneeker/spawn.lua index 3e3f153b..344ef3f7 100644 --- a/mods/mobiles/aggressive/sneeker/spawn.lua +++ b/mods/mobiles/aggressive/sneeker/spawn.lua @@ -14,7 +14,7 @@ if minetest.setting_getbool('log_mods') then end minetest.register_abm({ - nodenames = {'default:dirt_with_grass','default:stone'}, + nodenames = {'default:dirt_with_grass', 'default:stone'}, neighbors = {'air'}, interval = spawn_interval, chance = spawn_chance, @@ -42,6 +42,16 @@ minetest.register_abm({ if minetest.get_node(pos).name ~= 'air' then return end - minetest.add_entity(pos,'sneeker:sneeker') + + -- Get total count of sneekers in world + local name, count + for name in pairs(minetest.luaentities) do + if name == sneeker.mob_name then + count = count + 1 + end + end + if count >= sneeker.spawn_cap then return end -- Max sneekers already exist + + minetest.add_entity(pos, sneeker.mob_name) end }) diff --git a/settingtypes.txt b/settingtypes.txt index b4b8c9c3..1c24fc8f 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -104,7 +104,7 @@ airtanks_wear_in_creative (Air tanks wear out in creative mode) bool true sneeker.debug (Log debug output) bool false # Sets maximum number of spawns that can exist in world. -sneeker.spawn_cap (Maximum spawns) int 50 +sneeker.spawn_cap (Maximum spawns) int 25 # Sets possibility for spawn. sneeker.spawn_chance (Spawn chance) int 18000