From e2d29e0dd932234bfc13d23039e6173f5d55798c Mon Sep 17 00:00:00 2001 From: Duane Date: Wed, 29 Jun 2016 14:30:03 -0500 Subject: [PATCH] Adjust pyramid caskets. --- mapgen.lua | 10 +--------- pyramid.lua | 41 ++++++++++++++++------------------------- village.lua | 1 + 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/mapgen.lua b/mapgen.lua index 164cc0d..435828e 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -374,7 +374,6 @@ local function generate(p_minp, p_maxp, seed) end local aster = false - local true_casket if minp.y > 17200 then -- nop elseif minp.y > 11000 then @@ -403,7 +402,7 @@ local function generate(p_minp, p_maxp, seed) write2, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biomemap, biome_ids, underzone) write3 = fun_caves.treegen(minp, maxp, data, p2data, area, node) if not write3 then - write4, write_p4, true_casket = fun_caves.pyramid(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap) + write4, write_p4 = fun_caves.pyramid(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap) end if biomemap and not (write3 or write4) then local biome = biome_ids[biomemap[40*80+40]] @@ -431,13 +430,6 @@ local function generate(p_minp, p_maxp, seed) end vm:update_liquids() vm:write_to_map() - - if true_casket then - vm:update_map() - local meta = minetest.get_meta(true_casket) - local id = meta:set_string('true', 'true') - --print('* True casket at '..minetest.pos_to_string(true_casket)) - end end -- Deal with memory issues. This, of course, is supposed to be automatic. diff --git a/pyramid.lua b/pyramid.lua index 388ebf2..0a5a1a3 100644 --- a/pyramid.lua +++ b/pyramid.lua @@ -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 diff --git a/village.lua b/village.lua index 06e1463..ea6e51e 100644 --- a/village.lua +++ b/village.lua @@ -43,6 +43,7 @@ fun_caves.village = function(minp, maxp, data, p2data, area, node, biome, height if not biome or math.random(10) ~= 1 then return end + local turf if biome:find('grass') or biome:find('forest') then turf = 'default:dirt_with_grass' elseif biome:find('taiga') or biome:find('tundra') then