Give generators relative position and area size instead of seed

This commit is contained in:
ShadowNinja 2013-03-02 21:04:17 -05:00
parent b296febac7
commit f7432118a8
2 changed files with 10 additions and 11 deletions

View File

@ -1,21 +1,21 @@
build_0gb_us.register_generator("woodchecker", function(seed)
if seed%2==0 then
build_0gb_us.register_generator("woodchecker", function(pos, size)
if (pos.x+pos.y+pos.z)%2 == 0 then
return "default:tree"
else
return "default:wood"
end
end)
build_0gb_us.register_generator("cactuschecker", function(seed)
if seed%2==0 then
build_0gb_us.register_generator("cactuschecker", function(pos, size)
if (pos.x+pos.y+pos.z)%2 == 0 then
return "default:cobble"
else
return "default:cactus"
end
end)
build_0gb_us.register_generator("furnacechests", function(seed)
if seed%2==0 then
build_0gb_us.register_generator("furnacechests", function(pos, size)
if (pos.x+pos.y+pos.z)%2 == 0 then
return "default:chest"
else
return "default:furnace"

View File

@ -88,16 +88,15 @@ end,
fillpattern = function(player, pos0, pos1, pattern, dir)
local seed=0
local min, max = build_0gb_us.normalize(pos0, pos1)
local size = {x=max.x-min.x, y=max.y-min.y, z=max.z-min.z}
if build_0gb_us.generators[pattern] then
for y = min.y, max.y do
for x = min.x, max.x do
for x = min.x, max.x do
for y = min.y, max.y do
for z = min.z, max.z do
build_0gb_us.place(player, {x=x,y=y,z=z}, build_0gb_us.generators[pattern](seed), dir)
seed = seed + 1
build_0gb_us.place(player, {x=x,y=y,z=z}, build_0gb_us.generators[pattern]({x=x-min.x, y=y-min.y, z=z-min.z}, size), dir)
end
end
end
end