mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
This commit is contained in:
parent
bf81bb7f07
commit
21e6c5ad1f
1 changed files with 36 additions and 14 deletions
|
@ -517,39 +517,61 @@ mcl_structures.register_structures = function(structure_type, structures)
|
|||
registered_structures[structure_type] = structures
|
||||
end
|
||||
|
||||
-- helper - finds the rotation value for a certain direction
|
||||
-- https://forum.minetest.net/viewtopic.php?t=13280
|
||||
-- by Exilyth
|
||||
local function dir_to_rotation(p_dir)
|
||||
if p_dir.x == 0 and p_dir.z > 0 then
|
||||
return "0"
|
||||
end
|
||||
if p_dir.x == 0 and p_dir.z < 0 then
|
||||
return "180"
|
||||
end
|
||||
if p_dir.x > 0 and p_dir.z == 0 then
|
||||
return "90"
|
||||
end
|
||||
if p_dir.x < 0 and p_dir.z == 0 then
|
||||
return "270"
|
||||
end
|
||||
return "0"
|
||||
end
|
||||
|
||||
-- Debug command
|
||||
minetest.register_chatcommand("spawnstruct", {
|
||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine",
|
||||
description = S("Generate a pre-defined structure near your position."),
|
||||
privs = {debug = true},
|
||||
func = function(name, param)
|
||||
local pos = minetest.get_player_by_name(name):get_pos()
|
||||
if not pos then
|
||||
return
|
||||
end
|
||||
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.")
|
||||
if param == "desert_temple" then
|
||||
mcl_structures.generate_desert_temple(pos)
|
||||
mcl_structures.generate_desert_temple(pos, rot, pr)
|
||||
elseif param == "desert_well" then
|
||||
mcl_structures.generate_desert_well(pos)
|
||||
mcl_structures.generate_desert_well(pos, rot, pr)
|
||||
elseif param == "igloo" then
|
||||
mcl_structures.generate_igloo(pos)
|
||||
mcl_structures.generate_igloo(pos, rot, pr)
|
||||
elseif param == "witch_hut" then
|
||||
mcl_structures.generate_witch_hut(pos)
|
||||
mcl_structures.generate_witch_hut(pos, rot, pr)
|
||||
elseif param == "boulder" then
|
||||
mcl_structures.generate_boulder(pos)
|
||||
mcl_structures.generate_boulder(pos, rot, pr)
|
||||
elseif param == "fossil" then
|
||||
mcl_structures.generate_fossil(pos)
|
||||
mcl_structures.generate_fossil(pos, rot, pr)
|
||||
elseif param == "ice_spike_small" then
|
||||
mcl_structures.generate_ice_spike_small(pos)
|
||||
mcl_structures.generate_ice_spike_small(pos, rot, pr)
|
||||
elseif param == "ice_spike_large" then
|
||||
mcl_structures.generate_ice_spike_large(pos)
|
||||
mcl_structures.generate_ice_spike_large(pos, rot, pr)
|
||||
elseif param == "end_exit_portal" then
|
||||
mcl_structures.generate_end_exit_portal(pos)
|
||||
mcl_structures.generate_end_exit_portal(pos, rot, pr)
|
||||
elseif param == "end_portal_shrine" then
|
||||
mcl_structures.generate_end_portal_shrine(pos)
|
||||
mcl_structures.generate_end_portal_shrine(pos, rot, pr)
|
||||
elseif param == "" then
|
||||
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
||||
errord = true
|
||||
|
|
Loading…
Reference in a new issue