2015-07-03 06:58:45 +02:00
|
|
|
|
local init = os.clock()
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures ={}
|
2015-07-03 06:58:45 +02:00
|
|
|
|
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures.get_struct = function(file)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local localfile = minetest.get_modpath("mcl_structures").."/schematics/"..file
|
2015-07-03 06:58:45 +02:00
|
|
|
|
local file, errorload = io.open(localfile, "rb")
|
|
|
|
|
if errorload ~= nil then
|
2017-05-19 15:13:31 +02:00
|
|
|
|
minetest.log("error", '[mcl_structures] Could not open this struct: ' .. localfile)
|
2015-07-03 06:58:45 +02:00
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local allnode = file:read("*a")
|
|
|
|
|
file:close()
|
|
|
|
|
|
|
|
|
|
return allnode
|
|
|
|
|
end
|
|
|
|
|
|
2015-07-04 04:56:02 +02:00
|
|
|
|
-- The call of Struct
|
2017-09-10 20:16:13 +02:00
|
|
|
|
mcl_structures.call_struct = function(pos, struct_style, rotation)
|
|
|
|
|
if not rotation then
|
|
|
|
|
rotation = "random"
|
|
|
|
|
end
|
2017-05-20 06:47:42 +02:00
|
|
|
|
if struct_style == "village" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_village(pos, rotation)
|
2017-05-20 06:47:42 +02:00
|
|
|
|
elseif struct_style == "desert_temple" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_desert_temple(pos, rotation)
|
2017-05-20 06:47:42 +02:00
|
|
|
|
elseif struct_style == "desert_well" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_desert_well(pos, rotation)
|
2017-05-20 07:46:57 +02:00
|
|
|
|
elseif struct_style == "igloo" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_igloo_top(pos, rotation)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
elseif struct_style == "witch_hut" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_witch_hut(pos, rotation)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
elseif struct_style == "ice_spike_small" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_ice_spike_small(pos, rotation)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
elseif struct_style == "ice_spike_large" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_ice_spike_large(pos, rotation)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
elseif struct_style == "boulder" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_boulder(pos, rotation)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
elseif struct_style == "fossil" then
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return mcl_structures.generate_fossil(pos, rotation)
|
2017-11-21 07:24:56 +01:00
|
|
|
|
elseif struct_style == "end_exit_portal" then
|
|
|
|
|
return mcl_structures.generate_end_exit_portal(pos, rotation)
|
2017-12-10 22:22:37 +01:00
|
|
|
|
elseif struct_style == "end_portal_shrine" then
|
|
|
|
|
return mcl_structures.generate_end_portal_shrine(pos, rotation)
|
2017-05-20 06:47:42 +02:00
|
|
|
|
end
|
2015-07-04 04:56:02 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures.generate_village = function(pos)
|
2017-09-08 03:31:20 +02:00
|
|
|
|
-- No generating for the moment, only place it :D
|
|
|
|
|
-- TODO: Do complete overhaul of the algorithm
|
|
|
|
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_village.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(newpos, path, "random", nil, true)
|
2015-07-04 04:56:02 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-05-20 05:57:38 +02:00
|
|
|
|
mcl_structures.generate_desert_well = function(pos)
|
|
|
|
|
local newpos = {x=pos.x,y=pos.y-2,z=pos.z}
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_well.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(newpos, path, "0", nil, true)
|
2017-05-20 05:57:38 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-05-20 07:46:57 +02:00
|
|
|
|
mcl_structures.generate_igloo_top = function(pos)
|
|
|
|
|
-- FIXME: This spawns bookshelf instead of furnace. Fix this!
|
|
|
|
|
-- Furnace does ot work atm because apparently meta is not set. :-(
|
2017-05-20 07:59:10 +02:00
|
|
|
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_top.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(newpos, path, "random", nil, true)
|
2017-05-20 07:46:57 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-05-24 05:43:01 +02:00
|
|
|
|
mcl_structures.generate_igloo_basement = function(pos, orientation)
|
|
|
|
|
-- TODO: Add brewing stand
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_igloo_basement.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(pos, path, orientation, nil, true)
|
2017-05-24 05:43:01 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-08-11 00:28:29 +02:00
|
|
|
|
mcl_structures.generate_boulder = function(pos)
|
2017-08-12 02:24:34 +02:00
|
|
|
|
-- Choose between 2 boulder sizes (2×2×2 or 3×3×3)
|
|
|
|
|
local r = math.random(1, 10)
|
2017-09-03 06:38:50 +02:00
|
|
|
|
local path
|
2017-08-12 02:24:34 +02:00
|
|
|
|
if r <= 3 then
|
2017-09-03 06:38:50 +02:00
|
|
|
|
path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder_small.mts"
|
2017-08-12 02:24:34 +02:00
|
|
|
|
else
|
2017-09-03 06:38:50 +02:00
|
|
|
|
path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_boulder.mts"
|
2017-08-12 02:24:34 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 05:03:20 +02:00
|
|
|
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(newpos, path)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 20:16:13 +02:00
|
|
|
|
mcl_structures.generate_witch_hut = function(pos, rotation)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(pos, path, rotation, nil, true)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
mcl_structures.generate_ice_spike_small = function(pos)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_small.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(pos, path, "random", nil, false)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-08-11 01:48:36 +02:00
|
|
|
|
mcl_structures.generate_ice_spike_large = function(pos)
|
2017-09-03 06:38:50 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_ice_spike_large.mts"
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(pos, path, "random", nil, false)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-08-11 00:28:29 +02:00
|
|
|
|
mcl_structures.generate_fossil = function(pos)
|
|
|
|
|
-- Generates one out of 8 possible fossil pieces
|
|
|
|
|
local newpos = {x=pos.x,y=pos.y-1,z=pos.z}
|
|
|
|
|
local fossils = {
|
2017-09-08 01:39:14 +02:00
|
|
|
|
"mcl_structures_fossil_skull_1.mts", -- 4×5×5
|
|
|
|
|
"mcl_structures_fossil_skull_2.mts", -- 5×5×5
|
|
|
|
|
"mcl_structures_fossil_skull_3.mts", -- 5×5×7
|
|
|
|
|
"mcl_structures_fossil_skull_4.mts", -- 7×5×5
|
|
|
|
|
"mcl_structures_fossil_spine_1.mts", -- 3×3×13
|
|
|
|
|
"mcl_structures_fossil_spine_2.mts", -- 5×4×13
|
|
|
|
|
"mcl_structures_fossil_spine_3.mts", -- 7×4×13
|
|
|
|
|
"mcl_structures_fossil_spine_4.mts", -- 8×5×13
|
2017-08-11 00:28:29 +02:00
|
|
|
|
}
|
|
|
|
|
local r = math.random(1, #fossils)
|
2017-08-11 01:48:36 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/"..fossils[r]
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return minetest.place_schematic(newpos, path, "random", nil, true)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-11-21 07:24:56 +01:00
|
|
|
|
mcl_structures.generate_end_exit_portal = function(pos)
|
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_exit_portal.mts"
|
|
|
|
|
return minetest.place_schematic(pos, path, "0", nil, true)
|
|
|
|
|
end
|
|
|
|
|
|
2017-12-10 22:22:37 +01:00
|
|
|
|
mcl_structures.generate_end_portal_shrine = function(pos)
|
2017-12-09 02:05:41 +01:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_end_portal_room_simple.mts"
|
2017-12-10 18:39:02 +01:00
|
|
|
|
local offset = {x=6, y=8, z=6}
|
2017-12-09 02:05:41 +01:00
|
|
|
|
local size = {x=13, y=8, z=13}
|
2017-12-10 18:39:02 +01:00
|
|
|
|
local newpos = { x = pos.x - offset.x, y = pos.y, z = pos.z - offset.z }
|
|
|
|
|
local ret = minetest.place_schematic(newpos, path, "0", nil, true)
|
2017-12-09 02:05:41 +01:00
|
|
|
|
if ret == nil then
|
|
|
|
|
return ret
|
|
|
|
|
end
|
|
|
|
|
|
2017-12-10 18:39:02 +01:00
|
|
|
|
local area_start, area_end = newpos, vector.add(newpos, size)
|
2017-12-09 02:05:41 +01:00
|
|
|
|
-- Find and setup spawner with silverfish
|
|
|
|
|
local spawners = minetest.find_nodes_in_area(area_start, area_end, "mcl_mobspawners:spawner")
|
|
|
|
|
for s=1, #spawners do
|
|
|
|
|
local meta = minetest.get_meta(spawners[s])
|
|
|
|
|
mcl_mobspawners.setup_spawner(spawners[s], "mobs_mc:silverfish")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Shuffle stone brick types
|
|
|
|
|
local bricks = minetest.find_nodes_in_area(area_start, area_end, "mcl_core:stonebrick")
|
|
|
|
|
-- FIXME: Use better seeding
|
|
|
|
|
local pr = PseudoRandom(math.random(0, 4294967295))
|
|
|
|
|
for b=1, #bricks do
|
|
|
|
|
local r_bricktype = pr:next(1, 100)
|
|
|
|
|
local r_infested = pr:next(1, 100)
|
|
|
|
|
local bricktype
|
2017-12-09 14:08:36 +01:00
|
|
|
|
if r_infested <= 5 then
|
|
|
|
|
if r_bricktype <= 30 then -- 30%
|
2017-12-09 02:05:41 +01:00
|
|
|
|
bricktype = "mcl_monster_eggs:monster_egg_stonebrickmossy"
|
2017-12-09 14:08:36 +01:00
|
|
|
|
elseif r_bricktype <= 50 then -- 20%
|
2017-12-09 02:05:41 +01:00
|
|
|
|
bricktype = "mcl_monster_eggs:monster_egg_stonebrickcracked"
|
2017-12-09 14:08:36 +01:00
|
|
|
|
else -- 50%
|
2017-12-09 02:05:41 +01:00
|
|
|
|
bricktype = "mcl_monster_eggs:monster_egg_stonebrick"
|
|
|
|
|
end
|
|
|
|
|
else
|
2017-12-09 14:08:36 +01:00
|
|
|
|
if r_bricktype <= 30 then -- 30%
|
2017-12-09 02:05:41 +01:00
|
|
|
|
bricktype = "mcl_core:stonebrickmossy"
|
2017-12-09 14:08:36 +01:00
|
|
|
|
elseif r_bricktype <= 50 then -- 20%
|
2017-12-09 02:05:41 +01:00
|
|
|
|
bricktype = "mcl_core:stonebrickcracked"
|
|
|
|
|
end
|
2017-12-09 14:08:36 +01:00
|
|
|
|
-- 50% stonebrick (no change necessary)
|
2017-12-09 02:05:41 +01:00
|
|
|
|
end
|
|
|
|
|
if bricktype ~= nil then
|
|
|
|
|
minetest.set_node(bricks[b], { name = bricktype })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-12-09 16:50:32 +01:00
|
|
|
|
-- Also replace stairs
|
|
|
|
|
local stairs = minetest.find_nodes_in_area(area_start, area_end, {"mcl_stairs:stair_stonebrick", "mcl_stairs:stair_stonebrick_outer", "mcl_stairs:stair_stonebrick_inner"})
|
|
|
|
|
for s=1, #stairs do
|
|
|
|
|
local stair = minetest.get_node(stairs[s])
|
|
|
|
|
local r_type = pr:next(1, 100)
|
|
|
|
|
if r_type <= 30 then -- 30% mossy
|
|
|
|
|
if stair.name == "mcl_stairs:stair_stonebrick" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickmossy"
|
|
|
|
|
elseif stair.name == "mcl_stairs:stair_stonebrick_outer" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickmossy_outer"
|
|
|
|
|
elseif stair.name == "mcl_stairs:stair_stonebrick_inner" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickmossy_inner"
|
|
|
|
|
end
|
|
|
|
|
minetest.set_node(stairs[s], stair)
|
|
|
|
|
elseif r_type <= 50 then -- 20% cracky
|
|
|
|
|
if stair.name == "mcl_stairs:stair_stonebrick" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickcracked"
|
|
|
|
|
elseif stair.name == "mcl_stairs:stair_stonebrick_outer" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickcracked_outer"
|
|
|
|
|
elseif stair.name == "mcl_stairs:stair_stonebrick_inner" then
|
|
|
|
|
stair.name = "mcl_stairs:stair_stonebrickcracked_inner"
|
|
|
|
|
end
|
|
|
|
|
minetest.set_node(stairs[s], stair)
|
|
|
|
|
end
|
|
|
|
|
-- 50% no change
|
|
|
|
|
end
|
|
|
|
|
|
2017-12-09 02:05:41 +01:00
|
|
|
|
-- Randomly add ender eyes into end portal frames, but never fill the entire frame
|
|
|
|
|
local frames = minetest.find_nodes_in_area(area_start, area_end, "mcl_portals:end_portal_frame")
|
|
|
|
|
local eyes = 0
|
|
|
|
|
for f=1, #frames do
|
|
|
|
|
local r_eye = pr:next(1, 10)
|
|
|
|
|
if r_eye == 1 then
|
|
|
|
|
eyes = eyes + 1
|
|
|
|
|
if eyes < #frames then
|
|
|
|
|
local frame_node = minetest.get_node(frames[f])
|
|
|
|
|
frame_node.name = "mcl_portals:end_portal_frame_eye"
|
|
|
|
|
minetest.set_node(frames[f], frame_node)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
end
|
|
|
|
|
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures.generate_desert_temple = function(pos)
|
2015-07-04 04:56:02 +02:00
|
|
|
|
-- No Generating for the temple ... Why using it ? No Change
|
2017-09-08 04:30:47 +02:00
|
|
|
|
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_desert_temple.mts"
|
2015-07-04 04:56:02 +02:00
|
|
|
|
local newpos = {x=pos.x,y=pos.y-12,z=pos.z}
|
2017-09-08 04:30:47 +02:00
|
|
|
|
local size = {x=22, y=24, z=22}
|
2015-07-04 04:56:02 +02:00
|
|
|
|
if newpos == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
2017-09-10 20:18:16 +02:00
|
|
|
|
local ret = minetest.place_schematic(newpos, path, "random", nil, true)
|
|
|
|
|
if ret == nil then
|
|
|
|
|
return ret
|
|
|
|
|
end
|
2017-09-08 04:30:47 +02:00
|
|
|
|
|
|
|
|
|
-- Find chests.
|
|
|
|
|
-- FIXME: Searching this large area just for the chets is not efficient. Need a better way to find the chests;
|
|
|
|
|
-- probably let's just infer it from newpos because the schematic always the same.
|
|
|
|
|
local chests = minetest.find_nodes_in_area({x=newpos.x-size.x, y=newpos.y, z=newpos.z-size.z}, vector.add(newpos, size), "mcl_chests:chest")
|
2017-05-19 19:26:59 +02:00
|
|
|
|
|
|
|
|
|
-- Add desert temple loot into chests
|
|
|
|
|
for c=1, #chests do
|
|
|
|
|
-- FIXME: Use better seeding
|
|
|
|
|
local pr = PseudoRandom(math.random(0, 4294967295))
|
|
|
|
|
local lootitems = mcl_loot.get_multi_loot({
|
|
|
|
|
{
|
|
|
|
|
stacks_min = 2,
|
|
|
|
|
stacks_max = 4,
|
|
|
|
|
items = {
|
|
|
|
|
{ itemstring = "mcl_mobitems:bone", weight = 25, amount_min = 4, amount_max=6 },
|
|
|
|
|
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 25, amount_min = 3, amount_max=7 },
|
|
|
|
|
{ itemstring = "mcl_mobitems:spider_eye", weight = 25, amount_min = 1, amount_max=3 },
|
|
|
|
|
-- TODO: Enchanted Book
|
|
|
|
|
{ itemstring = "mcl_books:book", weight = 20, },
|
|
|
|
|
{ itemstring = "mcl_mobitems:saddle", weight = 20, },
|
|
|
|
|
{ itemstring = "mcl_core:apple_gold", weight = 20, },
|
|
|
|
|
{ itemstring = "mcl_core:gold_ingot", weight = 15, amount_min = 2, amount_max = 7 },
|
|
|
|
|
{ itemstring = "mcl_core:iron_ingot", weight = 15, amount_min = 1, amount_max = 5 },
|
|
|
|
|
{ itemstring = "mcl_core:emerald", weight = 15, amount_min = 1, amount_max = 3 },
|
|
|
|
|
{ itemstring = "", weight = 15, },
|
2017-07-06 14:49:02 +02:00
|
|
|
|
{ itemstring = "mobs_mc:iron_horse_armor", weight = 15, },
|
|
|
|
|
{ itemstring = "mobs_mc:gold_horse_armor", weight = 10, },
|
|
|
|
|
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 5, },
|
2017-05-19 19:26:59 +02:00
|
|
|
|
{ itemstring = "mcl_core:diamond", weight = 5, amount_min = 1, amount_max = 3 },
|
|
|
|
|
-- TODO: Enchanted Golden Apple
|
|
|
|
|
{ itemstring = "mcl_core:apple_gold", weight = 2, },
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
stacks_min = 4,
|
|
|
|
|
stacks_max = 4,
|
|
|
|
|
items = {
|
|
|
|
|
{ itemstring = "mcl_mobitems:bone", weight = 10, amount_min = 1, amount_max = 8 },
|
|
|
|
|
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 10, amount_min = 1, amount_max = 8 },
|
|
|
|
|
{ itemstring = "mcl_mobitems:gunpowder", weight = 10, amount_min = 1, amount_max = 8 },
|
|
|
|
|
{ itemstring = "mcl_core:sand", weight = 10, amount_min = 1, amount_max = 8 },
|
|
|
|
|
{ itemstring = "mcl_mobitems:string", weight = 10, amount_min = 1, amount_max = 8 },
|
|
|
|
|
}
|
|
|
|
|
}}, pr)
|
|
|
|
|
|
|
|
|
|
local meta = minetest.get_meta(chests[c])
|
|
|
|
|
local inv = meta:get_inventory()
|
2017-09-08 04:30:47 +02:00
|
|
|
|
inv:set_size("main", 9*3)
|
2017-05-19 19:26:59 +02:00
|
|
|
|
for i=1, #lootitems do
|
|
|
|
|
inv:add_item("main", lootitems[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-09-10 20:18:16 +02:00
|
|
|
|
|
2017-09-14 03:41:06 +02:00
|
|
|
|
-- Initialize pressure plates
|
|
|
|
|
local pplates = minetest.find_nodes_in_area({x=newpos.x-size.x, y=newpos.y, z=newpos.z-size.z}, vector.add(newpos, size), "mesecons_pressureplates:pressure_plate_stone_off")
|
|
|
|
|
for p=1, #pplates do
|
|
|
|
|
minetest.registered_nodes["mesecons_pressureplates:pressure_plate_stone_off"].on_construct(pplates[p])
|
|
|
|
|
end
|
|
|
|
|
|
2017-09-10 20:18:16 +02:00
|
|
|
|
return ret
|
2015-07-04 04:56:02 +02:00
|
|
|
|
end
|
|
|
|
|
|
2017-12-10 22:20:48 +01:00
|
|
|
|
local registered_structures = {}
|
|
|
|
|
|
|
|
|
|
--[[ Returns a table of structure of the specified type.
|
|
|
|
|
Currently the only valid parameter is "stronghold".
|
|
|
|
|
Format of return value:
|
|
|
|
|
{
|
|
|
|
|
{ pos = <position>, generated=<true/false> }, -- first structure
|
|
|
|
|
{ pos = <position>, generated=<true/false> }, -- second structure
|
|
|
|
|
-- and so on
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TODO: Implement this function for all other structure types as well.
|
|
|
|
|
]]
|
|
|
|
|
mcl_structures.get_registered_structures = function(structure_type)
|
2017-12-11 19:33:58 +01:00
|
|
|
|
if registered_structures[structure_type] then
|
|
|
|
|
return table.copy(registered_structures[structure_type])
|
|
|
|
|
else
|
|
|
|
|
return {}
|
|
|
|
|
end
|
2017-12-10 22:20:48 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Register a structures table for the given type. The table format is the same as for
|
|
|
|
|
-- mcl_structures.get_registered_structures.
|
|
|
|
|
mcl_structures.register_structures = function(structure_type, structures)
|
|
|
|
|
registered_structures[structure_type] = structures
|
|
|
|
|
end
|
2015-07-04 04:56:02 +02:00
|
|
|
|
|
|
|
|
|
-- Debug command
|
|
|
|
|
minetest.register_chatcommand("spawnstruct", {
|
2017-12-10 22:22:37 +01:00
|
|
|
|
params = "desert_temple | desert_well | igloo | village | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine",
|
2017-02-18 02:22:24 +01:00
|
|
|
|
description = "Generate a pre-defined structure near your position.",
|
|
|
|
|
privs = {debug = true},
|
2015-07-04 04:56:02 +02:00
|
|
|
|
func = function(name, param)
|
|
|
|
|
local pos= minetest.get_player_by_name(name):getpos()
|
|
|
|
|
if not pos then
|
|
|
|
|
return
|
|
|
|
|
end
|
2017-05-19 15:09:46 +02:00
|
|
|
|
local errord = false
|
2017-05-19 15:06:21 +02:00
|
|
|
|
if param == "village" then
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures.generate_village(pos)
|
2017-12-13 00:35:02 +01:00
|
|
|
|
minetest.chat_send_player(name, "Village built. WARNING: Villages are experimental and might have bugs.")
|
2017-05-19 15:09:46 +02:00
|
|
|
|
elseif param == "desert_temple" then
|
2017-05-19 15:13:31 +02:00
|
|
|
|
mcl_structures.generate_desert_temple(pos)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
minetest.chat_send_player(name, "Desert temple built.")
|
2017-05-20 05:57:38 +02:00
|
|
|
|
elseif param == "desert_well" then
|
|
|
|
|
mcl_structures.generate_desert_well(pos)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
minetest.chat_send_player(name, "Desert well built.")
|
2017-05-20 07:46:57 +02:00
|
|
|
|
elseif param == "igloo" then
|
|
|
|
|
mcl_structures.generate_igloo_top(pos)
|
2017-08-11 00:28:29 +02:00
|
|
|
|
minetest.chat_send_player(name, "Igloo built.")
|
|
|
|
|
elseif param == "witch_hut" then
|
|
|
|
|
mcl_structures.generate_witch_hut(pos)
|
|
|
|
|
minetest.chat_send_player(name, "Witch hut built.")
|
|
|
|
|
elseif param == "boulder" then
|
|
|
|
|
mcl_structures.generate_boulder(pos)
|
|
|
|
|
minetest.chat_send_player(name, "Moss stone boulder placed.")
|
|
|
|
|
elseif param == "fossil" then
|
|
|
|
|
mcl_structures.generate_fossil(pos)
|
|
|
|
|
minetest.chat_send_player(name, "Fossil placed.")
|
|
|
|
|
elseif param == "ice_spike_small" then
|
|
|
|
|
mcl_structures.generate_ice_spike_small(pos)
|
|
|
|
|
minetest.chat_send_player(name, "Small ice spike placed.")
|
2017-08-11 01:48:36 +02:00
|
|
|
|
elseif param == "ice_spike_large" then
|
|
|
|
|
mcl_structures.generate_ice_spike_large(pos)
|
|
|
|
|
minetest.chat_send_player(name, "Large ice spike placed.")
|
2017-11-21 07:24:56 +01:00
|
|
|
|
elseif param == "end_exit_portal" then
|
|
|
|
|
mcl_structures.generate_end_exit_portal(pos)
|
|
|
|
|
minetest.chat_send_player(name, "End exit portal placed.")
|
2017-12-10 22:22:37 +01:00
|
|
|
|
elseif param == "end_portal_shrine" then
|
|
|
|
|
mcl_structures.generate_end_portal_shrine(pos)
|
|
|
|
|
minetest.chat_send_player(name, "End portal shrine placed.")
|
2017-05-19 15:09:46 +02:00
|
|
|
|
elseif param == "" then
|
|
|
|
|
minetest.chat_send_player(name, "Error: No structure type given. Please use “/spawnstruct <type>”.")
|
|
|
|
|
errord = true
|
|
|
|
|
else
|
|
|
|
|
minetest.chat_send_player(name, "Error: Unknown structure type. Please use “/spawnstruct <type>”.")
|
|
|
|
|
errord = true
|
|
|
|
|
end
|
|
|
|
|
if errord then
|
2017-08-11 00:28:29 +02:00
|
|
|
|
minetest.chat_send_player(name, "Use /help spawnstruct to see a list of avaiable types.")
|
2015-07-04 04:56:02 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
})
|
|
|
|
|
|
2015-07-03 06:58:45 +02:00
|
|
|
|
local time_to_load= os.clock() - init
|
2017-09-11 04:25:39 +02:00
|
|
|
|
minetest.log("action", (string.format("[MOD] "..minetest.get_current_modname().." loaded in %.4f s", time_to_load)))
|