Hellfill: multiple prefabs per level
This commit is contained in:
+44
-13
@@ -94,8 +94,12 @@ end
|
|||||||
|
|
||||||
-- the prefab maps must have contents-function, or populatemaze()
|
-- the prefab maps must have contents-function, or populatemaze()
|
||||||
-- puts the stuff only inside the prefab map.
|
-- puts the stuff only inside the prefab map.
|
||||||
|
-- contains either a function, or an object with "repeatable" and "contents".
|
||||||
|
-- function alone implies not repeatable.
|
||||||
local hell_prefabs = {
|
local hell_prefabs = {
|
||||||
function ()
|
{
|
||||||
|
repeatable = true,
|
||||||
|
contents = function ()
|
||||||
des.map({ halign = rnd_halign(), valign = "center", map = [[
|
des.map({ halign = rnd_halign(), valign = "center", map = [[
|
||||||
......
|
......
|
||||||
......
|
......
|
||||||
@@ -113,8 +117,11 @@ local hell_prefabs = {
|
|||||||
......
|
......
|
||||||
......
|
......
|
||||||
......]], contents = function() end });
|
......]], contents = function() end });
|
||||||
end,
|
end
|
||||||
function ()
|
},
|
||||||
|
{
|
||||||
|
repeatable = true,
|
||||||
|
contents = function ()
|
||||||
des.map({ halign = rnd_halign(), valign = "center", map = [[
|
des.map({ halign = rnd_halign(), valign = "center", map = [[
|
||||||
xxxxxx.....xxxxxx
|
xxxxxx.....xxxxxx
|
||||||
xxxx.........xxxx
|
xxxx.........xxxx
|
||||||
@@ -134,7 +141,8 @@ xx.............xx
|
|||||||
xxxx.........xxxx
|
xxxx.........xxxx
|
||||||
xxxxxx.....xxxxxx
|
xxxxxx.....xxxxxx
|
||||||
]], contents = function() end });
|
]], contents = function() end });
|
||||||
end,
|
end
|
||||||
|
},
|
||||||
function (coldhell)
|
function (coldhell)
|
||||||
des.map({ halign = rnd_halign(), valign = rnd_valign(), map = [[
|
des.map({ halign = rnd_halign(), valign = rnd_valign(), map = [[
|
||||||
xxxxxx.xxxxxx
|
xxxxxx.xxxxxx
|
||||||
@@ -171,15 +179,20 @@ xxxxxx.xxxxxx
|
|||||||
end
|
end
|
||||||
end });
|
end });
|
||||||
end,
|
end,
|
||||||
function ()
|
{
|
||||||
|
repeatable = true,
|
||||||
|
contents = function ()
|
||||||
des.map({ halign = "center", valign = "center", map = [[
|
des.map({ halign = "center", valign = "center", map = [[
|
||||||
..............................................................
|
..............................................................
|
||||||
..............................................................
|
..............................................................
|
||||||
..............................................................
|
..............................................................
|
||||||
..............................................................
|
..............................................................
|
||||||
..............................................................]], contents = function() end });
|
..............................................................]], contents = function() end });
|
||||||
end,
|
end
|
||||||
function ()
|
},
|
||||||
|
{
|
||||||
|
repeatable = true,
|
||||||
|
contents = function ()
|
||||||
des.map({ halign = rnd_halign(), valign = rnd_valign(), lit = true, map = [[
|
des.map({ halign = rnd_halign(), valign = rnd_valign(), lit = true, map = [[
|
||||||
x.....x
|
x.....x
|
||||||
.......
|
.......
|
||||||
@@ -188,7 +201,8 @@ x.....x
|
|||||||
.......
|
.......
|
||||||
.......
|
.......
|
||||||
x.....x]], contents = function() end });
|
x.....x]], contents = function() end });
|
||||||
end,
|
end
|
||||||
|
},
|
||||||
function ()
|
function ()
|
||||||
des.map({ halign = rnd_halign(), valign = rnd_valign(), map = [[
|
des.map({ halign = rnd_halign(), valign = rnd_valign(), map = [[
|
||||||
BBBBBBB
|
BBBBBBB
|
||||||
@@ -251,7 +265,9 @@ BBBBBBB]], contents = function()
|
|||||||
map = mapstr, contents = function() end })
|
map = mapstr, contents = function() end })
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function ()
|
{
|
||||||
|
repeatable = true,
|
||||||
|
contents = function ()
|
||||||
local mapstr = [[
|
local mapstr = [[
|
||||||
...
|
...
|
||||||
...
|
...
|
||||||
@@ -270,16 +286,31 @@ BBBBBBB]], contents = function()
|
|||||||
...
|
...
|
||||||
...
|
...
|
||||||
...]];
|
...]];
|
||||||
for dx = 1, 3 + math.random(0, 5) do
|
for dx = 1, 3 do
|
||||||
des.map({ x = math.random(3, 75), y = 3,
|
des.map({ x = math.random(3, 75), y = 3,
|
||||||
map = mapstr, contents = function() end })
|
map = mapstr, contents = function() end })
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function rnd_hell_prefab(coldhell)
|
function rnd_hell_prefab(coldhell)
|
||||||
local pf = math.random(1, #hell_prefabs);
|
local dorepeat = true;
|
||||||
hell_prefabs[pf](coldhell);
|
local nloops = 0;
|
||||||
|
repeat
|
||||||
|
nloops = nloops + 1;
|
||||||
|
local pf = math.random(1, #hell_prefabs);
|
||||||
|
local fab = hell_prefabs[pf];
|
||||||
|
local fabtype = type(fab);
|
||||||
|
|
||||||
|
if (fabtype == "function") then
|
||||||
|
fab(coldhell);
|
||||||
|
dorepeat = false;
|
||||||
|
elseif (fabtype == "table") then
|
||||||
|
fab.contents(coldhell);
|
||||||
|
dorepeat = not (fab.repeatable and math.random(0, nloops * 2) == 0);
|
||||||
|
end
|
||||||
|
until ((not dorepeat) or (nloops > 5));
|
||||||
end
|
end
|
||||||
|
|
||||||
hells = {
|
hells = {
|
||||||
|
|||||||
Reference in New Issue
Block a user