Various command-related fixes

This commit is contained in:
Hugues Ross 2020-04-26 10:21:24 -04:00
parent 8ccf1afbb6
commit 7c55cfaeaf
3 changed files with 12 additions and 8 deletions

View File

@ -16,14 +16,18 @@ minetest.register_chatcommand("map", {
if detail then
detail = tonumber(detail);
else
detail = MAXINT;
end
if scale then
scale = tonumber(scale);
else
scale = 1;
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));
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, scale, true));
end,
})

View File

@ -141,7 +141,7 @@ end
function cartographer.get_map_formspec(data, x, y, w, h, detail, scale, height_mode)
local formspec_width = (w + 1) * TILE_OFFSET + 0.01;
local formspec_height = (h + 1) * TILE_OFFSET + 0.01;
return map_formspec_prefix:format(formspec_width, formspec_height)..generate_map(data, x - (w * 0.5), y - (h * 0.5), w, h, x, z, detail, scale, height_mode),
return map_formspec_prefix:format(formspec_width, formspec_height)..generate_map(data, x - (w * 0.5), y - (h * 0.5), w, h, x, y, detail, scale, height_mode),
formspec_width,
formspec_height;
end

View File

@ -674,21 +674,21 @@ minetest.register_node("cartographer:advanced_table", {
});
function cartographer.register_map_material_name(name, material, value)
if _cartographer.materials_by_name[name] == nil then
if _cartographer.materials_by_name[name] then
_cartographer.materials_by_name[name][material] = value or 1;
else
_cartographer.materials_by_name[name] = {
[material] = value or 1,
};
else
_cartographer.materials_by_name[name][material] = value;
end
end
function cartographer.register_map_material_group(name, material, value)
if _cartographer.materials_by_group[name] == nil then
if _cartographer.materials_by_group[name] then
_cartographer.materials_by_group[name][material] = value or 1;
else
_cartographer.materials_by_group[name] = {
[material] = value or 1,
};
else
_cartographer.materials_by_group[name][material] = value;
end
end