Limit casket spawns.
This commit is contained in:
parent
6286a4e829
commit
801b11bf67
2 changed files with 22 additions and 11 deletions
14
abms.lua
14
abms.lua
|
@ -302,7 +302,19 @@ minetest.register_abm({
|
|||
nodenames = {"fun_caves:casket"},
|
||||
interval = 2,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
catch_up = false,
|
||||
action = function(pos, node, aoc, active_object_count_wider)
|
||||
-- do not spawn if too many active entities in area
|
||||
if active_object_count_wider > 5 then
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local ready = meta:get_string('formspec')
|
||||
if ready ~= '' then
|
||||
return
|
||||
end
|
||||
|
||||
local objs = minetest.get_objects_inside_radius(pos, 7)
|
||||
for i = 1, #objs do
|
||||
if objs[i]:is_player() then
|
||||
|
|
19
pyramid.lua
19
pyramid.lua
|
@ -8,11 +8,6 @@ newnode.groups.pyramid = 1
|
|||
newnode.drop = 'default:sandstone'
|
||||
minetest.register_node("fun_caves:pyramid_1", newnode)
|
||||
|
||||
local newnode = fun_caves.clone_node("default:chest")
|
||||
newnode.description = "Treasure Casket"
|
||||
newnode.light_source = 1
|
||||
newnode.on_construct = nil
|
||||
|
||||
local chest_formspec =
|
||||
"size[8,9]" ..
|
||||
default.gui_bg ..
|
||||
|
@ -33,16 +28,16 @@ end
|
|||
|
||||
local gems = {'fun_caves:moonstone', 'fun_caves:coral_gem', 'fun_caves:garnet', 'fun_caves:aquamarine', 'fun_caves:zoisite', 'fun_caves:sky_iron'}
|
||||
|
||||
local newnode = fun_caves.clone_node("default:chest")
|
||||
newnode.description = "Treasure Casket"
|
||||
newnode.light_source = 1
|
||||
newnode.on_construct = nil
|
||||
newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local ready = meta:get_string('formspec')
|
||||
|
||||
if ready == '' then
|
||||
if math.random(15) ~= 1 then
|
||||
meta:set_string("formspec", 'del')
|
||||
clicker:set_hp(clicker:get_hp() - 2)
|
||||
minetest.remove_node(pos)
|
||||
else
|
||||
if math.random(10) == 1 then
|
||||
meta:set_string("formspec", chest_formspec)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
|
@ -50,6 +45,10 @@ newnode.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
|||
inv:add_item('main', filler[math.random(#filler)])
|
||||
end
|
||||
inv:add_item('main', gems[math.random(#gems)])
|
||||
else
|
||||
meta:set_string("formspec", 'del')
|
||||
clicker:set_hp(clicker:get_hp() - 2)
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue