2016-02-02 19:41:28 -08:00
|
|
|
|
|
|
|
-- Node that turns into a chest containing some loot
|
|
|
|
minetest.register_node("loot:loot_node",
|
|
|
|
{ drawtype = "airlike",
|
|
|
|
pointable = false,
|
|
|
|
walkable = false,
|
|
|
|
diggable = false,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"loot:loot_node"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos)
|
|
|
|
minetest.remove_node(pos)
|
2019-06-07 13:37:15 -04:00
|
|
|
minetest.add_node(pos, {name = "default:chest"})
|
2016-02-02 19:41:28 -08:00
|
|
|
local inv = minetest.get_meta(pos):get_inventory()
|
|
|
|
|
|
|
|
local valuable_count = math.random(1,3)
|
2016-02-02 19:41:49 -08:00
|
|
|
local generic_count = math.random(0,5)
|
2016-02-02 19:41:28 -08:00
|
|
|
|
|
|
|
local valuables = loot.generate_loot("valuable", valuable_count)
|
|
|
|
local loots = loot.generate_loot("generic", generic_count)
|
|
|
|
|
|
|
|
for i, v in ipairs(valuables) do
|
|
|
|
table.insert(loots,v)
|
|
|
|
end
|
|
|
|
|
|
|
|
inv:set_list("main", loots)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|