From 8bdede04bb948e5c9c4b0862323379f8004118e4 Mon Sep 17 00:00:00 2001 From: juraj Date: Sat, 5 Mar 2016 18:54:38 +0100 Subject: [PATCH] settings file, map generation --- config.lua | 13 +++++++++++++ init.lua | 23 +++++++++++++++++++++-- pyramids.lua | 5 ----- settings.txt | 2 ++ spawners_gen.lua | 40 ++++++++++++++++++++++++++++++++++++++++ spawners_mobs.lua | 6 ++---- 6 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 settings.txt create mode 100644 spawners_gen.lua diff --git a/config.lua b/config.lua index b340b3d..98258da 100644 --- a/config.lua +++ b/config.lua @@ -14,6 +14,8 @@ -- [sound_custom : string] - Custom name for the sound file name if differ from default: i.e 'mobs_cow'. +-- [env : boolean] - This spawner will become environmental spawner. Environmental spawners have different properties/behaviour (used for map gen) and cannot be crafted. + -- [*] -> MANDATORY - has to be filled in! -- mods what should be enabled and loded, remove/add the one you want to load @@ -93,6 +95,17 @@ MOBS_PROPS = { night_only=false, sound_custom="" }, + { + name="spider", + egg_name_custom="", + dummy_size={x=2,y=2}, + dummy_offset=-0.2, + dummy_mesh="mobs_spider.x", + dummy_texture={"mobs_spider.png"}, + night_only="disable", + sound_custom="", + env = true + }, { name="stone_monster", egg_name_custom="", diff --git a/init.lua b/init.lua index eb89367..f8de05f 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,7 @@ --- user settings +-- Main settings +dofile(minetest.get_modpath("spawners").."/settings.txt") + +-- Spawners configurations dofile(minetest.get_modpath("spawners").."/config.lua") -- API @@ -10,7 +13,23 @@ dofile(minetest.get_modpath("spawners").."/spawners_mobs.lua") -- Spawners for ores dofile(minetest.get_modpath("spawners").."/spawners_ores.lua") +-- include mummy mobs redo addon (mob) +if minetest.get_modpath("mobs") then + dofile(minetest.get_modpath("spawners").."/mob_mummy.lua") +end + -- Spawners Pyramids -dofile(minetest.get_modpath("spawners").."/pyramids.lua") +if SPAWN_PYRAMIDS then + dofile(minetest.get_modpath("spawners").."/pyramids.lua") + + print("[Mod][spawners] Pyramids enabled") +end + +-- Spawners Pyramids +if SPAWNERS_GENERATE then + dofile(minetest.get_modpath("spawners").."/spawners_gen.lua") + + print("[Mod][spawners] Environmental enabled") +end print ("[Mod] Spawners 0.6 Loaded.") \ No newline at end of file diff --git a/pyramids.lua b/pyramids.lua index d59db9f..8eb721d 100644 --- a/pyramids.lua +++ b/pyramids.lua @@ -5,11 +5,6 @@ pyramids = {} dofile(minetest.get_modpath("spawners").."/pyramids_nodes.lua") dofile(minetest.get_modpath("spawners").."/pyramids_room.lua") --- include mummy mobs redo addon -if minetest.get_modpath("mobs") then - dofile(minetest.get_modpath("spawners").."/mob_mummy.lua") -end - local chest_stuff = { {name="default:apple", max = 3}, {name="default:torch", max = 10}, diff --git a/settings.txt b/settings.txt new file mode 100644 index 0000000..eca1ff2 --- /dev/null +++ b/settings.txt @@ -0,0 +1,2 @@ +SPAWN_PYRAMIDS = true +SPAWNERS_GENERATE = true diff --git a/spawners_gen.lua b/spawners_gen.lua new file mode 100644 index 0000000..620f7bb --- /dev/null +++ b/spawners_gen.lua @@ -0,0 +1,40 @@ +-- Place spawners in dungeons +local function place_spawner(param) + local tab = param[1] + local gen_obj = param[2] + + local pos = tab[math.random(1, (#tab or 3))] + pos.y = pos.y - 1 + + local n = minetest.get_node_or_nil(pos) + + if n and n.name ~= "air" then + pos.y = pos.y + 1 + + if gen_obj == "dungeon" then + minetest.log("action", "[Mod][Spawners] dungeon spawner placed at: "..minetest.pos_to_string(pos)) + + minetest.set_node(pos, {name = "spawners:spawners_mummy_spawner_env"}) + else + minetest.log("action", "[Mod][Spawners] temple spawner placed at: "..minetest.pos_to_string(pos)) + + minetest.set_node(pos, {name = "spawners:mobs_spider_spawner_env"}) + end + + end +end + +minetest.set_gen_notify("dungeon") +minetest.set_gen_notify("temple") + +minetest.register_on_generated(function(minp, maxp, blockseed) + local ntf = minetest.get_mapgen_object("gennotify") + + if ntf and ntf.dungeon then + minetest.after(3, place_spawner, {table.copy(ntf.dungeon), "dungeon"}) + end + + if ntf and ntf.temple then + minetest.after(3, place_spawner, {table.copy(ntf.temple), "temple"}) + end +end) \ No newline at end of file diff --git a/spawners_mobs.lua b/spawners_mobs.lua index 930b6c8..f27dfc2 100644 --- a/spawners_mobs.lua +++ b/spawners_mobs.lua @@ -325,8 +325,8 @@ function spawners.create(mob_name, mod_prefix, size, offset, mesh, texture, nigh "spawners:"..mod_prefix.."_"..mob_name.."_spawner_waiting_env" }, neighbors = {"air"}, - interval = 15.0, - chance = 10, + interval = 10.0, + chance = 6, catch_up = false, action = function(pos, node, active_object_count, active_object_count_wider) @@ -360,10 +360,8 @@ function spawners.create(mob_name, mod_prefix, size, offset, mesh, texture, nigh return end - print(node.name) -- make sure the right node status is shown if node.name ~= "spawners:"..mod_prefix.."_"..mob_name.."_spawner_active"..ext then - print("active: "..node.name) minetest.set_node(pos, {name="spawners:"..mod_prefix.."_"..mob_name.."_spawner_active"..ext}) end