From 7803efb0b1697b3821e55811d601d4717278c0ff Mon Sep 17 00:00:00 2001 From: BlockMen Date: Thu, 15 Oct 2015 20:03:37 +0200 Subject: [PATCH] Generate spawners in dungeons --- zombie/init.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/zombie/init.lua b/zombie/init.lua index 97f70ac..66d934b 100644 --- a/zombie/init.lua +++ b/zombie/init.lua @@ -111,3 +111,23 @@ local def = { } creatures.register_mob(def) + + +-- Place spawners in dungeons + +local function place_spawner(tab) + local pos = tab[math.random(1, (#tab or 4))] + pos.y = pos.y - 1 + local n = core.get_node_or_nil(pos) + if n and n.name ~= "air" then + pos.y = pos.y + 1 + core.set_node(pos, {name = "creatures:zombie_spawner"}) + end +end +core.set_gen_notify("dungeon") +core.register_on_generated(function(minp, maxp, blockseed) + local ntf = core.get_mapgen_object("gennotify") + if ntf and ntf.dungeon and #ntf.dungeon > 3 then + core.after(3, place_spawner, table.copy(ntf.dungeon)) + end +end)