Add worldgen beginnings and materialized_walls
parent
4047375d69
commit
3b5ea31c28
|
@ -0,0 +1,70 @@
|
|||
minetest.register_node("kingdoms:materializer", {
|
||||
description = "Materializer",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"kingdoms_materializer.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {oddly_breakable_by_hand = 2},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5 ,-0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
for level = 1, kingdoms.config.materialized_levels do
|
||||
local first = (level == 1)
|
||||
local last = (level == kingdoms.config.materialized_levels)
|
||||
local drop = {}
|
||||
-- If this is the first level, it should drop something instead of downgrading.
|
||||
if first then
|
||||
drop = nil
|
||||
end
|
||||
minetest.register_node("kingdoms:materialized_wall_"..tostring(level), {
|
||||
description = "Materializer Wall Level "..tostring(level),
|
||||
drawtype = "nodebox",
|
||||
tiles = {"kingdoms_materialized.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
-- Only include the first and last in the creative inventory.
|
||||
groups = {cracky = 1, level = 2, not_in_creative_inventory = ((first or last) and 0 or 1), kingdoms_materialized_up=(last and 0 or 1)},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
drop = drop,
|
||||
level = level,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5 ,-0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
}
|
||||
},
|
||||
on_destruct = function(pos)
|
||||
if not first then
|
||||
minetest.after(0, minetest.set_node, pos, {name="kingdoms:materialized_wall_"..tostring(level - 1)})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_abm{
|
||||
nodenames = {"group:kingdoms_materialized_up"},
|
||||
interval = kingdoms.config.materialized_abm_interval,
|
||||
chance = kingdoms.config.materialized_abm_chance,
|
||||
action = function(pos, node)
|
||||
local nextname = "kingdoms:materialized_wall_"..tostring(minetest.registered_nodes[node.name].level + 1)
|
||||
local r = kingdoms.config.materializer_radius
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x = pos.x - r, y = pos.y - r, z = pos.z - r},
|
||||
{x = pos.x + r, y = pos.y + r, z = pos.z + r},
|
||||
{"kingdoms:materializer"})
|
||||
for _, mpos in ipairs(positions) do
|
||||
-- local meta = minetest.get_meta(mpos)
|
||||
minetest.swap_node(pos, {name=nextname})
|
||||
return
|
||||
end
|
||||
end,
|
||||
}
|
|
@ -127,7 +127,7 @@ minetest.register_node("kingdoms:corestone", {
|
|||
drawtype = "nodebox",
|
||||
tiles = {"kingdoms_corestone.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {oddly_breakable_by_hand = 2, unbreakable = 1},
|
||||
groups = {oddly_breakable_by_hand = 2, unbreakable = 1, kingdom_infotext = 1},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
|
@ -147,25 +147,25 @@ minetest.register_node("kingdoms:corestone", {
|
|||
if not placer or pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
local kingdom = kingdoms.player.kingdom(placer:get_player_name())
|
||||
if not kingdom or not kingdoms.player.can(placer:get_player_name(), "corestone") then
|
||||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a corestone if you are not of sufficient level in a kingdom.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
if kingdom.corestone.pos then
|
||||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a corestone if the kingdom already has a corestone placed.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
if pointed_thing.under.y < kingdoms.config.corestone_miny then
|
||||
minetest.chat_send_player(placer:get_player_name(), ("You cannot place a corestone below %d."):format(kingdoms.config.corestone_miny))
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
local radius = kingdoms.config.corestone_radius * kingdoms.config.corestone_overlap_multiplier
|
||||
|
||||
|
||||
kingdoms.spm(false)
|
||||
local cantplace = not kingdoms.can_dig(radius, pointed_thing.under, placer:get_player_name()) or not kingdoms.can_dig(radius, pointed_thing.above, placer:get_player_name())
|
||||
local cantplaceward = not kingdoms.check_claimward(kingdoms.config.corestone_radius, pointed_thing.above, placer:get_player_name()) or not kingdoms.check_claimward(kingdoms.config.corestone_radius, pointed_thing.under, placer:get_player_name())
|
||||
|
@ -178,11 +178,11 @@ minetest.register_node("kingdoms:corestone", {
|
|||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a corestone this close to an opposing claim ward.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
kingdom.corestone.pos = pointed_thing.above
|
||||
kingdom.corestone.placed = os.time()
|
||||
kingdoms.log("action", ("Corestone of '%s' placed at %s."):format(kingdom.longname, minetest.pos_to_string(pointed_thing.above)))
|
||||
|
||||
|
||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||
end,
|
||||
|
||||
|
@ -190,16 +190,15 @@ minetest.register_node("kingdoms:corestone", {
|
|||
local kingdom = kingdoms.player.kingdom(placer:get_player_name())
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("kingdom.id", kingdom.id)
|
||||
build_infotext(pos, "Corestone")
|
||||
end,
|
||||
|
||||
|
||||
can_dig = function(pos, digger)
|
||||
local akingdom = kingdoms.bycspos(pos)
|
||||
local pkingdom = kingdoms.player.kingdom(digger:get_player_name())
|
||||
-- Can only dig if this is the digger's kingdom and he has enough levels.
|
||||
return not akingdom or (pkingdom and pkingdom.id == akingdom.id and kingdoms.player.can(digger:get_player_name(), "corestone"))
|
||||
end,
|
||||
|
||||
|
||||
on_destruct = function(pos)
|
||||
local kingdom = kingdoms.bycspos(pos)
|
||||
if not kingdom then return end
|
||||
|
@ -216,19 +215,12 @@ minetest.register_node("kingdoms:corestone", {
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm{
|
||||
nodenames = {"kingdoms:corestone"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos) build_infotext(pos, "Corestone") end,
|
||||
}
|
||||
|
||||
minetest.register_node("kingdoms:claimward", {
|
||||
description = "Claim Ward",
|
||||
drawtype = "nodebox",
|
||||
tiles = {"kingdoms_claimward.png"},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
groups = {oddly_breakable_by_hand = 2, unbreakable = 1},
|
||||
groups = {oddly_breakable_by_hand = 2, unbreakable = 1, kingdom_infotext = 1},
|
||||
is_ground_content = false,
|
||||
paramtype = "light",
|
||||
light_source = 0,
|
||||
|
@ -244,15 +236,15 @@ minetest.register_node("kingdoms:claimward", {
|
|||
if not placer or pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
local kingdom = kingdoms.player.kingdom(placer:get_player_name())
|
||||
if not kingdom then
|
||||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a ward if you are not a member of a kingdom.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
local radius = kingdoms.config.corestone_radius
|
||||
|
||||
|
||||
kingdoms.spm(false)
|
||||
local cantplace = not kingdoms.can_dig(radius, pointed_thing.under, placer:get_player_name()) or not kingdoms.can_dig(radius, pointed_thing.above, placer:get_player_name())
|
||||
kingdoms.spm(true)
|
||||
|
@ -260,7 +252,7 @@ minetest.register_node("kingdoms:claimward", {
|
|||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a ward this close to another corestone.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||
end,
|
||||
|
||||
|
@ -268,17 +260,9 @@ minetest.register_node("kingdoms:claimward", {
|
|||
local kingdom = kingdoms.player.kingdom(placer:get_player_name())
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("kingdom.id", kingdom.id)
|
||||
build_infotext(pos, "Claim ward")
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm{
|
||||
nodenames = {"kingdoms:claimward"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos) build_infotext(pos, "Claim ward") end,
|
||||
}
|
||||
|
||||
minetest.register_node("kingdoms:servercorestone", {
|
||||
description = "Server Core",
|
||||
drawtype = "nodebox",
|
||||
|
@ -304,20 +288,20 @@ minetest.register_node("kingdoms:servercorestone", {
|
|||
if not placer or pointed_thing.type ~= "node" then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
if not minetest.check_player_privs(placer:get_player_name(), {server = true}) then
|
||||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a server corestone. How did you even get it?")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
if kingdoms.db.servercorestone then
|
||||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a server corestone if there is already one placed.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
-- Even the server corestone cannot overlap already existent corestones.
|
||||
local radius = kingdoms.config.corestone_radius * kingdoms.config.corestone_overlap_multiplier
|
||||
|
||||
|
||||
kingdoms.spm(false)
|
||||
local cantplace = not kingdoms.can_dig(radius, pointed_thing.under, placer:get_player_name()) or not kingdoms.can_dig(radius, pointed_thing.above, placer:get_player_name())
|
||||
local cantplaceward = not kingdoms.check_claimward(kingdoms.config.corestone_radius, pointed_thing.above, placer:get_player_name()) or not kingdoms.check_claimward(kingdoms.config.corestone_radius, pointed_thing.under, placer:get_player_name())
|
||||
|
@ -330,9 +314,9 @@ minetest.register_node("kingdoms:servercorestone", {
|
|||
minetest.chat_send_player(placer:get_player_name(), "You cannot place a corestone this close to an opposing claim ward.")
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
||||
kingdoms.db.servercorestone = pointed_thing.above
|
||||
|
||||
|
||||
return minetest.item_place(itemstack, placer, pointed_thing)
|
||||
end,
|
||||
|
||||
|
@ -340,12 +324,19 @@ minetest.register_node("kingdoms:servercorestone", {
|
|||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", "Server Spawn")
|
||||
end,
|
||||
|
||||
|
||||
can_dig = function(pos, digger)
|
||||
return minetest.check_player_privs(digger:get_player_name(), {server = true})
|
||||
end,
|
||||
|
||||
|
||||
on_destruct = function(pos)
|
||||
kingdoms.db.servercorestone = nil
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm{
|
||||
nodenames = {"group:kingdom_infotext"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node) build_infotext(pos, minetest.registered_nodes[node.name].description) end,
|
||||
}
|
||||
|
|
|
@ -7,3 +7,6 @@ minetest.register_craft({
|
|||
|
||||
-- kingdoms:corestone
|
||||
-- kingdoms:claimward
|
||||
|
||||
-- kingdoms:materialized_wall_1
|
||||
-- kingdoms:materializer
|
||||
|
|
|
@ -40,3 +40,11 @@ kingdoms.config.player_visible_distance = 4
|
|||
|
||||
-- Distance of around speech. Use <player_visible_distance * 16> to match with player visibility.
|
||||
kingdoms.config.around = kingdoms.config.player_visible_distance * 16
|
||||
|
||||
-- Radius a materializer reaches.
|
||||
kingdoms.config.materializer_radius = 5
|
||||
-- Number of levels in materialized blocks.
|
||||
kingdoms.config.materialized_levels = 4
|
||||
-- Materializer ABM settings.
|
||||
kingdoms.config.materialized_abm_interval = 2
|
||||
kingdoms.config.materialized_abm_chance = 2
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
-- Set flags used by Kingdoms.
|
||||
minetest.register_on_mapgen_init(function(params)
|
||||
minetest.set_mapgen_params({
|
||||
mgname = "v7",
|
||||
flags = "trees, caves, dungeons, noflat, light, decorations",
|
||||
})
|
||||
-- Biomes won't be registered properly until done manually.
|
||||
default.register_biomes()
|
||||
default.register_decorations()
|
||||
end)
|
||||
|
||||
-- Dungeons
|
||||
local items = kingdoms.utils.probability_list({
|
||||
["default:mese"] = 1,
|
||||
["default:diamondblock"] = 1,
|
||||
|
||||
["default:goldblock"] = 2,
|
||||
["default:copperblock"] = 2,
|
||||
|
||||
["default:bronzeblock"] = 3,
|
||||
["default:steelblock"] = 3,
|
||||
|
||||
["default:obsidian"] = 3,
|
||||
["default:coalblock"] = 3,
|
||||
})
|
||||
|
||||
local function place_item(tab)
|
||||
local pos = tab[math.random(1, (#tab or 4))]
|
||||
pos.y = pos.y - 1
|
||||
local n = core.get_node_or_nil(pos)
|
||||
if n and n.name ~= "air" then
|
||||
pos.y = pos.y + 1
|
||||
local name = items[math.random(1, #items)]
|
||||
--Failsafe
|
||||
if minetest.registered_nodes[name] then
|
||||
core.set_node(pos, {name = name})
|
||||
else
|
||||
kingdoms.log("warning", "Tried to place unregistered node "..name.." in dungeon.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
core.set_gen_notify("dungeon")
|
||||
core.register_on_generated(function(minp, maxp, blockseed)
|
||||
local ntf = core.get_mapgen_object("gennotify")
|
||||
if ntf and ntf.dungeon and #ntf.dungeon > 0 then
|
||||
core.after(3, place_item, table.copy(ntf.dungeon))
|
||||
end
|
||||
end)
|
|
@ -62,6 +62,7 @@ domodfile("nametags.lua")
|
|||
domodfile("hud.lua")
|
||||
domodfile("corestone.lua")
|
||||
domodfile("gen.lua")
|
||||
domodfile("barriers.lua")
|
||||
|
||||
-- Overrides of default to support kingdoms.
|
||||
domodfile("ext/chests.lua")
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 728 B |
Binary file not shown.
After Width: | Height: | Size: 729 B |
|
@ -1,5 +1,5 @@
|
|||
kingdoms.utils = {}
|
||||
|
||||
|
||||
-- Return a UUID-like identifier.
|
||||
function kingdoms.utils.uniqueid()
|
||||
local s = ("%x"):format(math.random(0, 0xFFFF))
|
||||
|
@ -54,3 +54,13 @@ function kingdoms.utils.spairs(t, order)
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
function kingdoms.utils.probability_list(t)
|
||||
local ret = {}
|
||||
for k,v in pairs(t) do
|
||||
for i=1,v do
|
||||
table.insert(ret, k)
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
kingdoms
|
|
@ -0,0 +1,10 @@
|
|||
-- Function to execute more files.
|
||||
local modpath = minetest.get_modpath("magic")
|
||||
local function domodfile(f)
|
||||
dofile(modpath .. '/' .. f)
|
||||
end
|
||||
|
||||
-- Mod namespace.
|
||||
magic = {}
|
||||
|
||||
kingdoms.log("action", "Magic loaded.")
|
Loading…
Reference in New Issue