Adjust pyramid caskets.

This commit is contained in:
Duane 2016-06-29 14:30:03 -05:00
parent 695316ea2a
commit e2d29e0dd9
3 changed files with 18 additions and 34 deletions

View file

@ -10,10 +10,8 @@ minetest.register_node("fun_caves:pyramid_1", newnode)
local newnode = fun_caves.clone_node("default:chest")
newnode.description = "Treasure Casket"
newnode.on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("true", 'true')
end
newnode.light_source = 1
newnode.on_construct = nil
local chest_formspec =
"size[8,9]" ..
@ -37,21 +35,22 @@ local gems = {'fun_caves:moonstone', 'fun_caves:coral_gem', 'fun_caves:garnet',
newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local true_casket = meta:get_string('true')
if true_casket ~= 'true' then
clicker:set_hp(clicker:get_hp() - 2)
return
end
local ready = meta:get_string('formspec')
if ready == '' then
meta:set_string("formspec", chest_formspec)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
for i = 1, math.random(12) do
inv:add_item('main', filler[math.random(#filler)])
if math.random(15) ~= 1 then
meta:set_string("formspec", 'del')
clicker:set_hp(clicker:get_hp() - 2)
minetest.remove_node(pos)
else
meta:set_string("formspec", chest_formspec)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
for i = 1, math.random(12) do
inv:add_item('main', filler[math.random(#filler)])
end
inv:add_item('main', gems[math.random(#gems)])
end
inv:add_item('main', gems[math.random(#gems)])
end
end
minetest.register_node("fun_caves:casket", newnode)
@ -75,7 +74,6 @@ fun_caves.pyramid = function(minp, maxp, data, p2data, area, biomemap, biome_ids
if not pyramid_biomes[biome] then
return
end
--print('* Creating pyramid in '..biome)
elseif math.random(5) ~= 1 then
return
end
@ -109,7 +107,6 @@ fun_caves.pyramid = function(minp, maxp, data, p2data, area, biomemap, biome_ids
local write = true
local p2write = false
local caskets = {}
index = 0
local index3d = 0
@ -121,14 +118,12 @@ fun_caves.pyramid = function(minp, maxp, data, p2data, area, biomemap, biome_ids
index3d = math.floor((z - minp.z) / 5) * (csize.y) * csize.x + math.floor((x - minp.x) / 5) + 1
local ivm = area:index(x, minp.y, z)
--pyramid_1[index] = math.floor(pyramid_1[index] + 0.5)
for y = minp.y, maxp.y do
local dy = y - minp.y
if dy >= base_height + 3 and dy <= base_height + 37 - math.max(math.abs(dx - 40), math.abs(dz - 40)) and pyramid_1[index3d] > 0 then
if data[ivm - area.ystride] == node['fun_caves:pyramid_1'] and math.random(100) == 1 then
data[ivm] = node['fun_caves:casket']
caskets[#caskets+1] = {x=x, y=y, z=z}
else
data[ivm] = node['air']
end
@ -144,9 +139,5 @@ fun_caves.pyramid = function(minp, maxp, data, p2data, area, biomemap, biome_ids
end
end
if #caskets > 0 then
return write, p2write, caskets[math.random(#caskets)]
else
return write, p2write
end
return write, p2write
end