40 lines
1.3 KiB
Lua
40 lines
1.3 KiB
Lua
local MAXINT = 2147483647;
|
|
|
|
-- /map <detail> <scale> -- Displays a regional map around the player
|
|
-- (Optional)detail: Specifies the map's detail level. Defaults to the highest
|
|
-- available detail.
|
|
-- (Optional)scale: Specifies the map's scale. Defaults to 1.
|
|
minetest.register_chatcommand("map", {
|
|
params = "[<detail>] [<scale>]",
|
|
func = function(name, param)
|
|
local player = minetest.get_player_by_name(name);
|
|
local pos = player:get_pos();
|
|
|
|
local player_x, player_z = cartographer.to_map_coordinates(nil, pos.x, pos.z);
|
|
|
|
local detail, scale = param:match("(%d*) (%d*)");
|
|
|
|
if detail then
|
|
detail = tonumber(detail);
|
|
end
|
|
|
|
if scale then
|
|
scale = tonumber(scale);
|
|
end
|
|
|
|
cartographer.map_sound("cartographer_open_map", player);
|
|
minetest.show_formspec(name, "map", cartographer.get_map_formspec(data, math.floor(player_x / scale + 0.5), math.floor(player_z / scale + 0.5), 40, 40, detail or MAXINT, scale or 1, true));
|
|
end,
|
|
})
|
|
|
|
-- TODO: Remove before release
|
|
minetest.register_chatcommand("scan", {
|
|
func = function(name)
|
|
local player = minetest.get_player_by_name(name);
|
|
local pos = player:get_pos();
|
|
|
|
local b = minetest.get_biome_data(pos).biome;
|
|
minetest.chat_send_all(minetest.get_biome_name(b));
|
|
end,
|
|
})
|