aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/testnodes/overlays.lua
blob: 294e06a1653ea106ef73043278b7db6c6a8546f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local S = minetest.get_translator("testnodes")

minetest.register_node("testnodes:overlay", {
	description = S("Texture Overlay Test Node") .. "\n" ..
		S("Uncolorized"),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_color_all", {
	description = S("Texture Overlay Test Node, Colorized") .. "\n" ..
		S("param2 changes color"),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_color_overlay", {
	description = S("Texture Overlay Test Node, Colorized Overlay") .. "\n" ..
		S("param2 changes color of overlay"),
	tiles = {{name = "testnodes_overlayable.png", color="white"}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_color_overlayed", {
	description = S("Texture Overlay Test Node, Colorized Base") .. "\n" ..
		S("param2 changes color of base texture"),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png", color="white"}},
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})

local global_overlay_color = "#FF2000"
minetest.register_node("testnodes:overlay_global", {
	description = S("Texture Overlay Test Node, Global Color") .. "\n" ..
		S("Global color = @1", global_overlay_color),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	color = global_overlay_color,


	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_global_color_all", {
	description = S("Texture Overlay Test Node, Global Color + Colorized") .. "\n" ..
		S("Global color = @1", global_overlay_color) .. "\n" ..
		S("param2 changes color"),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	color = global_overlay_color,
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_global_color_overlay", {
	description = S("Texture Overlay Test Node, Global Color + Colorized Overlay") .. "\n" ..
		S("Global color = @1", global_overlay_color) .. "\n" ..
		S("param2 changes color of overlay"),
	tiles = {{name = "testnodes_overlayable.png", color=global_overlay_color}},
	overlay_tiles = {{name = "testnodes_overlay.png"}},
	color = global_overlay_color,
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})
minetest.register_node("testnodes:overlay_global_color_overlayed", {
	description = S("Texture Overlay Test Node, Global Color + Colorized Base") .. "\n" ..
		S("Global color = @1", global_overlay_color) .. "\n" ..
		S("param2 changes color of base texture"),
	tiles = {{name = "testnodes_overlayable.png"}},
	overlay_tiles = {{name = "testnodes_overlay.png", color=global_overlay_color}},
	color = global_overlay_color,
	paramtype2 = "color",
	palette = "testnodes_palette_full.png",


	groups = { dig_immediate = 2 },
})
d">UASSERT(getIdFromNrBacklog(&test_content1, "", CONTENT_IGNORE) == true); UASSERT(getIdFromNrBacklog(&test_content2, "", CONTENT_IGNORE) == false); } void TestNodeResolver::testNodeResolving(IWritableNodeDefManager *ndef) { Foobar foobar; size_t i; foobar.m_nodenames.push_back("default:torch"); foobar.m_nodenames.push_back("default:dirt_with_grass"); foobar.m_nodenames.push_back("default:water"); foobar.m_nodenames.push_back("default:abloobloobloo"); foobar.m_nodenames.push_back("default:stone"); foobar.m_nodenames.push_back("default:shmegoldorf"); foobar.m_nnlistsizes.push_back(5); foobar.m_nodenames.push_back("group:liquids"); foobar.m_nnlistsizes.push_back(1); foobar.m_nodenames.push_back("default:warf"); foobar.m_nodenames.push_back("default:stone"); foobar.m_nodenames.push_back("default:bloop"); foobar.m_nnlistsizes.push_back(3); foobar.m_nnlistsizes.push_back(0); foobar.m_nodenames.push_back("default:brick"); foobar.m_nodenames.push_back("default:desert_stone"); foobar.m_nodenames.push_back("default:shnitzle"); ndef->pendNodeResolve(&foobar); UASSERT(foobar.m_ndef == ndef); ndef->setNodeRegistrationStatus(true); ndef->runNodeResolveCallbacks(); // Check that we read single nodes successfully UASSERTEQ(content_t, foobar.test_nr_node1, t_CONTENT_TORCH); UASSERTEQ(content_t, foobar.test_nr_node2, t_CONTENT_BRICK); UASSERTEQ(content_t, foobar.test_nr_node3, t_CONTENT_BRICK); UASSERTEQ(content_t, foobar.test_nr_node4, CONTENT_AIR); UASSERTEQ(content_t, foobar.test_nr_node5, CONTENT_IGNORE); // Check that we read all the regular list items static const content_t expected_test_nr_list[] = { t_CONTENT_GRASS, t_CONTENT_WATER, t_CONTENT_STONE, }; UASSERTEQ(size_t, foobar.test_nr_list.size(), 3); for (i = 0; i != foobar.test_nr_list.size(); i++) UASSERTEQ(content_t, foobar.test_nr_list[i], expected_test_nr_list[i]); // Check that we read all the list items that were from a group entry static const content_t expected_test_nr_list_group[] = { t_CONTENT_WATER, t_CONTENT_LAVA, }; UASSERTEQ(size_t, foobar.test_nr_list_group.size(), 2); for (i = 0; i != foobar.test_nr_list_group.size(); i++) { UASSERT(CONTAINS(foobar.test_nr_list_group, expected_test_nr_list_group[i])); } // Check that we read all the items we're able to in a required list static const content_t expected_test_nr_list_required[] = { CONTENT_AIR, t_CONTENT_STONE, CONTENT_AIR, }; UASSERTEQ(size_t, foobar.test_nr_list_required.size(), 3); for (i = 0; i != foobar.test_nr_list_required.size(); i++) UASSERTEQ(content_t, foobar.test_nr_list_required[i], expected_test_nr_list_required[i]); // Check that the edge case of 0 is successful UASSERTEQ(size_t, foobar.test_nr_list_empty.size(), 0); } void TestNodeResolver::testPendingResolveCancellation(IWritableNodeDefManager *ndef) { Foobaz foobaz1; foobaz1.test_content1 = 1234; foobaz1.test_content2 = 5678; foobaz1.m_nodenames.push_back("default:dirt_with_grass"); foobaz1.m_nodenames.push_back("default:abloobloobloo"); ndef->pendNodeResolve(&foobaz1); Foobaz foobaz2; foobaz2.test_content1 = 1234; foobaz2.test_content2 = 5678; foobaz2.m_nodenames.push_back("default:dirt_with_grass"); foobaz2.m_nodenames.push_back("default:abloobloobloo"); ndef->pendNodeResolve(&foobaz2); ndef->cancelNodeResolveCallback(&foobaz1); ndef->setNodeRegistrationStatus(true); ndef->runNodeResolveCallbacks(); UASSERT(foobaz1.test_content1 == 1234); UASSERT(foobaz1.test_content2 == 5678); UASSERT(foobaz2.test_content1 == t_CONTENT_GRASS); UASSERT(foobaz2.test_content2 == CONTENT_IGNORE); }