Initial commit

This commit is contained in:
Hugues Ross 2020-02-16 12:55:07 -05:00
commit d0f7c58c47
79 changed files with 1911 additions and 0 deletions

43
commands.lua Normal file
View File

@ -0,0 +1,43 @@
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,
})

77
init.lua Normal file
View File

@ -0,0 +1,77 @@
local mod_storage = minetest.get_mod_storage();
-- The API object
cartographer = {
biome_lookup = {},
biome_heights = {},
scan_queue = {},
};
_cartographer = {
CHUNK_SIZE = 16,
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 = {},
};
if _cartographer.next_map_id == 0 then
_cartographer.next_map_id = 1;
end
data = {
generated = minetest.deserialize(mod_storage:get_string("map")) or {},
}
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);
local function periodic_save()
save();
minetest.after(60, periodic_save);
end
minetest.after(60, periodic_save);
function tochunk(coord)
return math.floor(coord / _cartographer.CHUNK_SIZE);
end
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");
-- Includes
dofile(modpath .. "/commands.lua");
dofile(modpath .. "/scanner.lua");
dofile(modpath .. "/map_api.lua");
dofile(modpath .. "/map_formspec.lua");
dofile(modpath .. "/items.lua");
dofile(modpath .. "/table.lua");
-- Setup mod/game support
if minetest.get_modpath("default") then
dofile(modpath .. "/repixture.lua");
end

146
items.lua Normal file
View File

@ -0,0 +1,146 @@
minetest.register_node("cartographer:map", {
description = "Map",
inventory_image = "cartographer_map.png",
drawtype = "signlike",
paramtype = "light",
paramtype2 = "wallmounted",
stack_max = 1,
on_use = function(stack, player, _)
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);
local meta = stack:get_meta();
local id = meta:get_int("cartographer:map_id");
if id == 0 then
local size = meta:get_int("cartographer:size") or 10;
local detail = meta:get_int("cartographer:detail") or 1;
local map_x = math.floor((player_x + 10)/size)*size-10
local map_y = math.floor((player_y + 10)/size)*size-10;
id = cartographer.create_map(map_x,map_y,size,size,false, detail);
meta:set_int("cartographer:map_id", id);
meta:set_string("description", "Map #" .. tostring(id) .. "\n[" .. tostring(fromchunk(map_x)) .. "," .. tostring(fromchunk(map_y)) .. "] - [" .. tostring(fromchunk(map_x + size)) .. "," .. tostring(fromchunk(map_y + size)) .. "]")
end
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));
return stack;
end,
after_place_node = function(stack, placer, pointed_thing)
local meta = stack:get_meta():to_table();
local s = minetest.item_place(stack, placer, pointed_thing);
local node_meta = minetest.get_meta(pointed_thing);
node_meta:from_table(meta);
return nil;
end,
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);
local id = meta:get_int("cartographer:map_id");
if id == 0 then
local map_x = math.floor((player_x + 10)/20)*20-10
local map_y = math.floor((player_y + 10)/20)*20-10;
id = cartographer.create_map(map_x,map_y,20,20,false);
meta:set_int("cartographer:map_id", id);
end
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));
end,
});
function cartographer.create_map_item(size, detail)
local map = ItemStack("cartographer:map");
local meta = map:get_meta();
meta:set_int("cartographer:size", size);
meta:set_int("cartographer:detail", detail);
meta:set_string("description", "Empty Map\nUse to set the initial location");
return map;
end
function cartographer.copy_map_item(stack)
local meta = stack:get_meta();
local size = meta:get_int("cartographer:size");
local detail = meta:get_int("cartographer:detail");
local copy = cartographer.create_map_item(size, detail);
local copy_meta = copy:get_meta();
local id = meta:get_int("cartographer:map_id");
local new_id = 0;
if id > 0 then
local src = cartographer.get_map(id);
new_id = cartographer.create_map(src.x, src.z, src.w, src.h, false, src.detail);
local dest = cartographer.get_map(new_id);
for k,v in pairs(src.fill) do
dest.fill[k] = v;
end
copy_meta:set_int("cartographer:map_id", new_id);
copy_meta:set_string("description", "Map #" .. tostring(new_id) .. "\n[" .. tostring(fromchunk(dest.x)) .. "," .. tostring(fromchunk(dest.z)) .. "] - [" .. tostring(fromchunk(dest.x + dest.w)) .. "," .. tostring(fromchunk(dest.z + dest.h)) .. "]")
end
return copy;
end
function cartographer.resize_map_item(meta, size)
local old_size = meta:get_int("cartographer:size");
if old_size >= size then
return;
end
meta:set_int("cartographer:size", size);
local id = meta:get_int("cartographer:map_id");
if id > 0 then
local map = cartographer.get_map(id);
cartographer.resize_map(id, size, size);
meta:set_string("description", "Map #" .. tostring(id) .. "\n[" .. tostring(fromchunk(map.x)) .. "," .. tostring(fromchunk(map.z)) .. "] - [" .. tostring(fromchunk(map.x + map.w)) .. "," .. tostring(fromchunk(map.z + map.h)) .. "]")
end
end

110
map_api.lua Normal file
View File

@ -0,0 +1,110 @@
function cartographer.create_map(x, z, w, h, filled, detail)
local id = _cartographer.next_map_id;
local map = {
id = id,
x = x,
z = z,
w = w,
h = h,
detail = detail,
fill = {},
};
_cartographer.maps[id] = map;
if filled then
cartographer.fill(map, x, z, w, h);
end
_cartographer.next_map_id = _cartographer.next_map_id + 1;
return id;
end
function cartographer.get_map(id)
return _cartographer.maps[id];
end
function cartographer.resize_map(id, w, h)
local map = cartographer.get_map(id);
if map ~= nil and w >= map.w and h >= map.h then
map.w = w;
map.h = h;
end
end
function cartographer.fill(map, x, z, w, h)
if map == nil then
return;
end
for i = math.max(x, map.x),math.min(x + w - 1, map.x + map.w),1 do
for j = math.max(z, map.z),math.min(z + h - 1, map.z + map.h),1 do
map.fill[(i - map.x) + ((j - map.z) * map.w)] = map.detail;
end
end
end
function cartographer.fill_local(id, x, z)
local map = cartographer.get_map(id);
if map ~= nil and x >= map.x - 2 and x <= map.x + map.w + 1 and z >= map.z - 2 and z <= map.z + map.h + 1 then
minetest.chat_send_all("[" .. tostring(x) .. ", " .. tostring(z) .. "] - [" .. tostring(map.x - 2) .. ", " .. tostring(map.z - 2) .. "], [" .. tostring(map.x + map.w + 1) .. ", " .. tostring(map.z + map.h + 1) .. "]");
cartographer.fill(map, x - 2, z - 2, 5, 5);
end
end
local timer = 0;
minetest.register_globalstep(function(dt)
timer = timer - dt;
if timer < 0 then
timer = timer + 5;
-- Fill in all player-held maps
for _,p in ipairs(minetest.get_connected_players()) do
local inventory = p:get_inventory();
local pos = p:get_pos();
local player_x = tochunk(pos.x);
local player_y = tochunk(pos.z);
for i = 1,inventory:get_size("main") do
local stack = inventory:get_stack("main", i);
if stack:get_name() == "cartographer:map" then
cartographer.fill_local(stack:get_meta():get_int("cartographer:map_id"), player_x, player_y);
end
end
for i = -2,2 do
for j = -2,2 do
local adjusted_pos = {
x = tochunk(pos.x + fromchunk(i)),
y = tochunk(pos.y),
z = tochunk(pos.z + fromchunk(j)),
}
cartographer.queue_region(adjusted_pos);
end
end
end
for i = 1,10 do
cartographer.scan_regions();
end
end
end)
function cartographer.register_biome(name, texture, height)
cartographer.biome_lookup[name] = texture;
if height ~= nil and height ~= 0 then
cartographer.biome_heights[name] = height;
end
end
function cartographer.is_filled(map, x, z)
if map == nil then
return false;
end
minetest.chat_send_all(tostring(x).. ", " .. tostring(z) .. "(" .. tostring(x + (z * map.w)) .."): " .. tostring(map.fill[x + (z * map.w)]));
return map.fill[(x - map.x) + ((z - map.z) * map.w)] ~= nil;
end

64
map_formspec.lua Normal file
View File

@ -0,0 +1,64 @@
local scale = 0.25;
local variant_odds = { 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4 };
local function get_variant(random)
return variant_odds[random:next(1, 12)];
end
local map_formspec_prefix = [[
formspec_version[3]
size[%f,%f]
real_coordinates[true]
style_type[image_button;border=false]
]];
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, is_visible, user)
local str = "";
local random = PcgRandom(x + y + w + h); -- TODO: Better seed
for i = x,x + w,1 do
local fx = (i - x) * (scale - 0.01);
local column = data.generated[i];
for j = y + h,y,-1 do
local fy = (y + h - j) * (scale - 0.01);
if column == nil or column[j] == nil or (is_visible and not is_visible(user, i, j)) then
str = str..tile:format(fx, fy, scale, scale, "cartographer_unknown_biome." .. tostring(get_variant(random)) .. ".png")
else
local name = minetest.get_biome_name(column[j]);
local biome = cartographer.biome_lookup[name];
local height = cartographer.biome_heights[name] or 0;
if biome == nil then
minetest.chat_send_all(name);
str = str..tile:format(fx, fy, scale, scale, "cartographer_unknown_biome." .. tostring(get_variant(random)) .. ".png")
else
if height > 0 then
str = str..tile:format(fx, fy, scale, scale, "cartographer_cliff.png")
end
str = str..tile:format(fx, fy - (height * 0.025), scale, scale, biome[math.min(detail, #biome)] .. "." .. tostring(get_variant(random)) .. ".png")
end
if i == player_x and j == player_y then
str = str..marker:format(fx, fy - (height * 0.025), 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
end
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);
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, cartographer.is_filled, map);
end

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = cartographer
description = Adds an unlockable world map
optional_depends = crafting

Binary file not shown.

View File

@ -0,0 +1,749 @@
# Blender v2.81 (sub 16) OBJ File: 'simple_table.blend'
# www.blender.org
o Legs_Plane.001
v 0.437500 -0.437500 -0.312500
v 0.375000 -0.437500 -0.312500
v 0.437500 -0.437500 0.312500
v 0.375000 -0.437500 0.312500
v 0.437500 -0.375000 0.312500
v 0.437500 -0.375000 -0.312500
v 0.375000 -0.375000 -0.312500
v 0.375000 -0.375000 0.312500
v 0.375000 -0.437500 -0.375000
v 0.437500 -0.437500 -0.375000
v 0.437500 -0.437500 0.062500
v 0.375000 -0.437500 0.062500
v 0.437500 -0.375000 0.062500
v 0.375000 -0.375000 0.062500
v 0.437500 -0.437500 0.062500
v 0.437500 -0.437500 -0.062500
v 0.437500 -0.375000 -0.062167
v 0.437500 -0.437500 -0.061835
v 0.375000 -0.437500 -0.061835
v 0.375000 -0.375000 -0.061835
v 0.375000 0.125000 -0.061835
v 0.375000 0.125000 0.062500
v 0.437500 0.125000 0.062500
v 0.437500 0.125000 -0.062167
v 0.375000 0.250000 -0.061835
v 0.375000 0.312500 0.062500
v 0.437500 0.312500 0.062500
v 0.437500 0.250000 -0.062167
v 0.437500 -0.375000 -0.375000
v 0.375000 -0.375000 -0.375000
v 0.375000 -0.437500 0.375000
v 0.437500 -0.437500 0.375000
v 0.375000 -0.375000 0.375000
v 0.437500 -0.375000 0.375000
v 0.375000 -0.312500 0.312500
v 0.437500 -0.312500 0.312500
v 0.375000 -0.312500 0.375000
v 0.437500 -0.312500 0.375000
v 0.375000 -0.500000 0.312500
v 0.437500 -0.500000 0.312500
v 0.375000 -0.500000 0.375000
v 0.437500 -0.500000 0.375000
v 0.437500 -0.500000 -0.312500
v 0.375000 -0.500000 -0.312500
v 0.437500 -0.500000 -0.375000
v 0.375000 -0.500000 -0.375000
v 0.437500 -0.312500 -0.312500
v 0.375000 -0.312500 -0.312500
v 0.437500 -0.312500 -0.375000
v 0.375000 -0.312500 -0.375000
v -0.437500 -0.437500 -0.312500
v -0.375000 -0.437500 -0.312500
v -0.437500 -0.437500 0.312500
v -0.375000 -0.437500 0.312500
v -0.437500 -0.375000 0.312500
v -0.437500 -0.375000 -0.312500
v -0.375000 -0.375000 -0.312500
v -0.375000 -0.375000 0.312500
v -0.375000 -0.437500 -0.375000
v -0.437500 -0.437500 -0.375000
v -0.437500 -0.437500 0.062500
v -0.375000 -0.437500 0.062500
v -0.437500 -0.375000 0.062500
v -0.375000 -0.375000 0.062500
v -0.437500 -0.437500 0.062500
v -0.437500 -0.437500 -0.062500
v -0.437500 -0.375000 -0.062167
v -0.437500 -0.437500 -0.061835
v -0.375000 -0.437500 -0.061835
v -0.375000 -0.375000 -0.061835
v -0.375000 0.125000 -0.061835
v -0.375000 0.125000 0.062500
v -0.437500 0.125000 0.062500
v -0.437500 0.125000 -0.062167
v -0.375000 0.250000 -0.061835
v -0.375000 0.312500 0.062500
v -0.437500 0.312500 0.062500
v -0.437500 0.250000 -0.062167
v -0.437500 -0.375000 -0.375000
v -0.375000 -0.375000 -0.375000
v -0.375000 -0.437500 0.375000
v -0.437500 -0.437500 0.375000
v -0.375000 -0.375000 0.375000
v -0.437500 -0.375000 0.375000
v -0.375000 -0.312500 0.312500
v -0.437500 -0.312500 0.312500
v -0.375000 -0.312500 0.375000
v -0.437500 -0.312500 0.375000
v -0.375000 -0.500000 0.312500
v -0.437500 -0.500000 0.312500
v -0.375000 -0.500000 0.375000
v -0.437500 -0.500000 0.375000
v -0.437500 -0.500000 -0.312500
v -0.375000 -0.500000 -0.312500
v -0.437500 -0.500000 -0.375000
v -0.375000 -0.500000 -0.375000
v -0.437500 -0.312500 -0.312500
v -0.375000 -0.312500 -0.312500
v -0.437500 -0.312500 -0.375000
v -0.375000 -0.312500 -0.375000
vt 0.692308 0.333333
vt 0.615385 0.358974
vt 0.615385 0.333333
vt 0.615385 0.410256
vt 0.692308 0.384615
vt 0.615385 0.384615
vt 0.692308 0.435897
vt 0.615385 0.435897
vt 0.711538 0.410256
vt 0.692308 0.384615
vt 0.711538 0.384615
vt 0.480769 0.410256
vt 0.500000 0.384615
vt 0.500000 0.410256
vt 0.576923 0.384615
vt 0.500000 0.358974
vt 0.576923 0.358974
vt 0.634615 0.717949
vt 0.403846 0.666667
vt 0.634615 0.666667
vt 0.634615 0.666667
vt 0.653846 0.897436
vt 0.653846 0.666667
vt 0.615385 0.358974
vt 0.576923 0.333333
vt 0.576923 0.358974
vt 0.615385 0.384615
vt 0.692308 0.358974
vt 0.692308 0.384615
vt 0.653846 0.692308
vt 0.692308 0.666667
vt 0.653846 0.666667
vt 0.576923 0.333333
vt 0.500000 0.358974
vt 0.500000 0.333333
vt 0.576923 0.384615
vt 0.500000 0.384615
vt 0.576923 0.435897
vt 0.500000 0.435897
vt 0.653846 0.897436
vt 0.692308 0.948718
vt 0.653846 0.974359
vt 0.750000 0.666667
vt 0.711538 0.897436
vt 0.711538 0.666667
vt 0.692308 0.692308
vt 0.711538 0.897436
vt 0.711538 0.692308
vt 0.692308 0.692308
vt 0.653846 0.692308
vt 0.634615 0.897436
vt 0.653846 0.974359
vt 0.692308 0.897436
vt 0.634615 0.897436
vt 0.403846 0.974359
vt 0.634615 0.974359
vt 0.961538 0.897436
vt 0.711538 0.948718
vt 0.961538 0.948718
vt 0.423077 0.384615
vt 0.442308 0.410256
vt 0.423077 0.410256
vt 0.423077 0.358974
vt 0.442308 0.384615
vt 0.442308 0.358974
vt 0.403846 0.384615
vt 0.423077 0.384615
vt 0.442308 0.410256
vt 0.423077 0.435897
vt 0.423077 0.410256
vt 0.769231 0.410256
vt 0.750000 0.384615
vt 0.769231 0.384615
vt 0.769231 0.410256
vt 0.750000 0.435897
vt 0.750000 0.410256
vt 0.769231 0.384615
vt 0.788462 0.358974
vt 0.769231 0.358974
vt 0.750000 0.358974
vt 0.730769 0.384615
vt 0.711538 0.410256
vt 0.711538 0.384615
vt 0.730769 0.384615
vt 0.750000 0.384615
vt 0.750000 0.410256
vt 0.730769 0.384615
vt 0.730769 0.410256
vt 0.788462 0.410256
vt 0.807692 0.384615
vt 0.807692 0.410256
vt 0.826923 0.410256
vt 0.807692 0.384615
vt 0.826923 0.384615
vt 0.788462 0.435897
vt 0.769231 0.435897
vt 0.788462 0.410256
vt 0.403846 0.384615
vt 0.384615 0.410256
vt 0.384615 0.384615
vt 0.403846 0.384615
vt 0.403846 0.410256
vt 0.384615 0.384615
vt 0.365385 0.410256
vt 0.365385 0.384615
vt 0.461538 0.410256
vt 0.480769 0.384615
vt 0.480769 0.410256
vt 0.461538 0.358974
vt 0.461538 0.435897
vt 0.442308 0.435897
vt 0.442308 0.384615
vt 0.461538 0.410256
vt 0.403846 0.641026
vt 0.634615 0.589744
vt 0.634615 0.641026
vt 0.615385 0.487179
vt 0.692308 0.461538
vt 0.615385 0.461538
vt 0.692308 0.512821
vt 0.615385 0.538462
vt 0.615385 0.512821
vt 0.692308 0.564103
vt 0.615385 0.564103
vt 0.692308 0.512821
vt 0.711538 0.538462
vt 0.711538 0.512821
vt 0.500000 0.512821
vt 0.480769 0.538462
vt 0.500000 0.538462
vt 0.576923 0.512821
vt 0.500000 0.487179
vt 0.500000 0.512821
vt 0.403846 0.897436
vt 0.384615 0.666667
vt 0.576923 0.487179
vt 0.576923 0.461538
vt 0.692308 0.487179
vt 0.615385 0.512821
vt 0.692308 0.512821
vt 0.384615 0.692308
vt 0.346154 0.666667
vt 0.346154 0.692308
vt 0.500000 0.487179
vt 0.500000 0.461538
vt 0.576923 0.512821
vt 0.500000 0.512821
vt 0.576923 0.564103
vt 0.500000 0.564103
vt 0.384615 0.897436
vt 0.346154 0.948718
vt 0.346154 0.897436
vt 0.961538 0.897436
vt 0.923077 0.666667
vt 0.961538 0.666667
vt 0.980769 0.897436
vt 0.961538 0.692308
vt 0.980769 0.692308
vt 0.346154 0.692308
vt 0.384615 0.692308
vt 0.403846 0.974359
vt 0.980769 0.948718
vt 0.634615 0.846154
vt 0.634615 0.897436
vt 0.442308 0.538462
vt 0.423077 0.512821
vt 0.423077 0.538462
vt 0.442308 0.487179
vt 0.423077 0.512821
vt 0.442308 0.512821
vt 0.403846 0.487179
vt 0.423077 0.487179
vt 0.423077 0.564103
vt 0.442308 0.538462
vt 0.423077 0.538462
vt 0.750000 0.512821
vt 0.769231 0.538462
vt 0.769231 0.512821
vt 0.750000 0.564103
vt 0.769231 0.538462
vt 0.750000 0.538462
vt 0.788462 0.512821
vt 0.769231 0.487179
vt 0.769231 0.512821
vt 0.750000 0.512821
vt 0.711538 0.538462
vt 0.730769 0.512821
vt 0.711538 0.512821
vt 0.730769 0.487179
vt 0.750000 0.487179
vt 0.730769 0.512821
vt 0.750000 0.538462
vt 0.730769 0.538462
vt 0.807692 0.512821
vt 0.788462 0.538462
vt 0.807692 0.538462
vt 0.807692 0.512821
vt 0.826923 0.538462
vt 0.826923 0.512821
vt 0.788462 0.564103
vt 0.769231 0.564103
vt 0.788462 0.538462
vt 0.384615 0.538462
vt 0.403846 0.512821
vt 0.384615 0.512821
vt 0.403846 0.512821
vt 0.403846 0.538462
vt 0.365385 0.538462
vt 0.384615 0.512821
vt 0.365385 0.512821
vt 0.480769 0.512821
vt 0.461538 0.538462
vt 0.480769 0.538462
vt 0.461538 0.512821
vt 0.461538 0.564103
vt 0.442308 0.564103
vt 0.461538 0.538462
vt 0.442308 0.512821
vt 0.634615 0.717949
vt 0.403846 0.743590
vt 0.634615 0.743590
vt 0.692308 0.358974
vt 0.692308 0.410256
vt 0.692308 0.410256
vt 0.480769 0.384615
vt 0.500000 0.384615
vt 0.403846 0.717949
vt 0.615385 0.333333
vt 0.615385 0.358974
vt 0.692308 0.692308
vt 0.576923 0.358974
vt 0.576923 0.410256
vt 0.750000 0.897436
vt 0.692308 0.897436
vt 0.634615 0.974359
vt 0.711538 0.948718
vt 0.403846 0.897436
vt 0.711538 0.897436
vt 0.403846 0.358974
vt 0.788462 0.384615
vt 0.730769 0.410256
vt 0.730769 0.358974
vt 0.730769 0.410256
vt 0.730769 0.435897
vt 0.807692 0.410256
vt 0.788462 0.410256
vt 0.788462 0.384615
vt 0.403846 0.410256
vt 0.403846 0.410256
vt 0.403846 0.435897
vt 0.384615 0.410256
vt 0.461538 0.384615
vt 0.461538 0.410256
vt 0.461538 0.384615
vt 0.403846 0.589744
vt 0.692308 0.487179
vt 0.692308 0.538462
vt 0.692308 0.538462
vt 0.480769 0.512821
vt 0.576923 0.487179
vt 0.615385 0.487179
vt 0.576923 0.538462
vt 0.384615 0.974359
vt 0.923077 0.897436
vt 0.961538 0.948718
vt 0.403846 0.846154
vt 0.403846 0.512821
vt 0.788462 0.487179
vt 0.730769 0.538462
vt 0.730769 0.512821
vt 0.730769 0.538462
vt 0.730769 0.564103
vt 0.788462 0.512821
vt 0.807692 0.538462
vt 0.788462 0.538462
vt 0.788462 0.512821
vt 0.403846 0.538462
vt 0.403846 0.538462
vt 0.403846 0.564103
vt 0.384615 0.538462
vt 0.461538 0.512821
vt 0.461538 0.487179
vt 0.461538 0.538462
vt 0.461538 0.512821
vt 0.403846 0.717949
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 0.0000
vn -0.0053 0.0000 -1.0000
vn 0.0053 0.0000 -1.0000
s off
f 3/1/1 12/2/1 11/3/1
f 14/4/2 5/5/2 13/6/2
f 4/7/3 14/4/3 12/8/3
f 8/9/4 36/10/4 5/11/4
f 6/12/5 48/13/5 7/14/5
f 16/15/6 6/16/6 17/17/6
f 20/18/2 64/19/2 14/20/2
f 13/21/5 22/22/5 14/23/5
f 11/24/1 19/25/1 18/26/1
f 15/27/6 5/28/6 3/29/6
f 15/30/6 17/31/6 13/32/6
f 18/33/1 2/34/1 1/35/1
f 7/14/2 17/36/2 6/37/2
f 19/38/3 7/14/3 2/39/3
f 23/40/6 28/41/6 27/42/6
f 14/43/3 21/44/3 20/45/3
f 20/46/7 24/47/7 17/48/7
f 17/49/6 23/40/6 13/50/6
f 23/51/5 26/52/5 22/22/5
f 21/44/7 28/41/7 24/53/7
f 26/54/5 72/55/5 22/56/5
f 21/57/4 75/58/4 25/59/4
f 9/60/4 29/61/4 10/62/4
f 1/63/6 29/64/6 6/65/6
f 1/63/6 45/66/6 10/67/6
f 7/68/3 9/69/3 2/70/3
f 32/71/5 33/72/5 31/73/5
f 4/74/3 33/75/3 8/76/3
f 32/77/6 40/78/6 3/79/6
f 5/80/6 32/77/6 3/79/6
f 35/81/2 38/82/2 36/83/2
f 5/80/6 38/84/6 34/85/6
f 34/86/5 37/87/5 33/72/5
f 33/75/3 35/88/3 8/76/3
f 40/89/1 41/90/1 39/91/1
f 3/92/4 39/93/4 4/94/4
f 4/74/3 41/95/3 31/96/3
f 31/73/5 42/97/5 32/71/5
f 44/98/1 45/99/1 43/100/1
f 10/62/4 46/101/4 9/60/4
f 9/69/3 44/102/3 2/70/3
f 2/103/5 43/104/5 1/105/5
f 47/106/2 50/107/2 48/108/2
f 29/64/6 47/109/6 6/65/6
f 7/68/3 50/110/3 30/111/3
f 30/112/4 49/113/4 29/61/4
f 62/114/1 19/115/1 12/116/1
f 62/117/1 53/118/1 61/119/1
f 55/120/2 64/121/2 63/122/2
f 64/121/6 54/123/6 62/124/6
f 86/125/4 58/126/4 55/127/4
f 98/128/5 56/129/5 57/130/5
f 66/131/3 56/132/3 51/133/3
f 64/19/5 12/116/5 14/20/5
f 72/134/5 63/135/5 64/19/5
f 69/136/1 61/119/1 68/137/1
f 55/138/3 65/139/3 53/140/3
f 65/141/3 67/142/3 66/143/3
f 52/144/1 68/137/1 51/145/1
f 67/146/2 57/130/2 56/147/2
f 57/130/6 69/148/6 52/149/6
f 73/150/3 78/151/3 74/152/3
f 71/153/6 64/154/6 70/155/6
f 74/156/8 70/157/8 67/158/8
f 73/150/3 67/159/3 63/160/3
f 76/161/5 73/150/5 72/134/5
f 78/162/8 71/153/8 74/156/8
f 72/134/1 21/163/1 22/164/1
f 79/165/4 59/166/4 60/167/4
f 79/168/3 51/169/3 56/170/3
f 95/171/3 51/169/3 60/172/3
f 59/173/6 57/174/6 52/175/6
f 83/176/5 82/177/5 81/178/5
f 83/179/6 54/180/6 58/181/6
f 90/182/3 82/183/3 53/184/3
f 82/183/3 55/185/3 53/184/3
f 88/186/2 85/187/2 86/188/2
f 88/189/3 55/185/3 84/190/3
f 87/191/5 84/192/5 83/176/5
f 85/193/6 83/179/6 58/181/6
f 91/194/1 90/195/1 89/196/1
f 89/197/4 53/198/4 54/199/4
f 91/200/6 54/180/6 81/201/6
f 92/202/5 81/178/5 82/177/5
f 95/203/1 94/204/1 93/205/1
f 96/206/4 60/167/4 59/166/4
f 94/207/6 59/173/6 52/175/6
f 93/208/5 52/209/5 51/210/5
f 100/211/2 97/212/2 98/213/2
f 97/214/3 79/168/3 56/170/3
f 100/215/6 57/174/6 80/216/6
f 99/217/4 80/218/4 79/165/4
f 19/219/4 70/220/4 20/221/4
f 3/1/1 4/222/1 12/2/1
f 14/4/2 8/223/2 5/5/2
f 4/7/3 8/223/3 14/4/3
f 8/9/4 35/224/4 36/10/4
f 6/12/5 47/225/5 48/13/5
f 16/15/6 1/226/6 6/16/6
f 20/18/2 70/227/2 64/19/2
f 13/21/5 23/51/5 22/22/5
f 11/24/1 12/228/1 19/25/1
f 15/27/6 13/229/6 5/28/6
f 15/30/6 16/230/6 17/31/6
f 18/33/1 19/231/1 2/34/1
f 7/14/2 20/232/2 17/36/2
f 19/38/3 20/232/3 7/14/3
f 23/40/6 24/53/6 28/41/6
f 14/43/3 22/233/3 21/44/3
f 20/46/7 21/234/7 24/47/7
f 17/49/6 24/53/6 23/40/6
f 23/51/5 27/235/5 26/52/5
f 21/44/7 25/236/7 28/41/7
f 26/54/5 76/237/5 72/55/5
f 21/57/4 71/238/4 75/58/4
f 9/60/4 30/112/4 29/61/4
f 1/63/6 10/67/6 29/64/6
f 1/63/6 43/239/6 45/66/6
f 7/68/3 30/111/3 9/69/3
f 32/71/5 34/86/5 33/72/5
f 4/74/3 31/96/3 33/75/3
f 32/77/6 42/240/6 40/78/6
f 5/80/6 34/85/6 32/77/6
f 35/81/2 37/241/2 38/82/2
f 5/80/6 36/242/6 38/84/6
f 34/86/5 38/243/5 37/87/5
f 33/75/3 37/244/3 35/88/3
f 40/89/1 42/240/1 41/90/1
f 3/92/4 40/245/4 39/93/4
f 4/74/3 39/246/3 41/95/3
f 31/73/5 41/247/5 42/97/5
f 44/98/1 46/248/1 45/99/1
f 10/62/4 45/249/4 46/101/4
f 9/69/3 46/250/3 44/102/3
f 2/103/5 44/251/5 43/104/5
f 47/106/2 49/252/2 50/107/2
f 29/64/6 49/252/6 47/109/6
f 7/68/3 48/253/3 50/110/3
f 30/112/4 50/254/4 49/113/4
f 62/114/1 69/255/1 19/115/1
f 62/117/1 54/256/1 53/118/1
f 55/120/2 58/257/2 64/121/2
f 64/121/6 58/257/6 54/123/6
f 86/125/4 85/258/4 58/126/4
f 98/128/5 97/259/5 56/129/5
f 66/131/3 67/260/3 56/132/3
f 64/19/5 62/114/5 12/116/5
f 72/134/5 73/150/5 63/135/5
f 69/136/1 62/117/1 61/119/1
f 55/138/3 63/261/3 65/139/3
f 65/141/3 63/135/3 67/142/3
f 52/144/1 69/136/1 68/137/1
f 67/146/2 70/262/2 57/130/2
f 57/130/6 70/262/6 69/148/6
f 73/150/3 77/263/3 78/151/3
f 71/153/6 72/264/6 64/154/6
f 74/156/8 71/153/8 70/157/8
f 73/150/3 74/152/3 67/159/3
f 76/161/5 77/263/5 73/150/5
f 78/162/8 75/265/8 71/153/8
f 72/134/1 71/266/1 21/163/1
f 79/165/4 80/218/4 59/166/4
f 79/168/3 60/172/3 51/169/3
f 95/171/3 93/267/3 51/169/3
f 59/173/6 80/216/6 57/174/6
f 83/176/5 84/192/5 82/177/5
f 83/179/6 81/201/6 54/180/6
f 90/182/3 92/268/3 82/183/3
f 82/183/3 84/190/3 55/185/3
f 88/186/2 87/269/2 85/187/2
f 88/189/3 86/270/3 55/185/3
f 87/191/5 88/271/5 84/192/5
f 85/193/6 87/272/6 83/179/6
f 91/194/1 92/273/1 90/195/1
f 89/197/4 90/274/4 53/198/4
f 91/200/6 89/275/6 54/180/6
f 92/202/5 91/276/5 81/178/5
f 95/203/1 96/277/1 94/204/1
f 96/206/4 95/278/4 60/167/4
f 94/207/6 96/279/6 59/173/6
f 93/208/5 94/280/5 52/209/5
f 100/211/2 99/281/2 97/212/2
f 97/214/3 99/282/3 79/168/3
f 100/215/6 98/283/6 57/174/6
f 99/217/4 100/284/4 80/218/4
f 19/219/4 69/285/4 70/220/4
o Surface_Plane.002
v 0.437500 -0.059359 -0.309359
v 0.437500 0.603553 0.353553
v 0.437500 0.647748 0.309359
v 0.437500 -0.015165 -0.353553
v 0.437500 -0.103553 -0.353553
v 0.437500 -0.059359 -0.397748
v 0.500000 0.603553 0.353553
v 0.500000 -0.059359 -0.309359
v 0.500000 0.647748 0.309359
v 0.500000 -0.015165 -0.353553
v 0.500000 -0.059359 -0.397748
v 0.500000 -0.103553 -0.353553
v 0.437500 0.029029 -0.397748
v 0.437500 -0.015165 -0.441942
v -0.437500 -0.059359 -0.309359
v -0.437500 0.603553 0.353553
v -0.437500 0.647748 0.309359
v -0.437500 -0.015165 -0.353553
v -0.437500 -0.103553 -0.353553
v -0.437500 -0.059359 -0.397748
v -0.500000 0.603553 0.353553
v -0.500000 -0.059359 -0.309359
v -0.500000 0.647748 0.309359
v -0.500000 -0.015165 -0.353553
v -0.500000 -0.059359 -0.397748
v -0.500000 -0.103553 -0.353553
v -0.437500 0.029029 -0.397748
v -0.437500 -0.015165 -0.441942
vt 0.038462 0.461538
vt 0.307692 0.435897
vt 0.307692 0.461538
vt 0.038462 0.051282
vt 0.038462 0.435897
vt 0.038462 0.974359
vt 0.019231 0.948718
vt 0.038462 0.948718
vt 0.038462 0.538462
vt 0.019231 0.512821
vt 0.038462 0.512821
vt 0.038462 0.564103
vt 0.019231 0.538462
vt 0.019231 0.948718
vt 0.000000 0.564103
vt 0.019231 0.564103
vt 0.019231 0.512821
vt 0.000000 0.538462
vt 0.000000 0.512821
vt 0.019231 0.435897
vt 0.019231 0.564103
vt 0.038462 0.564103
vt 0.038462 0.461538
vt 0.019231 0.487179
vt 0.038462 0.487179
vt 0.019231 0.051282
vt 0.307692 0.487179
vt 0.307692 0.974359
vt 0.307692 0.948718
vt 0.038462 0.487179
vt 0.307692 0.512821
vt 0.038462 0.512821
vt 0.307692 0.564103
vt 0.307692 0.948718
vt 0.326923 0.974359
vt 0.326923 0.948718
vt 0.307692 0.512821
vt 0.326923 0.538462
vt 0.326923 0.512821
vt 0.307692 0.538462
vt 0.326923 0.564103
vt 0.326923 0.564103
vt 0.346154 0.948718
vt 0.346154 0.564103
vt 0.326923 0.538462
vt 0.346154 0.512821
vt 0.326923 0.512821
vt 0.307692 0.435897
vt 0.326923 0.461538
vt 0.326923 0.435897
vt 0.307692 0.564103
vt 0.326923 0.564103
vt 0.307692 0.487179
vt 0.326923 0.461538
vt 0.307692 0.051282
vt 0.326923 0.051282
vt 0.038462 0.564103
vt 0.307692 0.538462
vt 0.038462 0.538462
vt 0.307692 0.512821
vt 0.038462 0.512821
vt 0.307692 0.051282
vt 0.019231 0.974359
vt 0.019231 0.538462
vt 0.019231 0.564103
vt 0.000000 0.948718
vt 0.019231 0.538462
vt 0.019231 0.461538
vt 0.019231 0.461538
vt 0.307692 0.974359
vt 0.307692 0.538462
vt 0.307692 0.564103
vt 0.326923 0.948718
vt 0.346154 0.538462
vt 0.307692 0.461538
vt 0.326923 0.487179
vt 0.307692 0.564103
vt 0.307692 0.538462
vn 0.0000 -0.7071 0.7071
vn 0.0000 0.7071 0.7071
vn 0.0000 0.7071 -0.7071
vn 1.0000 0.0000 0.0000
vn 0.0000 -0.7071 -0.7071
vn -1.0000 0.0000 0.0000
s off
f 105/286/9 115/287/9 119/288/9
f 102/289/9 115/287/9 101/290/9
f 102/291/10 109/292/10 103/293/10
f 104/294/11 111/295/11 106/296/11
f 106/297/12 113/298/12 104/294/12
f 108/299/12 109/300/12 107/301/12
f 108/302/12 111/303/12 110/304/12
f 105/286/9 108/305/9 101/290/9
f 103/293/11 110/306/11 104/307/11
f 106/308/13 112/309/13 105/310/13
f 101/290/9 107/311/9 102/289/9
f 120/312/13 105/286/13 119/288/13
f 116/313/10 103/293/10 117/314/10
f 106/315/13 128/316/13 114/317/13
f 118/318/11 103/293/11 104/307/11
f 123/319/10 116/320/10 117/321/10
f 125/322/11 118/323/11 120/324/11
f 127/325/14 120/326/14 118/323/14
f 123/327/14 122/328/14 121/329/14
f 125/330/14 122/331/14 124/332/14
f 122/333/9 119/334/9 115/335/9
f 124/336/11 117/321/11 118/337/11
f 126/338/13 120/339/13 119/288/13
f 121/340/9 115/335/9 116/341/9
f 113/342/10 118/343/10 104/294/10
f 114/344/11 127/345/11 113/346/11
f 105/286/9 101/290/9 115/287/9
f 102/289/9 116/347/9 115/287/9
f 102/291/10 107/348/10 109/292/10
f 104/294/11 110/349/11 111/295/11
f 106/297/12 114/350/12 113/298/12
f 108/299/12 110/351/12 109/300/12
f 108/302/12 112/352/12 111/303/12
f 105/286/9 112/353/9 108/305/9
f 103/293/11 109/292/11 110/306/11
f 106/308/13 111/354/13 112/309/13
f 101/290/9 108/305/9 107/311/9
f 120/312/13 106/315/13 105/286/13
f 116/313/10 102/291/10 103/293/10
f 106/315/13 120/312/13 128/316/13
f 118/318/11 117/314/11 103/293/11
f 123/319/10 121/355/10 116/320/10
f 125/322/11 124/356/11 118/323/11
f 127/325/14 128/357/14 120/326/14
f 123/327/14 124/358/14 122/328/14
f 125/330/14 126/359/14 122/331/14
f 122/333/9 126/360/9 119/334/9
f 124/336/11 123/319/11 117/321/11
f 126/338/13 125/361/13 120/339/13
f 121/340/9 122/333/9 115/335/9
f 113/342/10 127/362/10 118/343/10
f 114/344/11 128/363/11 127/345/11

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

89
repixture.lua Normal file
View File

@ -0,0 +1,89 @@
-- Biomes
cartographer.register_biome("Marsh", {
"cartographer_simple_land",
"cartographer_colored_land",
});
cartographer.register_biome("Swamp", {
"cartographer_simple_land",
"cartographer_colored_land",
"cartographer_colored_land",
"cartographer_swamp",
});
cartographer.register_biome("Deep Forest", {
"cartographer_simple_forest",
"cartographer_colored_forest",
"cartographer_deep_forest",
});
cartographer.register_biome("Forest", {
"cartographer_simple_forest",
"cartographer_colored_forest",
"cartographer_dense_forest",
});
cartographer.register_biome("Grove", {
"cartographer_simple_forest",
"cartographer_colored_forest",
"cartographer_grove",
});
cartographer.register_biome("Wilderness", {
"cartographer_simple_forest",
"cartographer_colored_forest",
});
cartographer.register_biome("Grassland", {
"cartographer_simple_land",
"cartographer_colored_land",
});
cartographer.register_biome("Orchard", {
"cartographer_simple_forest",
"cartographer_colored_forest",
});
cartographer.register_biome("Chaparral", {
"cartographer_simple_land",
"cartographer_colored_land",
"cartographer_colored_land",
"cartographer_chaparral",
});
cartographer.register_biome("Savanna", {
"cartographer_simple_land",
"cartographer_colored_land",
"cartographer_colored_land",
"cartographer_savanna",
});
cartographer.register_biome("Desert", {
"cartographer_simple_land",
"cartographer_colored_sand",
"cartographer_colored_sand",
});
cartographer.register_biome("Wasteland", {
"cartographer_simple_land",
"cartographer_colored_sand",
"cartographer_colored_sand",
"cartographer_wasteland",
});
cartographer.register_biome("Grassland Ocean", {
"cartographer_simple_water",
"cartographer_colored_water",
});
cartographer.register_biome("Gravel Beach", {
"cartographer_simple_land",
"cartographer_colored_sand",
"cartographer_gravel",
});
cartographer.register_biome("Savanna Ocean", {
"cartographer_simple_water",
"cartographer_colored_water",
});
-- Materials
cartographer.register_map_material_name("default:paper", "fiber", 5);
cartographer.register_map_material_name("default:lump_coal", "pigment");
cartographer.register_map_material_name("default:block_coal", "pigment", 9);
-- Crafting Recipes
crafting.register_craft({
output = "cartographer:simple_table",
items = {
"default:fiber 2",
"default:stick 8",
"group:wood 6",
},
});

169
scanner.lua Normal file
View File

@ -0,0 +1,169 @@
local CHUNK_SIZE = _cartographer.CHUNK_SIZE;
local function register_mapchunk(x, y, biome)
if not data.generated[x] then
data.generated[x] = {
[y] = biome,
};
elseif not data.generated[x][y] then
data.generated[x][y] = biome;
end
end
local function get_mapgen_biome(min, max, mmin, mmax)
local UNDERGROUND = minetest.get_biome_id("underground");
local DEFAULT = minetest.get_biome_id("default");
local biomes = minetest.get_mapgen_object("biomemap");
local xx = max.x - min.x;
local yy = max.y - min.y;
local zz = max.z - min.z;
local xxx = mmax.x - mmin.x;
local yyy = mmax.y - mmin.y;
local zzz = mmax.z - mmin.z;
local startx = min.x - mmin.x;
local starty = min.y - mmin.y;
local startz = min.z - mmin.z;
local scan_biomes = {};
for i = startx,startx + xx,1 do
for k = startz,startz + zz,1 do
local b = biomes[i + (k * (xxx + 1))]
if b ~= nil and b ~= UNDERGROUND and b ~= DEFAULT then
scan_biomes[b] = (scan_biomes[b] or 0) + 1;
end
end
end
local biome = nil;
local high = 0;
for k,v in pairs(scan_biomes) do
if v > high then
biome = k;
high = v;
end
end
return biome;
end
local function get_biome(min, max)
local UNDERGROUND = minetest.get_biome_id("underground");
local DEFAULT = minetest.get_biome_id("default");
local WATER_SOURCE = minetest.registered_aliases["mapgen_water_source"];
local xx = max.x - min.x;
local yy = max.y - min.y;
local zz = max.z - min.z;
local scan_biomes = {};
for i = min.x,max.x,1 do
for j = min.y,max.y,1 do
for k = min.z,max.z,1 do
local pos = { x=i, y=j, z=k };
local b = minetest.get_biome_data(pos).biome;
local node = minetest.get_node(pos).name;
if b ~= nil and b ~= UNDERGROUND and b ~= DEFAULT and node ~= "air" and node ~= WATER_SOURCE then
pos.y = pos.y + 1;
node = minetest.get_node(pos).name;
if node == "air" or node == WATER_SOURCE then
scan_biomes[b] = (scan_biomes[b] or 0) + 1;
end
end
end
end
end
local biome = nil;
local high = 0;
for k,v in pairs(scan_biomes) do
if v > high then
biome = k;
high = v;
end
end
return biome;
end
local function on_generated(min, max, blockseed)
local chunk = {
x = tochunk(min.x),
y = tochunk(min.z),
};
for i = tochunk(min.x),tochunk(max.x),1 do
for j = tochunk(min.z),tochunk(max.z),1 do
local sub_min = {
x = i * CHUNK_SIZE,
y = min.y,
z = j * CHUNK_SIZE,
};
local sub_max = {
x = i * CHUNK_SIZE + CHUNK_SIZE,
y = max.y,
z = j * CHUNK_SIZE + CHUNK_SIZE,
};
local biome = get_mapgen_biome(sub_min, sub_max, min, max);
if biome ~= nil then
register_mapchunk(i, j, biome)
end
end
end
end
function cartographer.queue_region(pos)
local converted = {
x = tochunk(pos.x) * CHUNK_SIZE,
y = tochunk(pos.y) * CHUNK_SIZE,
z = tochunk(pos.z) * CHUNK_SIZE,
};
if data.generated[pos.x] ~= nil and data.generated[pos.x][pos.z] ~= nil then
return;
end
for _,queued_pos in ipairs(cartographer.scan_queue) do
if vector.equals(converted, queued_pos) then
return;
end
end
cartographer.scan_queue[#cartographer.scan_queue + 1] = converted;
end
function cartographer.scan_regions()
local len = #cartographer.scan_queue;
if len == 0 then
return;
end
local startpos = cartographer.scan_queue[len];
local endpos = {
x = startpos.x + CHUNK_SIZE,
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;
end
local biome = get_biome(startpos, endpos);
if biome ~= nil then
register_mapchunk(startpos.x / CHUNK_SIZE, startpos.z / CHUNK_SIZE, biome)
end
cartographer.scan_queue[len] = nil;
end
minetest.register_on_generated(on_generated);

461
table.lua Normal file
View File

@ -0,0 +1,461 @@
local SIZE_SMALL = 20;
local SIZE_LARGE = 40;
local separator = [[
formspec_version[3]
box[0.1,%f;10.1,0.01;black]
]];
local function get_material_cost(size, detail)
local fiber = 0;
local pigment = 0;
if size == SIZE_SMALL then
fiber = fiber + 20;
pigment = pigment + 5;
elseif size == SIZE_LARGE then
fiber = fiber + 80;
pigment = pigment + 20;
end
pigment = pigment + (detail * 5);
return {
fiber = math.max(fiber, 0),
pigment = math.max(pigment, 0),
};
end
local function get_full_material_cost(meta)
local cost = get_material_cost(meta:get_int("size") or SIZE_SMALL, meta:get_int("detail") or 0);
local stack = meta:get_inventory():get_stack("output", 1);
if stack:get_name() == "cartographer:map" then
local smeta = stack:get_meta();
local sub_cost = get_material_cost(smeta:get_int("cartographer:size") or SIZE_SMALL, (smeta:get_int("cartographer:detail") or 1) - 1);
cost.fiber = math.max(cost.fiber - sub_cost.fiber, 0);
cost.pigment = math.max(cost.pigment - sub_cost.pigment, 0);
end
return cost;
end
local fs = {};
function fs.header(w, h, rank, tab)
local data = [[
formspec_version[3]
size[%f,%f]
]];
data = data:format(w, h);
if rank < 2 then
data = data .. "tabheader[0,0;tabs;Materials,Create Map;%d;false;false]";
data = data:format(tab);
else
data = data .. "tabheader[0,0;tabs;Materials,Create Map,Copy Map;%d;false;false]";
data = data:format(tab);
end
return data;
end
function fs.materials(x, y, rank, meta)
local fiber = meta:get_int("fiber");
local pigment = meta:get_int("pigment");
local data = [[
container[%f,%f]
formspec_version[3]
label[0,0.25;Fiber x %d]
label[3,0.25;Pigment x %d]
]];
data = data:format(x, y, fiber, pigment);
if rank > 1 then
data = data .. "label[6,0.25;Stuff x %d]";
data = data:format(0);
if rank > 2 then
data = data .. "label[9,0.25;Things x %d]";
data = data:format(0);
end
end
return data .. "container_end[]";
end
function fs.cost(x, y, materials)
local data = "";
local i = 0;
for name,value in pairs(materials) do
data = data .. "label[" .. tostring(x) .. "," .. tostring(y + (i * 0.25)) .. ";" .. name .. " x " .. tostring(value) .. "]";
i = i + 1;
end
return data;
end
function fs.convert(x, y, pos)
local data = [[
container[%f,%f]
formspec_version[3]
list[nodemeta:%d,%d,%d;input;0,0;1,1;]
button[3.5,0.25;2,0.5;convert;Convert Materials]
]];
data = data:format(x, y, pos.x, pos.y, pos.z);
data = data .. fs.cost(1.25, 0.25, {
Fiber = 0,
Pigment = 0,
}) .. "container_end[]";
return data;
end
function fs.craft(x, y, pos, rank, meta)
local data = [[
container[%f, %f]
formspec_version[3]
list[nodemeta:%d,%d,%d;output;0,1;1,1;]
button[3.5,1.5;2,0.5;craft;Craft Map]
]] .. separator:format(0.75);
data = data:format(x, y, pos.x, pos.y, pos.z);
if rank > 2 then
local size = "s";
if meta:get_int("size") == SIZE_LARGE then
size = "l";
end
data = data .. [[
style[%s;bgcolor=blue]
button[0,0;0.5,0.5;s;S]
button[0.5,0;0.5,0.5;l;L]
]];
data = data:format(size);
end
local detail = tostring(meta:get_int("detail") + 1);
data = data .. [[
style[%s;bgcolor=blue]
button[1.25,0;0.5,0.5;1;1]
button[1.75,0;0.5,0.5;2;2]
]];
if rank > 1 then
data = data .. "button[2.25,0;0.5,0.5;3;3]";
if rank > 2 then
data = data .. "button[2.75,0;0.5,0.5;4;4]";
end
end
data = data:format(detail) .. fs.cost(3.5, 1, get_full_material_cost(meta)) .. "container_end[]";
return data;
end
function fs.copy(x, y, pos)
local data = [[
container[%f,%f]
formspec_version[3]
list[nodemeta:%d,%d,%d;copy_input;0,0;1,1;]
list[nodemeta:%d,%d,%d;copy_output;0,1.25;1,1;]
button[3.5,0.25;2,0.5;copy;Copy Map]
]];
data = data:format(x, y, pos.x, pos.y, pos.z, pos.x, pos.y, pos.z);
data = data .. fs.cost(1.25, 0.25, {
Fiber = 0,
Pigment = 0,
}) .. "container_end[]";
return data;
end
function fs.inv(x, y)
local data = [[
container[%f, %f]
formspec_version[3]
list[current_player;main;0,0;8,4;]
container_end[]
]];
return data:format(x, y)
end
local player_tables = {};
local function table_formspec(player, tab)
local pos = player_tables[player];
local meta = minetest.get_meta(pos);
local rank = 1;
local name = minetest.get_node(pos).name;
if name == "cartographer:standard_table" then
rank = 2;
elseif name == "cartographer:advanced_table" then
rank = 3;
end
if tab == 1 then
minetest.show_formspec(player, "simple_table",
fs.header(10.25, 6.75, rank, tab) ..
fs.materials(0.25, 0, rank, meta) ..
separator:format(0.4) ..
fs.convert(0.25, 0.5, pos) ..
fs.inv(0.25, 1.75)
);
elseif tab == 2 then
minetest.show_formspec(player, "simple_table",
fs.header(10.25, 8.0, rank, tab) ..
fs.materials(0.25, 0, rank, meta) ..
separator:format(0.4) ..
fs.craft(0.25, 0.5, pos, rank, meta) ..
fs.inv(0.25, 3)
);
elseif tab == 3 then
minetest.show_formspec(player, "simple_table",
fs.header(10.25, 8.0, rank, tab) ..
fs.materials(0.25, 0, rank, meta) ..
separator:format(0.4) ..
fs.copy(0.25, 0.5, pos) ..
fs.inv(0.25, 3)
);
end
end
minetest.register_on_player_receive_fields(function(player, name, fields)
if name == "simple_table" then
minetest.chat_send_all(name..": ");
for k,v in pairs(fields) do
minetest.chat_send_all(tostring(k).." - "..tostring(v));
end
local meta = minetest.get_meta(player_tables[player:get_player_name()]);
if fields["convert"] ~= nil then
local inv = meta:get_inventory();
local stack = inv:get_stack("input", 1);
local fiber = meta:get_int("fiber");
local pigment = meta:get_int("pigment");
local item_name = stack:get_name();
local item_count = stack:get_count();
local found_match = false;
for name,mats in pairs(_cartographer.materials_by_name) do
if name == item_name then
fiber = fiber + ((mats.fiber or 0) * item_count);
pigment = pigment + ((mats.pigment or 0) * item_count);
found_match = true;
break;
end
end
if not found_match then
for group,mats in pairs(_cartographer.materials_by_group) do
if minetest.get_item_group(item_name, group) ~= 0 then
fiber = fiber + ((mats.fiber or 0) * item_count);
pigment = pigment + ((mats.pigment or 0) * item_count);
found_match = true;
break;
end
end
end
if found_match then
inv:set_stack("input", 1, ItemStack());
end
meta:set_int("fiber", fiber);
meta:set_int("pigment", pigment);
table_formspec(player:get_player_name(), 1)
elseif fields["craft"] ~= nil then
local size = meta:get_int("size");
local detail = meta:get_int("detail");
local fiber = meta:get_int("fiber");
local pigment = meta:get_int("pigment");
local inv = meta:get_inventory();
local stack = inv:get_stack("output", 1);
local cost = get_full_material_cost(meta);
if stack:is_empty() then
if fiber >= cost.fiber and pigment >= cost.pigment then
fiber = fiber - cost.fiber;
pigment = pigment - cost.pigment;
meta:set_int("fiber", fiber);
meta:set_int("pigment", pigment);
inv:set_stack("output", 1, cartographer.create_map_item(size, 1 + detail));
end
else
local smeta = stack:get_meta();
local old_size = smeta:get_int("cartographer:size");
local old_detail = smeta:get_int("cartographer:detail") - 1;
if old_detail <= detail and old_size <= size and not (old_detail == detail and old_size == size) and fiber >= cost.fiber and pigment >= cost.pigment then
fiber = fiber - cost.fiber;
pigment = pigment - cost.pigment;
meta:set_int("fiber", fiber);
meta:set_int("pigment", pigment);
smeta:set_int("cartographer:detail", 1 + detail);
cartographer.resize_map_item(smeta, size);
local map = cartographer.get_map(smeta:get_int("cartographer:map_id"));
if map ~= nil then
map.detail = 1 + detail;
end
inv:set_stack("output", 1, stack);
end
end
table_formspec(player:get_player_name(), 2)
elseif fields["copy"] ~= nil then
local fiber = meta:get_int("fiber");
local pigment = meta:get_int("pigment");
local inv = meta:get_inventory();
local in_stack = inv:get_stack("copy_input", 1);
local out_stack = inv:get_stack("copy_output", 1);
if out_stack:is_empty() and in_stack:get_name() == "cartographer:map" then
local smeta = in_stack:get_meta();
local size = smeta:get_int("cartographer:size") or SIZE_SMALL;
local detail = smeta:get_int("cartographer:detail") or 1;
local cost = get_material_cost(size, detail - 1);
if fiber >= cost.fiber and pigment >= cost.pigment then
fiber = fiber - cost.fiber;
pigment = pigment - cost.pigment;
meta:set_int("fiber", fiber);
meta:set_int("pigment", pigment);
inv:set_stack("copy_output", 1, cartographer.copy_map_item(in_stack));
end
end
table_formspec(player:get_player_name(), 3)
elseif fields["s"] ~= nil then
meta:set_int("size", SIZE_SMALL);
table_formspec(player:get_player_name(), 2)
elseif fields["l"] ~= nil then
meta:set_int("size", SIZE_LARGE);
table_formspec(player:get_player_name(), 2)
elseif fields["1"] ~= nil then
meta:set_int("detail", 0);
table_formspec(player:get_player_name(), 2)
elseif fields["2"] ~= nil then
meta:set_int("detail", 1);
table_formspec(player:get_player_name(), 2)
elseif fields["3"] ~= nil then
meta:set_int("detail", 2);
table_formspec(player:get_player_name(), 2)
elseif fields["4"] ~= nil then
meta:set_int("detail", 3);
table_formspec(player:get_player_name(), 2)
elseif fields["tabs"] ~= nil then
table_formspec(player:get_player_name(), tonumber(fields["tabs"]));
end
end
end);
minetest.register_node("cartographer:simple_table", {
description = "Shabby Cartographer's Table",
drawtype = "mesh",
mesh = "cartographer_simple_table.obj",
tiles = { "cartographer_simple_table.png" },
paramtype2 = "facedir",
groups = {
choppy = 2,
oddly_breakable_by_hand = 2,
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);
table_formspec(player:get_player_name(), 1)
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
meta:get_inventory():set_size("input", 1);
meta:get_inventory():set_size("output", 1);
meta:set_int("size", SIZE_SMALL);
meta:set_int("detail", 0);
return res;
end,
});
minetest.register_node("cartographer:standard_table", {
groups = {
choppy = 2,
oddly_breakable_by_hand = 2,
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);
table_formspec(player:get_player_name(), 1)
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
meta:get_inventory():set_size("input", 1);
meta:get_inventory():set_size("output", 1);
meta:get_inventory():set_size("copy_input", 1);
meta:get_inventory():set_size("copy_output", 1);
meta:set_int("size", SIZE_SMALL);
meta:set_int("detail", 0);
return res;
end,
});
minetest.register_node("cartographer:advanced_table", {
groups = {
choppy = 2,
oddly_breakable_by_hand = 2,
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
player_tables[player:get_player_name()] = minetest.get_pointed_thing_position(pointed_thing);
table_formspec(player:get_player_name(), 1)
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos);
meta:get_inventory():set_size("input", 1);
meta:get_inventory():set_size("output", 1);
meta:get_inventory():set_size("copy_input", 1);
meta:get_inventory():set_size("copy_output", 1);
meta:set_int("size", SIZE_SMALL);
meta:set_int("detail", 0);
return res;
end,
});
function cartographer.register_map_material_name(name, material, value)
if _cartographer.materials_by_name[name] == nil then
_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
_cartographer.materials_by_group[name] = {
[material] = value or 1,
};
else
_cartographer.materials_by_group[name][material] = value;
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1002 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B