cartographer/commands.lua

44 lines
1.3 KiB
Lua
Raw Normal View History

2020-02-16 18:55:07 +01:00
local MAXINT = 2147483647;
minetest.register_chatcommand("map", {
params = "[<detail>]",
func = function(name, detail)
local player = minetest.get_player_by_name(name);
local pos = player:get_pos();
local spawn_x = nil;
local spawn_y = nil;
if _cartographer.spawns[name] then
spawn_x = tochunk(_cartographer.spawns[name].x);
spawn_y = tochunk(_cartographer.spawns[name].z);
end
local death_x = nil;
local death_y = nil;
if _cartographer.last_deaths[name] then
death_x = tochunk(_cartographer.last_deaths[name].x);
death_y = tochunk(_cartographer.last_deaths[name].z);
end
local player_x = tochunk(pos.x);
local player_y = tochunk(pos.z);
if detail == "" then
detail = MAXINT;
end
minetest.show_formspec(name, "map", cartographer.get_map_formspec(data, tochunk(pos.x), tochunk(pos.z), 40, 40, spawn_x, spawn_y, death_x, death_y, detail));
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,
})