Split off game support and turn into a pure API mod

- Add API table for skinning
This commit is contained in:
Hugues Ross 2020-03-29 14:12:10 -04:00
parent ade84c374d
commit 38d24aba7d
65 changed files with 32 additions and 124 deletions

View File

@ -53,13 +53,9 @@ local modpath = minetest.get_modpath("cartographer");
-- Includes
dofile(modpath .. "/commands.lua");
dofile(modpath .. "/scanner.lua");
dofile(modpath .. "/skin_api.lua");
dofile(modpath .. "/map_api.lua");
dofile(modpath .. "/map_formspec.lua");
dofile(modpath .. "/marker_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

View File

@ -15,6 +15,11 @@ local map_formspec_prefix = [[
local tile = "image[%f,%f;%f,%f;%s]";
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 str = "";
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
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
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
local name = minetest.get_biome_name(column[j * map_scale].biome);
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
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")
str = str .. unknown_biome_tile(fx, fy, scale, get_variant(random));
else
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
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
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

View File

@ -1,3 +1,2 @@
name = cartographer
description = Adds an unlockable world map
optional_depends = crafting
description = A game-agnostic mapmaking API. Needs additional mods to function.

View File

@ -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
View 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",
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1002 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 973 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 980 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 979 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 983 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 B