Split off game support and turn into a pure API mod
- Add API table for skinning
6
init.lua
@ -53,13 +53,9 @@ local modpath = minetest.get_modpath("cartographer");
|
|||||||
-- Includes
|
-- Includes
|
||||||
dofile(modpath .. "/commands.lua");
|
dofile(modpath .. "/commands.lua");
|
||||||
dofile(modpath .. "/scanner.lua");
|
dofile(modpath .. "/scanner.lua");
|
||||||
|
dofile(modpath .. "/skin_api.lua");
|
||||||
dofile(modpath .. "/map_api.lua");
|
dofile(modpath .. "/map_api.lua");
|
||||||
dofile(modpath .. "/map_formspec.lua");
|
dofile(modpath .. "/map_formspec.lua");
|
||||||
dofile(modpath .. "/marker_formspec.lua");
|
dofile(modpath .. "/marker_formspec.lua");
|
||||||
dofile(modpath .. "/items.lua");
|
dofile(modpath .. "/items.lua");
|
||||||
dofile(modpath .. "/table.lua");
|
dofile(modpath .. "/table.lua");
|
||||||
|
|
||||||
-- Setup mod/game support
|
|
||||||
if minetest.get_modpath("default") then
|
|
||||||
dofile(modpath .. "/repixture.lua");
|
|
||||||
end
|
|
||||||
|
@ -15,6 +15,11 @@ local map_formspec_prefix = [[
|
|||||||
local tile = "image[%f,%f;%f,%f;%s]";
|
local tile = "image[%f,%f;%f,%f;%s]";
|
||||||
local marker = "animated_image[%f,%f;%f,%f;;%s;%d;%d]";
|
local marker = "animated_image[%f,%f;%f,%f;;%s;%d;%d]";
|
||||||
|
|
||||||
|
-- Generate formspec markup for an unknown biome tile
|
||||||
|
local function unknown_biome_tile(x, y, scale, variant)
|
||||||
|
return tile:format(x, y, scale, scale, cartographer.skin.unknown_biome_texture .. "." .. tostring(variant) .. ".png");
|
||||||
|
end
|
||||||
|
|
||||||
local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_scale, is_visible, get_marker, user)
|
local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_scale, is_visible, get_marker, user)
|
||||||
local str = "";
|
local str = "";
|
||||||
local random = PcgRandom(x + y + w + h); -- TODO: Better seed
|
local random = PcgRandom(x + y + w + h); -- TODO: Better seed
|
||||||
@ -24,7 +29,7 @@ local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_sc
|
|||||||
for j = y + h,y,-1 do
|
for j = y + h,y,-1 do
|
||||||
local fy = (y + h - j) * (scale - 0.01);
|
local fy = (y + h - j) * (scale - 0.01);
|
||||||
if column == nil or column[j * map_scale] == nil or (is_visible and not is_visible(user, i, j)) then
|
if column == nil or column[j * map_scale] == 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")
|
str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random));
|
||||||
else
|
else
|
||||||
local name = minetest.get_biome_name(column[j * map_scale].biome);
|
local name = minetest.get_biome_name(column[j * map_scale].biome);
|
||||||
local height = column[j * map_scale].height;
|
local height = column[j * map_scale].height;
|
||||||
@ -40,11 +45,12 @@ local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_sc
|
|||||||
end
|
end
|
||||||
|
|
||||||
if biome == nil then
|
if biome == nil then
|
||||||
-- minetest.chat_send_all(name);
|
str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random));
|
||||||
str = str..tile:format(fx, fy, scale, scale, "cartographer_unknown_biome." .. tostring(get_variant(random)) .. ".png")
|
|
||||||
else
|
else
|
||||||
if height > 0 then
|
if height > 0 then
|
||||||
str = str..tile:format(fx, fy - (height * 0.05) + scale - 0.01, scale, (height * 0.05) + 0.01, "cartographer_cliff.png")
|
str = str..tile:format(fx, fy - (height * 0.05) + scale - 0.01,
|
||||||
|
scale, (height * 0.05) + 0.01,
|
||||||
|
cartographer.skin.cliff_texture .. ".png");
|
||||||
end
|
end
|
||||||
|
|
||||||
str = str..tile:format(fx, fy - (height * 0.05), scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod)
|
str = str..tile:format(fx, fy - (height * 0.05), scale, scale, biome .. "." .. tostring(get_variant(random)) .. ".png" .. mod)
|
||||||
@ -58,7 +64,11 @@ local function generate_map(data, x, y, w, h, player_x, player_y, detail, map_sc
|
|||||||
end
|
end
|
||||||
|
|
||||||
if i == player_x and j == player_y then
|
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)
|
str = str..marker:format(fx, fy - (height * 0.05),
|
||||||
|
scale, scale,
|
||||||
|
cartographer.skin.player_icon.texture .. ".png",
|
||||||
|
cartographer.skin.player_icon.frame_count,
|
||||||
|
cartographer.skin.player_icon.frame_duration);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
3
mod.conf
@ -1,3 +1,2 @@
|
|||||||
name = cartographer
|
name = cartographer
|
||||||
description = Adds an unlockable world map
|
description = A game-agnostic mapmaking API. Needs additional mods to function.
|
||||||
optional_depends = crafting
|
|
||||||
|
112
repixture.lua
@ -1,112 +0,0 @@
|
|||||||
-- 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",
|
|
||||||
}, 1);
|
|
||||||
cartographer.register_biome("Wasteland", {
|
|
||||||
"cartographer_simple_water",
|
|
||||||
"cartographer_colored_water",
|
|
||||||
}, nil, 0);
|
|
||||||
cartographer.register_biome("Grassland Ocean", {
|
|
||||||
"cartographer_simple_water",
|
|
||||||
"cartographer_colored_water",
|
|
||||||
}, nil, 0);
|
|
||||||
cartographer.register_biome("Grassland Ocean", {
|
|
||||||
"cartographer_simple_land",
|
|
||||||
"cartographer_colored_sand",
|
|
||||||
}, 1);
|
|
||||||
cartographer.register_biome("Gravel Beach", {
|
|
||||||
"cartographer_simple_water",
|
|
||||||
"cartographer_colored_water",
|
|
||||||
}, nil, 0);
|
|
||||||
cartographer.register_biome("Gravel Beach", {
|
|
||||||
"cartographer_simple_land",
|
|
||||||
"cartographer_colored_sand",
|
|
||||||
"cartographer_gravel",
|
|
||||||
}, 1);
|
|
||||||
cartographer.register_biome("Savanna Ocean", {
|
|
||||||
"cartographer_simple_water",
|
|
||||||
"cartographer_colored_water",
|
|
||||||
}, nil, 0);
|
|
||||||
cartographer.register_biome("Savanna Ocean", {
|
|
||||||
"cartographer_simple_land",
|
|
||||||
"cartographer_colored_sand",
|
|
||||||
}, 1);
|
|
||||||
|
|
||||||
-- Materials
|
|
||||||
cartographer.register_map_material_name("default:paper", "paper", 1);
|
|
||||||
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",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
crafting.register_craft({
|
|
||||||
output = "cartographer:standard_table",
|
|
||||||
items = {
|
|
||||||
"cartographer:simple_table",
|
|
||||||
"default:ingot_steel 6",
|
|
||||||
},
|
|
||||||
});
|
|
15
skin_api.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
-- Table used for skinning cartographer's look and feel
|
||||||
|
cartographer.skin = {
|
||||||
|
-- The texture to use in maps for the sides of tiles
|
||||||
|
cliff_texture = "cartographer_cliff",
|
||||||
|
|
||||||
|
-- The animated texture data to use for the player icon
|
||||||
|
player_icon = {
|
||||||
|
frame_count = 2,
|
||||||
|
frame_duration = 500,
|
||||||
|
texture = "cartographer_player_icon",
|
||||||
|
},
|
||||||
|
|
||||||
|
-- The texture to use in maps when biome data is missing or empty
|
||||||
|
unknown_biome_texture = "cartographer_unknown_biome",
|
||||||
|
};
|
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 989 B |
Before Width: | Height: | Size: 998 B |
Before Width: | Height: | Size: 982 B |
Before Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 986 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 974 B |
Before Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 976 B |
Before Width: | Height: | Size: 963 B |
Before Width: | Height: | Size: 963 B |
Before Width: | Height: | Size: 989 B |
Before Width: | Height: | Size: 986 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1016 B |
Before Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 976 B |
Before Width: | Height: | Size: 1009 B |
Before Width: | Height: | Size: 1011 B |
Before Width: | Height: | Size: 1009 B |
Before Width: | Height: | Size: 1016 B |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 974 B |
Before Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 1002 B |
Before Width: | Height: | Size: 1021 B |
Before Width: | Height: | Size: 987 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 973 B |
Before Width: | Height: | Size: 981 B |
Before Width: | Height: | Size: 977 B |
Before Width: | Height: | Size: 963 B |
Before Width: | Height: | Size: 963 B |
Before Width: | Height: | Size: 980 B |
Before Width: | Height: | Size: 979 B |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 974 B |
Before Width: | Height: | Size: 983 B |
Before Width: | Height: | Size: 984 B |
Before Width: | Height: | Size: 961 B |
Before Width: | Height: | Size: 994 B |
Before Width: | Height: | Size: 990 B |
Before Width: | Height: | Size: 976 B |