mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Fix chatcommand not under mcl_structures in /help
This commit is contained in:
parent
726d1f07fa
commit
92da429f50
1 changed files with 66 additions and 67 deletions
|
@ -573,74 +573,73 @@ end
|
||||||
|
|
||||||
dofile(modpath.."/api.lua")
|
dofile(modpath.."/api.lua")
|
||||||
|
|
||||||
minetest.register_on_mods_loaded(function()
|
-- Debug command
|
||||||
-- Debug command
|
minetest.register_chatcommand("spawnstruct", {
|
||||||
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"
|
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",
|
||||||
|
description = S("Generate a pre-defined structure near your position."),
|
||||||
for n,_ in pairs(mcl_structures.registered_structures) do
|
privs = {debug = true},
|
||||||
chatcommand_params = chatcommand_params .. " | "..n
|
func = function(name, param)
|
||||||
end
|
local player = minetest.get_player_by_name(name)
|
||||||
|
if not player then return end
|
||||||
minetest.register_chatcommand("spawnstruct", {
|
local pos = player:get_pos()
|
||||||
params = chatcommand_params,
|
if not pos then return end
|
||||||
description = S("Generate a pre-defined structure near your position."),
|
pos = vector.round(pos)
|
||||||
privs = {debug = true},
|
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
|
||||||
func = function(name, param)
|
local rot = dir_to_rotation(dir)
|
||||||
local player = minetest.get_player_by_name(name)
|
local pr = PseudoRandom(pos.x+pos.y+pos.z)
|
||||||
if not player then return end
|
local errord = false
|
||||||
local pos = player:get_pos()
|
local message = S("Structure placed.")
|
||||||
if not pos then return end
|
if param == "desert_temple" then
|
||||||
pos = vector.round(pos)
|
mcl_structures.generate_desert_temple(pos, rot, pr)
|
||||||
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
|
elseif param == "desert_well" then
|
||||||
local rot = dir_to_rotation(dir)
|
mcl_structures.generate_desert_well(pos, rot)
|
||||||
local pr = PseudoRandom(pos.x+pos.y+pos.z)
|
elseif param == "igloo" then
|
||||||
local errord = false
|
mcl_structures.generate_igloo(pos, rot, pr)
|
||||||
local message = S("Structure placed.")
|
elseif param == "witch_hut" then
|
||||||
if param == "desert_temple" then
|
mcl_structures.generate_witch_hut(pos, rot, pr)
|
||||||
mcl_structures.generate_desert_temple(pos, rot, pr)
|
elseif param == "boulder" then
|
||||||
elseif param == "desert_well" then
|
mcl_structures.generate_boulder(pos, rot, pr)
|
||||||
mcl_structures.generate_desert_well(pos, rot)
|
elseif param == "fossil" then
|
||||||
elseif param == "igloo" then
|
mcl_structures.generate_fossil(pos, rot, pr)
|
||||||
mcl_structures.generate_igloo(pos, rot, pr)
|
elseif param == "ice_spike_small" then
|
||||||
elseif param == "witch_hut" then
|
mcl_structures.generate_ice_spike_small(pos, rot, pr)
|
||||||
mcl_structures.generate_witch_hut(pos, rot, pr)
|
elseif param == "ice_spike_large" then
|
||||||
elseif param == "boulder" then
|
mcl_structures.generate_ice_spike_large(pos, rot, pr)
|
||||||
mcl_structures.generate_boulder(pos, rot, pr)
|
elseif param == "end_exit_portal" then
|
||||||
elseif param == "fossil" then
|
mcl_structures.generate_end_exit_portal(pos, rot, pr)
|
||||||
mcl_structures.generate_fossil(pos, rot, pr)
|
elseif param == "end_exit_portal_open" then
|
||||||
elseif param == "ice_spike_small" then
|
mcl_structures.generate_end_exit_portal_open(pos, rot, pr)
|
||||||
mcl_structures.generate_ice_spike_small(pos, rot, pr)
|
elseif param == "end_gateway_portal" then
|
||||||
elseif param == "ice_spike_large" then
|
mcl_structures.generate_end_gateway_portal(pos, rot, pr)
|
||||||
mcl_structures.generate_ice_spike_large(pos, rot, pr)
|
elseif param == "end_portal_shrine" then
|
||||||
elseif param == "end_exit_portal" then
|
mcl_structures.generate_end_portal_shrine(pos, rot, pr)
|
||||||
mcl_structures.generate_end_exit_portal(pos, rot, pr)
|
elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then
|
||||||
elseif param == "end_exit_portal_open" then
|
mcl_dungeons.spawn_dungeon(pos, rot, pr)
|
||||||
mcl_structures.generate_end_exit_portal_open(pos, rot, pr)
|
elseif param == "nether_portal" and mcl_portals and mcl_portals.spawn_nether_portal then
|
||||||
elseif param == "end_gateway_portal" then
|
mcl_portals.spawn_nether_portal(pos, rot, pr, name)
|
||||||
mcl_structures.generate_end_gateway_portal(pos, rot, pr)
|
elseif param == "" then
|
||||||
elseif param == "end_portal_shrine" then
|
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
||||||
mcl_structures.generate_end_portal_shrine(pos, rot, pr)
|
errord = true
|
||||||
elseif param == "dungeon" and mcl_dungeons and mcl_dungeons.spawn_dungeon then
|
else
|
||||||
mcl_dungeons.spawn_dungeon(pos, rot, pr)
|
for n,d in pairs(mcl_structures.registered_structures) do
|
||||||
elseif param == "nether_portal" and mcl_portals and mcl_portals.spawn_nether_portal then
|
if n == param then
|
||||||
mcl_portals.spawn_nether_portal(pos, rot, pr, name)
|
mcl_structures.place_structure(pos,d,pr)
|
||||||
elseif param == "" then
|
return true,message
|
||||||
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
|
|
||||||
mcl_structures.place_structure(pos,d,pr)
|
|
||||||
return true,message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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."))
|
|
||||||
end
|
end
|
||||||
|
message = S("Error: Unknown structure type. Please use “/spawnstruct <type>”.")
|
||||||
|
errord = true
|
||||||
end
|
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."))
|
||||||
|
end
|
||||||
|
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
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue