2021-05-25 13:52:25 +03:00
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
local S = minetest.get_translator(modname)
|
|
|
|
|
local modpath = minetest.get_modpath(modname)
|
|
|
|
|
|
|
|
|
|
mcl_structures = {}
|
|
|
|
|
|
2022-06-06 04:34:31 +03:00
|
|
|
|
dofile(modpath.."/api.lua")
|
2022-06-25 01:31:28 +03:00
|
|
|
|
dofile(modpath.."/shipwrecks.lua")
|
2022-06-24 03:11:24 +03:00
|
|
|
|
dofile(modpath.."/desert_temple.lua")
|
|
|
|
|
dofile(modpath.."/jungle_temple.lua")
|
2022-06-24 04:09:50 +03:00
|
|
|
|
dofile(modpath.."/ocean_ruins.lua")
|
2022-06-24 22:47:44 +03:00
|
|
|
|
dofile(modpath.."/witch_hut.lua")
|
|
|
|
|
dofile(modpath.."/igloo.lua")
|
2022-07-01 05:25:34 +03:00
|
|
|
|
dofile(modpath.."/woodland_mansion.lua")
|
2022-07-10 03:32:37 +03:00
|
|
|
|
dofile(modpath.."/ruined_portal.lua")
|
2022-06-25 00:24:51 +03:00
|
|
|
|
dofile(modpath.."/geode.lua")
|
2022-08-08 05:50:26 +03:00
|
|
|
|
dofile(modpath.."/pillager_outpost.lua")
|
2022-09-10 22:39:56 +03:00
|
|
|
|
dofile(modpath.."/end_spawn.lua")
|
2022-08-31 12:41:04 +03:00
|
|
|
|
dofile(modpath.."/end_city.lua")
|
2022-06-24 18:54:34 +03:00
|
|
|
|
|
2022-06-25 01:31:28 +03:00
|
|
|
|
|
2022-06-24 03:11:24 +03:00
|
|
|
|
mcl_structures.register_structure("desert_well",{
|
|
|
|
|
place_on = {"group:sand"},
|
2022-06-24 22:10:52 +03:00
|
|
|
|
fill_ratio = 0.01,
|
2022-06-24 03:11:24 +03:00
|
|
|
|
flags = "place_center_x, place_center_z",
|
|
|
|
|
not_near = { "desert_temple_new" },
|
|
|
|
|
solid_ground = true,
|
|
|
|
|
sidelen = 4,
|
2022-06-25 07:16:43 +03:00
|
|
|
|
chunk_probability = 600,
|
2022-06-24 03:11:24 +03:00
|
|
|
|
y_max = mcl_vars.mg_overworld_max,
|
|
|
|
|
y_min = 1,
|
|
|
|
|
y_offset = -2,
|
|
|
|
|
biomes = { "Desert" },
|
|
|
|
|
filenames = { modpath.."/schematics/mcl_structures_desert_well.mts" },
|
|
|
|
|
})
|
2022-06-06 04:34:31 +03:00
|
|
|
|
|
2022-06-24 22:47:44 +03:00
|
|
|
|
mcl_structures.register_structure("fossil",{
|
2022-06-25 07:16:43 +03:00
|
|
|
|
place_on = {"group:material_stone","group:sand"},
|
2022-06-24 22:47:44 +03:00
|
|
|
|
fill_ratio = 0.01,
|
|
|
|
|
flags = "place_center_x, place_center_z",
|
|
|
|
|
solid_ground = true,
|
|
|
|
|
sidelen = 13,
|
2022-06-25 07:16:43 +03:00
|
|
|
|
chunk_probability = 1000,
|
|
|
|
|
y_offset = function(pr) return ( pr:next(1,16) * -1 ) -16 end,
|
|
|
|
|
y_max = 15,
|
|
|
|
|
y_min = mcl_vars.mg_overworld_min + 35,
|
2022-06-24 22:47:44 +03:00
|
|
|
|
biomes = { "Desert" },
|
|
|
|
|
filenames = {
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_skull_1.mts", -- 4×5×5
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_skull_2.mts", -- 5×5×5
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_skull_3.mts", -- 5×5×7
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_skull_4.mts", -- 7×5×5
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_spine_1.mts", -- 3×3×13
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_spine_2.mts", -- 5×4×13
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_spine_3.mts", -- 7×4×13
|
|
|
|
|
modpath.."/schematics/mcl_structures_fossil_spine_4.mts", -- 8×5×13
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
2022-06-24 18:54:34 +03:00
|
|
|
|
mcl_structures.register_structure("boulder",{
|
|
|
|
|
filenames = {
|
|
|
|
|
modpath.."/schematics/mcl_structures_boulder_small.mts",
|
|
|
|
|
modpath.."/schematics/mcl_structures_boulder_small.mts",
|
|
|
|
|
modpath.."/schematics/mcl_structures_boulder_small.mts",
|
|
|
|
|
modpath.."/schematics/mcl_structures_boulder.mts",
|
2022-06-24 22:10:52 +03:00
|
|
|
|
-- small boulder 3x as likely
|
2022-06-24 18:54:34 +03:00
|
|
|
|
},
|
|
|
|
|
},true) --is spawned as a normal decoration. this is just for /spawnstruct
|
2022-10-24 06:26:47 +03:00
|
|
|
|
|
2022-06-24 18:54:34 +03:00
|
|
|
|
mcl_structures.register_structure("ice_spike_small",{
|
2022-10-24 06:26:47 +03:00
|
|
|
|
filenames = { modpath.."/schematics/mcl_structures_ice_spike_small.mts" },
|
2022-06-24 18:54:34 +03:00
|
|
|
|
},true) --is spawned as a normal decoration. this is just for /spawnstruct
|
|
|
|
|
mcl_structures.register_structure("ice_spike_large",{
|
|
|
|
|
sidelen = 6,
|
2022-10-24 06:26:47 +03:00
|
|
|
|
filenames = { modpath.."/schematics/mcl_structures_ice_spike_large.mts" },
|
2022-06-24 18:54:34 +03:00
|
|
|
|
},true) --is spawned as a normal decoration. this is just for /spawnstruct
|
|
|
|
|
|
2022-06-15 05:48:26 +03:00
|
|
|
|
-- Debug command
|
2022-10-24 06:26:47 +03:00
|
|
|
|
local function dir_to_rotation(dir)
|
|
|
|
|
local ax, az = math.abs(dir.x), math.abs(dir.z)
|
|
|
|
|
if ax > az then
|
|
|
|
|
if dir.x < 0 then
|
|
|
|
|
return "270"
|
|
|
|
|
end
|
|
|
|
|
return "90"
|
|
|
|
|
end
|
|
|
|
|
if dir.z < 0 then
|
|
|
|
|
return "180"
|
|
|
|
|
end
|
|
|
|
|
return "0"
|
|
|
|
|
end
|
|
|
|
|
|
2022-06-15 05:48:26 +03:00
|
|
|
|
minetest.register_chatcommand("spawnstruct", {
|
2022-10-24 05:09:08 +03:00
|
|
|
|
params = "dungeon",
|
2022-06-15 05:48:26 +03:00
|
|
|
|
description = S("Generate a pre-defined structure near your position."),
|
|
|
|
|
privs = {debug = true},
|
|
|
|
|
func = function(name, param)
|
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
|
if not player then return end
|
|
|
|
|
local pos = player:get_pos()
|
|
|
|
|
if not pos then return end
|
|
|
|
|
pos = vector.round(pos)
|
|
|
|
|
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
|
|
|
|
|
local rot = dir_to_rotation(dir)
|
|
|
|
|
local pr = PseudoRandom(pos.x+pos.y+pos.z)
|
|
|
|
|
local errord = false
|
|
|
|
|
local message = S("Structure placed.")
|
2022-10-24 05:09:08 +03:00
|
|
|
|
if param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then
|
2022-06-15 05:48:26 +03:00
|
|
|
|
mcl_dungeons.spawn_dungeon(pos, rot, pr)
|
|
|
|
|
elseif param == "" then
|
|
|
|
|
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
|
|
|
|
errord = true
|
|
|
|
|
else
|
|
|
|
|
for n,d in pairs(mcl_structures.registered_structures) do
|
|
|
|
|
if n == param then
|
2022-10-24 06:26:47 +03:00
|
|
|
|
mcl_structures.place_structure(pos,d,pr,math.random(),rot)
|
2022-06-15 05:48:26 +03:00
|
|
|
|
return true,message
|
2022-06-10 03:40:33 +03:00
|
|
|
|
end
|
|
|
|
|
end
|
2022-06-15 05:48:26 +03:00
|
|
|
|
message = S("Error: Unknown structure type. Please use “/spawnstruct <type>”.")
|
|
|
|
|
errord = true
|
|
|
|
|
end
|
|
|
|
|
minetest.chat_send_player(name, message)
|
|
|
|
|
if errord then
|
|
|
|
|
minetest.chat_send_player(name, S("Use /help spawnstruct to see a list of avaiable types."))
|
2022-06-10 03:40:33 +03:00
|
|
|
|
end
|
2022-06-15 05:48:26 +03:00
|
|
|
|
end
|
|
|
|
|
})
|
|
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
|
local p = ""
|
|
|
|
|
for n,_ in pairs(mcl_structures.registered_structures) do
|
|
|
|
|
p = p .. " | "..n
|
|
|
|
|
end
|
|
|
|
|
minetest.registered_chatcommands["spawnstruct"].params = minetest.registered_chatcommands["spawnstruct"].params .. p
|
2022-06-10 03:40:33 +03:00
|
|
|
|
end)
|