Remove home/death marker code

This commit is contained in:
Hugues Ross 2020-03-08 10:06:26 -04:00
parent 17e0ade3f4
commit 85eeb529b6
5 changed files with 8 additions and 69 deletions

View File

@ -6,20 +6,6 @@ minetest.register_chatcommand("map", {
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);
@ -27,7 +13,7 @@ minetest.register_chatcommand("map", {
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));
minetest.show_formspec(name, "map", cartographer.get_map_formspec(data, tochunk(pos.x), tochunk(pos.z), 40, 40, detail));
end,
})

View File

@ -10,8 +10,6 @@ _cartographer = {
biome_lookup = {},
maps = minetest.deserialize(mod_storage:get_string("maps")) or {},
next_map_id = mod_storage:get_int("next_map_id"),
last_deaths = minetest.deserialize(mod_storage:get_string("deaths")) or {},
spawns = minetest.deserialize(mod_storage:get_string("spawns")) or {},
materials_by_name = {},
materials_by_group = {},
@ -29,8 +27,6 @@ local function save()
mod_storage:set_string("maps", minetest.serialize(_cartographer.maps));
mod_storage:set_int("next_map_id", _cartographer.next_map_id);
mod_storage:set_string("map", minetest.serialize(data.generated));
mod_storage:set_string("deaths", minetest.serialize(_cartographer.last_deaths));
mod_storage:set_string("spawns", minetest.serialize(_cartographer.spawns));
end
minetest.register_on_shutdown(save);
minetest.register_on_leaveplayer(save);
@ -49,16 +45,6 @@ function fromchunk(coord)
return math.floor(coord * _cartographer.CHUNK_SIZE);
end
minetest.register_on_respawnplayer(function(player)
_cartographer.last_deaths[player:get_player_name()] = player:get_pos();
end)
minetest.register_on_newplayer(function(player)
minetest.after(1, function(player)
_cartographer.spawns[player:get_player_name()] = player:get_pos();
end, player);
end)
-- The path to this mod, for including files
local modpath = minetest.get_modpath("cartographer");

View File

@ -9,20 +9,6 @@ minetest.register_node("cartographer:map", {
local pos = player:get_pos();
local name = player:get_player_name();
local spawn_x = nil;
local spawn_y = nil;
if _cartographer.spawns[name] ~= nil 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] ~= nil 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);
@ -41,7 +27,7 @@ minetest.register_node("cartographer:map", {
cartographer.fill_local(id, player_x, player_y);
minetest.show_formspec(player:get_player_name(), "map", cartographer.get_map_formspec_map(data, cartographer.get_map(id), player_x, player_y, spawn_x, spawn_y, death_x, death_y));
minetest.show_formspec(player:get_player_name(), "map", cartographer.get_map_formspec_map(data, cartographer.get_map(id), player_x, player_y));
return stack;
end,
@ -59,20 +45,6 @@ minetest.register_node("cartographer:map", {
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos);
local spawn_x = nil;
local spawn_y = nil;
if _cartographer.spawns[name] ~= nil 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] ~= nil 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);
@ -86,7 +58,7 @@ minetest.register_node("cartographer:map", {
cartographer.fill_local(id, player_x, player_y);
minetest.show_formspec(player:get_player_name(), "map", cartographer.get_map_formspec_map(data, cartographer.get_map(id), player_x, player_y, spawn_x, spawn_y, death_x, death_y));
minetest.show_formspec(player:get_player_name(), "map", cartographer.get_map_formspec_map(data, cartographer.get_map(id), player_x, player_y));
end,
});

View File

@ -15,7 +15,7 @@ local map_formspec_prefix = [[
local tile = "image[%f,%f;%f,%f;%s]";
local marker = "animated_image[%f,%f;%f,%f;%s:%d,%d]";
local function generate_map(data, x, y, w, h, player_x, player_y, spawn_x, spawn_y, death_x, death_y, detail, map_scale, is_visible, user)
local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_scale, is_visible, user)
local str = "";
local random = PcgRandom(x + y + w + h); -- TODO: Better seed
for i = x,x + w,1 do
@ -52,10 +52,6 @@ local function generate_map(data, x, y, w, h, player_x, player_y, spawn_x, spawn
if i == player_x and j == player_y then
str = str..marker:format(fx, fy - (height * 0.05), scale, scale, "cartographer_player_icon.png", 2, 500)
-- elseif i == death_x and j == death_y then
-- str = str..marker:format(fx, fy - (height * 0.025), scale, scale, "dicon.png")
-- elseif i == spawn_x and j == spawn_y then
-- str = str..marker:format(fx, fy - (height * 0.025), scale, scale, "cartographer_home_icon.png")
end
end
end
@ -64,10 +60,10 @@ local function generate_map(data, x, y, w, h, player_x, player_y, spawn_x, spawn
return str;
end
function cartographer.get_map_formspec(data, x, y, w, h, spawn_x, spawn_y, death_x, death_y, detail)
return map_formspec_prefix:format(w * scale, h * scale)..generate_map(data, x - (w * 0.5), y - (h * 0.5), w, h, x, y, spawn_x, spawn_y, death_x, death_y, detail, 4);
function cartographer.get_map_formspec(data, x, y, w, h, detail)
return map_formspec_prefix:format(w * scale, h * scale)..generate_map(data, x - (w * 0.5), y - (h * 0.5), w, h, x, y, detail, 4);
end
function cartographer.get_map_formspec_map(data, map, x, y, spawn_x, spawn_y, death_x, death_y)
return map_formspec_prefix:format(map.w * scale, map.h * scale)..generate_map(data, map.x, map.z, map.w, map.h, x, y, spawn_x, spawn_y, death_x, death_y, map.detail, 1, cartographer.is_filled, map);
function cartographer.get_map_formspec_map(data, map, x, y)
return map_formspec_prefix:format(map.w * scale, map.h * scale)..generate_map(data, map.x, map.z, map.w, map.h, x, y, map.detail, 1, cartographer.is_filled, map);
end

View File

@ -173,7 +173,6 @@ function cartographer.scan_regions()
y = startpos.y + CHUNK_SIZE,
z = startpos.z + CHUNK_SIZE,
};
--vector.add(startpos, CHUNK_SIZE);
if data.generated[startpos.x] ~= nil and data.generated[startpos.x][startpos.z] ~= nil then
return;