forked from VoxeLibre/VoxeLibre
Add /spawnstruct support
This commit is contained in:
parent
8fa67e6b4f
commit
b0b8638a4c
|
@ -8,7 +8,7 @@ local adjacents = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function makegeode(pos,pr)
|
local function makegeode(pos,pr)
|
||||||
local size = pr:next(3,18)
|
local size = pr:next(4,12)
|
||||||
local p1 = vector.offset(pos,-size,-size,-size)
|
local p1 = vector.offset(pos,-size,-size,-size)
|
||||||
local p2 = vector.offset(pos,size,size,size)
|
local p2 = vector.offset(pos,size,size,size)
|
||||||
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"})
|
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"})
|
||||||
|
@ -49,7 +49,7 @@ local function makegeode(pos,pr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.register_structure("geodes",{
|
mcl_structures.register_structure("geode",{
|
||||||
place_on = {"mcl_core:stone"},
|
place_on = {"mcl_core:stone"},
|
||||||
spawn_by = {"air"},
|
spawn_by = {"air"},
|
||||||
num_spawn_by = 2,
|
num_spawn_by = 2,
|
||||||
|
@ -65,11 +65,3 @@ mcl_structures.register_structure("geodes",{
|
||||||
makegeode(pos,pr)
|
makegeode(pos,pr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("makegeode",{
|
|
||||||
privs = { debug = true },
|
|
||||||
func=function(n,p)
|
|
||||||
local pos = pl:get_pos()
|
|
||||||
makegeode(pos,PseudoRandom(minetest.get_mapgen_setting("seed")))
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
local registered_structures = {}
|
mcl_structures.registered_structures = {}
|
||||||
|
|
||||||
--[[] structure def:
|
--[[] structure def:
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ local registered_structures = {}
|
||||||
}
|
}
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
local function place_schem(pos, def, pr)
|
function mcl_structures.place_structure(pos, def, pr)
|
||||||
if not def then return end
|
if not def then return end
|
||||||
if type(def.y_offset) == "function" then
|
if type(def.y_offset) == "function" then
|
||||||
y_offset = def.y_offset(pr)
|
y_offset = def.y_offset(pr)
|
||||||
|
@ -67,12 +67,12 @@ function mcl_structures.register_structure(name,def,nospawn) --nospawn means it
|
||||||
for _, pos in pairs(gennotify["decoration#"..deco_id] or {}) do
|
for _, pos in pairs(gennotify["decoration#"..deco_id] or {}) do
|
||||||
local realpos = vector.offset(pos,0,-1,0)
|
local realpos = vector.offset(pos,0,-1,0)
|
||||||
minetest.remove_node(realpos)
|
minetest.remove_node(realpos)
|
||||||
place_schem(realpos,def,pr)
|
mcl_structures.place_structure(realpos,def,pr)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups})
|
minetest.register_node(":"..structblock, {drawtype="airlike", walkable = false, pointable = false,groups = sbgroups})
|
||||||
registered_structures[name] = def
|
mcl_structures.registered_structures[name] = def
|
||||||
end
|
end
|
||||||
|
|
||||||
--lbm for secondary structures (structblock included in base structure)
|
--lbm for secondary structures (structblock included in base structure)
|
||||||
|
@ -82,9 +82,9 @@ minetest.register_lbm({
|
||||||
nodenames = {"group:structblock_lbm"},
|
nodenames = {"group:structblock_lbm"},
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local name = node.name:gsub("mcl_structures:structblock_","")
|
local name = node.name:gsub("mcl_structures:structblock_","")
|
||||||
local def = registered_structures[name]
|
local def = mcl_structures.registered_structures[name]
|
||||||
if not def then return end
|
if not def then return end
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
place_schem(pos)
|
mcl_structures.place_structure(pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -573,9 +573,16 @@ end
|
||||||
|
|
||||||
dofile(modpath.."/api.lua")
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
-- Debug command
|
-- Debug command
|
||||||
|
local chatcommand_params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon"
|
||||||
|
|
||||||
|
for n,_ in pairs(mcl_structures.registered_structures) do
|
||||||
|
chatcommand_params = chatcommand_params .. " | "..n
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("spawnstruct", {
|
minetest.register_chatcommand("spawnstruct", {
|
||||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_exit_portal_open | end_gateway_portal | end_portal_shrine | nether_portal | dungeon",
|
params = chatcommand_params,
|
||||||
description = S("Generate a pre-defined structure near your position."),
|
description = S("Generate a pre-defined structure near your position."),
|
||||||
privs = {debug = true},
|
privs = {debug = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
|
@ -621,6 +628,13 @@ minetest.register_chatcommand("spawnstruct", {
|
||||||
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
||||||
errord = true
|
errord = true
|
||||||
else
|
else
|
||||||
|
for n,d in pairs(mcl_structures.registered_structures) do
|
||||||
|
if n == param then
|
||||||
|
mcl_structures.place_structure(pos,d,PseudoRandom(os.clock()))
|
||||||
|
minetest.chat_send_player(name, message)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
message = S("Error: Unknown structure type. Please use “/spawnstruct <type>”.")
|
message = S("Error: Unknown structure type. Please use “/spawnstruct <type>”.")
|
||||||
errord = true
|
errord = true
|
||||||
end
|
end
|
||||||
|
@ -630,3 +644,4 @@ minetest.register_chatcommand("spawnstruct", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue