Split stuff

This commit is contained in:
Raymoo 2016-02-02 19:41:28 -08:00
parent 3bcbe9b719
commit ed04f19f13
4 changed files with 58 additions and 55 deletions

19
dungeon.lua Normal file
View File

@ -0,0 +1,19 @@
minetest.set_gen_notify("dungeon")
minetest.register_on_generated(function(minp, maxp, blockseed)
local notif = minetest.get_mapgen_object("gennotify")
if not notif then return end
local locations = notif.dungeon
if not locations then return end
for i, location in ipairs(locations) do
if math.random(3) == 1 then
minetest.place_node(location, { name = "loot:loot_node" })
end
end
end)

View File

@ -67,7 +67,11 @@ end
loot.modpath = modpath
local vaults = minetest.setting_getbool("loot_vaults")
if vaults then dofile(modpath .. "loot_vault.lua") end
local no_d_loot = minetest.setting_getbool("no_dungeon_loot")
dofile(modpath .. "default_loot.lua")
dofile(modpath .. "loot_node.lua")
if vaults then dofile(modpath .. "loot_vault.lua") end
if not no_d_loot then dofile(modpath .. "dungeon.lua") end

33
loot_node.lua Normal file
View File

@ -0,0 +1,33 @@
-- 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)
minetest.place_node(pos, {name = "default:chest"})
local inv = minetest.get_meta(pos):get_inventory()
local valuable_count = math.random(1,3)
local generic_count = math.random(0,10)
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,
})

View File

@ -1,39 +1,5 @@
-- Creates loot vaults
-- 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)
minetest.place_node(pos, {name = "default:chest"})
local inv = minetest.get_meta(pos):get_inventory()
local valuable_count = math.random(1,3)
local generic_count = math.random(0,10)
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,
})
local mts = loot.modpath .. "loot_vault.mts"
minetest.register_on_generated(function(minp, maxp, seed)
@ -63,22 +29,3 @@ minetest.register_on_generated(function(minp, maxp, seed)
true)
end)
minetest.set_gen_notify("dungeon")
minetest.register_on_generated(function(minp, maxp, blockseed)
local notif = minetest.get_mapgen_object("gennotify")
if not notif then return end
local locations = notif.dungeon
if not locations then return end
for i, location in ipairs(locations) do
if math.random(3) == 1 then
minetest.place_node(location, { name = "loot:loot_node" })
end
end
end)