From e8fde86a19e1e363a0e112d811f597665b9126bc Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 10 Sep 2015 17:24:07 -0500 Subject: [PATCH] Fix crash when populating dungeons near 0 0 0 --- mods/mg/dungeons.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/mg/dungeons.lua b/mods/mg/dungeons.lua index 7d115f5..64a1ded 100755 --- a/mods/mg/dungeons.lua +++ b/mods/mg/dungeons.lua @@ -111,8 +111,16 @@ minetest.register_on_generated( function (minp, maxp, blockseed) local numgoblins = 2 + ( ((xsize * 2) * (zsize * 2)) * fillratio ) for e=1,numgoblins do - local rx = math.random((center.x-(xsize-1)),(center.x+(xsize-1))) - local rz = math.random((center.z-(zsize-1)),(center.z+(zsize-1))) + local x1 = (center.x-(xsize-1)) + local x2 = (center.x+(xsize-1)) + if x1 > x2 then break end + local rx = math.random(x1,x2) + + local z1 = (center.z-(zsize-1)) + local z2 = (center.z+(zsize-1)) + if z1 > z2 then break end + local rz = math.random(z1,z2) + local s = {mob="mobs:goblin",pos={x=rx,z=rz,y=(center.y+1)}} table.insert(spawn,s) end