aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_nodemeta.cpp
blob: 57052cb42b587a14d22556afe93773eb6fa8c75b (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "lua_api/l_nodemeta.h"
#include "lua_api/l_internal.h"
#include "lua_api/l_inventory.h"
#include "common/c_content.h"
#include "serverenvironment.h"
#include "map.h"
#include "mapblock.h"
#include "server.h"

/*
	NodeMetaRef
*/
NodeMetaRef* NodeMetaRef::checkobject(lua_State *L, int narg)
{
	luaL_checktype(L, narg, LUA_TUSERDATA);
	void *ud = luaL_checkudata(L, narg, className);
	if(!ud) luaL_typerror(L, narg, className);
	return *(NodeMetaRef**)ud;  // unbox pointer
}

Metadata* NodeMetaRef::getmeta(bool auto_create)
{
	if (m_is_local)
		return m_meta;

	NodeMetadata *meta = m_env->getMap().getNodeMetadata(m_p);
	if (meta == NULL && auto_create) {
		meta = new NodeMetadata(m_env->getGameDef()->idef());
		if (!m_env->getMap().setNodeMetadata(m_p, meta)) {
			delete meta;
			return NULL;
		}
	}
	return meta;
}

void NodeMetaRef::clearMeta()
{
	SANITY_CHECK(!m_is_local);
	m_env->getMap().removeNodeMetadata(m_p);
}

void NodeMetaRef::reportMetadataChange(const std::string *name)
{
	SANITY_CHECK(!m_is_local);
	// NOTE: This same code is in rollback_interface.cpp
	// Inform other things that the metadata has changed
	NodeMetadata *meta = dynamic_cast<NodeMetadata*>(m_meta);

	MapEditEvent event;
	event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
	event.p = m_p;
	event.is_private_change = name && meta && meta->isPrivate(*name);
	m_env->getMap().dispatchEvent(event);
}

// Exported functions

// garbage collector
int NodeMetaRef::gc_object(lua_State *L) {
	NodeMetaRef *o = *(NodeMetaRef **)(lua_touserdata(L, 1));
	delete o;
	return 0;
}

// get_inventory(self)
int NodeMetaRef::l_get_inventory(lua_State *L)
{
	MAP_LOCK_REQUIRED;

	NodeMetaRef *ref = checkobject(L, 1);
	ref->getmeta(true);  // try to ensure the metadata exists
	InvRef::createNodeMeta(L, ref->m_p);
	return 1;
}

// mark_as_private(self, <string> or {<string>, <string>, ...})
int NodeMetaRef::l_mark_as_private(lua_State *L)
{
	MAP_LOCK_REQUIRED;

	NodeMetaRef *ref = checkobject(L, 1);
	NodeMetadata *meta = dynamic_cast<NodeMetadata*>(ref->getmeta(true));
	assert(meta);

	if (lua_istable(L, 2)) {
		lua_pushnil(L);
		while (lua_next(L, 2) != 0) {
			// key at index -2 and value at index -1
			luaL_checktype(L, -1, LUA_TSTRING);
			meta->markPrivate(readParam<std::string>(L, -1), true);
			// removes value, keeps key for next iteration
			lua_pop(L, 1);
		}
	} else if (lua_isstring(L, 2)) {
		meta->markPrivate(readParam<std::string>(L, 2), true);
	}
	ref->reportMetadataChange();

	return 0;
}

void NodeMetaRef::handleToTable(lua_State *L, Metadata *_meta)
{
	// fields
	MetaDataRef::handleToTable(L, _meta);

	NodeMetadata *meta = (NodeMetadata*) _meta;

	// inventory
	lua_newtable(L);
	Inventory *inv = meta->getInventory();
	if (inv) {
		std::vector<const InventoryList *> lists = inv->getLists();
		for(std::vector<const InventoryList *>::const_iterator
				i = lists.begin(); i != lists.end(); ++i) {
			push_inventory_list(L, inv, (*i)->getName().c_str());
			lua_setfield(L, -2, (*i)->getName().c_str());
		}
	}
	lua_setfield(L, -2, "inventory");
}

// from_table(self, table)
bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
{
	// fields
	if (!MetaDataRef::handleFromTable(L, table, _meta))
		return false;

	NodeMetadata *meta = (NodeMetadata*) _meta;

	// inventory
	Inventory *inv = meta->getInventory();
	lua_getfield(L, table, "inventory");
	if (lua_istable(L, -1)) {
		int inventorytable = lua_gettop(L);
		lua_pushnil(L);
		while (lua_next(L, inventorytable) != 0) {
			// key at index -2 and value at index -1
			std::string name = luaL_checkstring(L, -2);
			read_inventory_list(L, -1, inv, name.c_str(), getServer(L));
			lua_pop(L, 1); // Remove value, keep key for next iteration
		}
		lua_pop(L, 1);
	}

	return true;
}


NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
	m_p(p),
	m_env(env)
{
}

NodeMetaRef::NodeMetaRef(Metadata *meta):
	m_meta(meta),
	m_is_local(true)
{
}

// Creates an NodeMetaRef and leaves it on top of stack
// Not callable from Lua; all references are created on the C side.
void NodeMetaRef::create(lua_State *L, v3s16 p, ServerEnvironment *env)
{
	NodeMetaRef *o = new NodeMetaRef(p, env);
	//infostream<<"NodeMetaRef::create: o="<<o<<std::endl;
	*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
	luaL_getmetatable(L, className);
	lua_setmetatable(L, -2);
}

// Client-sided version of the above
void NodeMetaRef::createClient(lua_State *L, Metadata *meta)
{
	NodeMetaRef *o = new NodeMetaRef(meta);
	*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
	luaL_getmetatable(L, className);
	lua_setmetatable(L, -2);
}

const char NodeMetaRef::className[] = "NodeMetaRef";
void NodeMetaRef::RegisterCommon(lua_State *L)
{
	lua_newtable(L);
	int methodtable = lua_gettop(L);
	luaL_newmetatable(L, className);
	int metatable = lua_gettop(L);

	lua_pushliteral(L, "__metatable");
	lua_pushvalue(L, methodtable);
	lua_settable(L, metatable);  // hide metatable from Lua getmetatable()

	lua_pushliteral(L, "metadata_class");
	lua_pushlstring(L, className, strlen(className));
	lua_settable(L, metatable);

	lua_pushliteral(L, "__index");
	lua_pushvalue(L, methodtable);
	lua_settable(L, metatable);

	lua_pushliteral(L, "__gc");
	lua_pushcfunction(L, gc_object);
	lua_settable(L, metatable);

	lua_pushliteral(L, "__eq");
	lua_pushcfunction(L, l_equals);
	lua_settable(L, metatable);

	lua_pop(L, 1);  // drop metatable
}

void NodeMetaRef::Register(lua_State *L)
{
	RegisterCommon(L);
	luaL_openlib(L, 0, methodsServer, 0);  // fill methodtable
	lua_pop(L, 1);  // drop methodtable
}


const luaL_Reg NodeMetaRef::methodsServer[] = {
	luamethod(MetaDataRef, contains),
	luamethod(MetaDataRef, get),
	luamethod(MetaDataRef, get_string),
	luamethod(MetaDataRef, set_string),
	luamethod(MetaDataRef, get_int),
	luamethod(MetaDataRef, set_int),
	luamethod(MetaDataRef, get_float),
	luamethod(MetaDataRef, set_float),
	luamethod(MetaDataRef, to_table),
	luamethod(MetaDataRef, from_table),
	luamethod(NodeMetaRef, get_inventory),
	luamethod(NodeMetaRef, mark_as_private),
	luamethod(MetaDataRef, equals),
	{0,0}
};


void NodeMetaRef::RegisterClient(lua_State *L)
{
	RegisterCommon(L);
	luaL_openlib(L, 0, methodsClient, 0);  // fill methodtable
	lua_pop(L, 1);  // drop methodtable
}


const luaL_Reg NodeMetaRef::methodsClient[] = {
	luamethod(MetaDataRef, contains),
	luamethod(MetaDataRef, get),
	luamethod(MetaDataRef, get_string),
	luamethod(MetaDataRef, get_int),
	luamethod(MetaDataRef, get_float),
	luamethod(MetaDataRef, to_table),
	{0,0}
};
, -0.25, 0.5, 0.333, 0.5}, {-0.5, 0.333, 0, 0.5, 0.417, 0.5}, {-0.5, 0.417, 0.25, 0.5, 0.5 , 0.5}, } } local minimal_slopes_defs = { [""] = { mesh = "moreblocks_slope.obj", collision_box = box_slope, selection_box = box_slope, }, ["_half"] = { mesh = "moreblocks_slope_half.obj", collision_box = box_slope_half, selection_box = box_slope_half, }, ["_half_raised"] = { mesh = "moreblocks_slope_half_raised.obj", collision_box = box_slope_half_raised, selection_box = box_slope_half_raised, }, } local function copytable(orig) local orig_type = type(orig) local copy if orig_type == 'table' then copy = {} for orig_key, orig_value in next, orig, nil do copy[copytable(orig_key)] = copytable(orig_value) end setmetatable(copy, copytable(getmetatable(orig))) else copy = orig end return copy end local function register_minimal_shapes(modname, subname, recipeitem, fields) local defs = copytable(minimal_slopes_defs) local desc = S("%s Slope"):format(fields.description) for alternate, def in pairs(defs) do for k, v in pairs(fields) do def[k] = v end def.drawtype = "mesh" def.paramtype = "light" def.paramtype2 = def.paramtype2 or "facedir" def.on_place = minetest.rotate_node def.description = desc def.use_texture_alpha = fields.use_texture_alpha def.groups = def.groups -- stairsplus:prepare_groups(fields.groups) if fields.drop and not (type(fields.drop) == "table") then def.drop = modname.. ":slope_" ..fields.drop..alternate end minetest.register_node(":" ..modname.. ":slope_" ..subname..alternate, def) end minetest.register_craft({ recipe = { { "","","" }, { "","",recipeitem, }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname }) minetest.register_craft({ recipe = { { "","","" }, { "","","", }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname .. "_half 12" }) minetest.register_craft({ recipe = { { "","",recipeitem, }, { "","","" }, { "", recipeitem, recipeitem }, }, output = modname .. ":slope_" .. subname .. "_half_raised 4" }) minetest.register_craft({ type = "shapeless", output = recipeitem, recipe = {modname .. ":slope_" .. subname, modname .. ":slope_" .. subname}, }) minetest.register_craft({ type = "shapeless", output = recipeitem, recipe = {modname .. ":slope_" .. subname .. "_half", modname .. ":slope_" .. subname .. "_half_raised"}, }) -- 100% slope 1 node -- 50% slope 2 nodes -- 50% slab 1 node end local nodes = { ["wood_tile"] = { description = S("Wooden Tile"), groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90"}, sounds = sound_wood, }, ["wood_tile_flipped"] = { description = S("Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR90", "default_wood.png^moreblocks_wood_tile.png^[transformR180", "default_wood.png^moreblocks_wood_tile.png^[transformR180"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_center"] = { description = S("Centered Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile_center.png"}, sounds = sound_wood, }, ["wood_tile_full"] = { description = S("Full Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = tile_tiles("wood_tile_full"), sounds = sound_wood, }, ["wood_tile_up"] = { description = S("Upwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^moreblocks_wood_tile_up.png"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_down"] = { description = S("Downwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR180^moreblocks_wood_tile_up.png^[transformR180"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_left"] = { description = S("Leftwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR270^moreblocks_wood_tile_up.png^[transformR270"}, sounds = sound_wood, no_stairs = true, }, ["wood_tile_right"] = { description = S("Rightwards Wooden Tile"), groups = {wood = 1, snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3}, tiles = {"default_wood.png^[transformR90^moreblocks_wood_tile_up.png^[transformR90"}, sounds = sound_wood, no_stairs = true, }, ["circle_stone_bricks"] = { description = S("Circle Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["grey_bricks"] = { description = S("Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["coal_stone_bricks"] = { description = S("Coal Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["iron_stone_bricks"] = { description = S("Iron Stone Bricks"), groups = {cracky = 3}, sounds = sound_stone, }, ["stone_tile"] = { description = S("Stone Tile"), groups = {cracky = 3}, sounds = sound_stone, }, ["split_stone_tile"] = { description = S("Split Stone Tile"), tiles = {"moreblocks_split_stone_tile_top.png", "moreblocks_split_stone_tile.png"}, groups = {cracky = 3}, sounds = sound_stone, }, ["split_stone_tile_alt"] = { description = S("Checkered Stone Tile"), groups = {cracky = 3}, sounds = sound_stone, }, ["tar"] = { description = S("Tar"), groups = {cracky = 2, tar_block = 1}, sounds = sound_stone, }, ["dirt_compressed"] = { description = S("Compressed Dirt"), groups = {crumbly=2}, is_ground_content = false, sounds = sound_dirt, }, ["cobble_compressed"] = { description = S("Compressed Cobblestone"), groups = {cracky = 1}, sounds = sound_stone, }, ["cobble_condensed"] = { description = "Condensed Cobblestone", tiles = {"moreblocks_cobble_compressed.png^[colorize:black:255]"}, is_ground_content = false, groups = {cracky = 1, stone = 2}, stack_max = 999, sounds = default.node_sound_stone_defaults(), }, ["plankstone"] = { description = S("Plankstone"), groups = {cracky = 3}, tiles = tile_tiles("plankstone"), sounds = sound_stone, }, ["iron_glass"] = { description = S("Iron Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_iron_glass.png", "moreblocks_iron_glass_detail.png"}, --tiles = {"moreblocks_iron_glass.png"}, one_texture = true, paramtype = "light", sunlight_propagates = true, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["coal_glass"] = { description = S("Coal Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_coal_glass.png", "moreblocks_coal_glass_detail.png"}, --tiles = {"moreblocks_coal_glass.png"}, one_texture = true, paramtype = "light", sunlight_propagates = true, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["clean_glass"] = { description = S("Clean Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_clean_glass.png", "moreblocks_clean_glass_detail.png"}, -- tiles = {"moreblocks_clean_glass.png"}, one_texture = true, paramtype = "light", sunlight_propagates = true, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["cactus_brick"] = { description = S("Cactus Brick"), groups = {cracky = 3}, sounds = sound_stone, }, ["cactus_checker"] = { description = S("Cactus Checker"), groups = {cracky = 3}, tiles = {"default_stone.png^moreblocks_cactus_checker.png", "default_stone.png^moreblocks_cactus_checker.png", "default_stone.png^moreblocks_cactus_checker.png", "default_stone.png^moreblocks_cactus_checker.png", "default_stone.png^moreblocks_cactus_checker.png^[transformR90", "default_stone.png^moreblocks_cactus_checker.png^[transformR90"}, sounds = sound_stone, }, ["empty_bookshelf"] = { description = S("Empty Bookshelf"), tiles = {"default_wood.png", "default_wood.png", "moreblocks_empty_bookshelf.png"}, groups = {snappy = 2, choppy = 3, oddly_breakable_by_hand = 2, flammable = 3}, sounds = sound_wood, furnace_burntime = 15, no_stairs = true, }, ["coal_stone"] = { description = S("Coal Stone"), groups = {cracky = 3}, sounds = sound_stone, }, ["iron_stone"] = { description = S("Iron Stone"), groups = {cracky = 3}, sounds = sound_stone, }, ["coal_checker"] = { description = S("Coal Checker"), tiles = {"default_stone.png^moreblocks_coal_checker.png", "default_stone.png^moreblocks_coal_checker.png", "default_stone.png^moreblocks_coal_checker.png", "default_stone.png^moreblocks_coal_checker.png", "default_stone.png^moreblocks_coal_checker.png^[transformR90", "default_stone.png^moreblocks_coal_checker.png^[transformR90"}, groups = {cracky = 3}, sounds = sound_stone, }, ["iron_checker"] = { description = S("Iron Checker"), tiles = {"default_stone.png^moreblocks_iron_checker.png", "default_stone.png^moreblocks_iron_checker.png", "default_stone.png^moreblocks_iron_checker.png", "default_stone.png^moreblocks_iron_checker.png", "default_stone.png^moreblocks_iron_checker.png^[transformR90", "default_stone.png^moreblocks_iron_checker.png^[transformR90"}, groups = {cracky = 3}, sounds = sound_stone, }, ["trap_stone"] = { description = S("Trap Stone"), walkable = false, groups = {cracky = 3}, sounds = sound_stone, no_stairs = true, }, ["trap_desert_stone"] = { description = S("Trap Desert Stone"), drawtype = "glasslike_framed", tiles = {"default_desert_stone.png^moreblocks_trap_box.png"}, walkable = false, groups = {cracky = 3}, paramtype = "light", is_ground_content = false, sounds = sound_stone, no_stairs = true, }, ["trap_glass"] = { description = S("Trap Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_trap_glass.png", "default_glass_detail.png"}, --tiles = {"moreblocks_trap_glass.png"}, paramtype = "light", sunlight_propagates = true, walkable = false, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, no_stairs = true, }, ["trap_obsidian_glass"] = { description = S("Trap Obsidian Glass"), drawtype = "glasslike_framed_optional", tiles = {"default_obsidian_glass.png^moreblocks_trap_box_glass.png", "default_obsidian_glass_detail.png"}, paramtype = "light", sunlight_propagates = true, is_ground_content = false, walkable = false, groups = {cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, no_stairs = true, }, ["trap_obsidian"] = { description = S("Trap Obsidian"), drawtype = "glasslike_framed", tiles = {"default_obsidian.png^moreblocks_trap_box.png"}, walkable = false, groups = {cracky = 1, level = 2}, paramtype = "light", is_ground_content = false, sounds = sound_stone, no_stairs = true, }, ["trap_sandstone"] = { description = S("Trap Sandstone"), drawtype = "glasslike_framed", tiles = {"default_sandstone.png^moreblocks_trap_box.png"}, walkable = false, groups = {crumbly = 1, cracky = 3}, paramtype = "light", is_ground_content = false, sounds = sound_stone, no_stairs = true, }, ["all_faces_tree"] = { description = S("All-faces Tree"), tiles = {"default_tree_top.png"}, groups = {tree = 1,snappy = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, sounds = sound_wood, furnace_burntime = 30, }, ["all_faces_jungle_tree"] = { description = S("All-faces Jungle Tree"), tiles = {"default_jungletree_top.png"}, groups = {tree = 1,snappy = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, sounds = sound_wood, furnace_burntime = 30, }, ["all_faces_pine_tree"] = { description = S("All-faces Pine Tree"), tiles = {"default_pine_tree_top.png"}, groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, sounds = sound_wood, furnace_burntime = 26, }, ["all_faces_acacia_tree"] = { description = S("All-faces Acacia Tree"), tiles = {"default_acacia_tree_top.png"}, groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2}, sounds = sound_wood, furnace_burntime = 34, }, ["all_faces_aspen_tree"] = { description = S("All-faces Aspen Tree"), tiles = {"default_aspen_tree_top.png"}, groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, sounds = sound_wood, furnace_burntime = 22, }, ["glow_glass"] = { description = S("Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_glow_glass.png", "moreblocks_glow_glass_detail.png"}, -- tiles = {"moreblocks_glow_glass.png"}, one_texture = true, paramtype = "light", sunlight_propagates = true, light_source = 11, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["trap_glow_glass"] = { description = S("Trap Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_trap_glass.png", "moreblocks_glow_glass_detail.png"}, -- tiles = {"moreblocks_trap_glass.png"}, paramtype = "light", sunlight_propagates = true, light_source = 11, walkable = false, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, no_stairs = true, }, ["super_glow_glass"] = { description = S("Super Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_super_glow_glass.png", "moreblocks_super_glow_glass_detail.png"}, -- tiles = {"moreblocks_super_glow_glass.png"}, -- tiles = {"default_glass.png^[colorize:#FFFF78"}, one_texture = true, paramtype = "light", sunlight_propagates = true, light_source = 14, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["dim_glow_glass"] = { description = S("Dim Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_dim_glow_glass.png"}, -- tiles = {"default_glass.png^[colorize:#FFFF78"}, one_texture = true, use_texture_alpha = true, paramtype = "light", sunlight_propagates = true, light_source = 5, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["bright_glow_glass"] = { description = S("Bright Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_dim_glow_glass.png"}, -- tiles = {"default_glass.png^[colorize:#FFFF78"}, one_texture = true, use_texture_alpha = true, paramtype = "light", sunlight_propagates = true, light_source = 12, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["low_glow_glass"] = { description = S("Low Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_low_glow_glass.png"}, -- tiles = {"default_glass.png^[colorize:#FFFF78"}, one_texture = true, use_texture_alpha = true, paramtype = "light", sunlight_propagates = true, light_source = 8, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, }, ["trap_super_glow_glass"] = { description = S("Trap Super Glow Glass"), drawtype = "glasslike_framed_optional", tiles = {"moreblocks_trap_super_glow_glass.png", "moreblocks_super_glow_glass_detail.png"}, -- tiles = {"moreblocks_trap_super_glow_glass.png"}, paramtype = "light", sunlight_propagates = true, light_source = 14, walkable = false, groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3}, sounds = sound_glass, no_stairs = true, }, ["rope"] = { description = S("Rope"), drawtype = "signlike", inventory_image = "moreblocks_rope.png", wield_image = "moreblocks_rope.png", paramtype = "light", sunlight_propagates = true, paramtype2 = "wallmounted", walkable = false, climbable = true, selection_box = {type = "wallmounted",}, groups = {snappy = 3, flammable = 2}, sounds = sound_leaves, no_stairs = true, }, ["copperpatina"] = { description = S("Copper Patina Block"), groups = {cracky = 1, level = 2}, sounds = sound_metal, }, ["gravel_stonebrick"] = { description = S("Gravel on Stonebrick"), tiles = {"default_gravel.png", "default_stone_brick.png", "default_gravel.png^[lowpart:50:default_stone_brick.png", "default_gravel.png^[lowpart:50:default_stone_brick.png", "default_gravel.png^[lowpart:50:default_stone_brick.png", "default_gravel.png^[lowpart:50:default_stone_brick.png"}, no_stairs = true; groups = {cracky = 3}, sounds = sound_gravel, }, ["gravel_slope"] = { description = S("Gravel Slope"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope.obj", collision_box = box_slope, selection_box = box_slope, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, ["gravel_slope_2a"] = { description = S("Gravel Slope 2a"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope_half.obj", collision_box = box_slope_half, selection_box = box_slope_half, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, ["gravel_slope_2b"] = { description = S("Gravel Slope 2b"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope_half_raised.obj", collision_box = box_slope_half_raised, selection_box = box_slope_half_raised, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, ["gravel_slope_3a"] = { description = S("Gravel Slope 3a"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope_third.obj", collision_box = box_slope_third, selection_box = box_slope_third, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, ["gravel_slope_3b"] = { description = S("Gravel Slope 3b"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope_third_raised.obj", collision_box = box_slope_third_raised, selection_box = box_slope_third_raised, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, ["gravel_slope_3c"] = { description = S("Gravel Slope 3c"), tiles = { "default_gravel.png" } , no_stairs = true, groups = {crumbly = 2, falling_node = 1, not_blocking_trains = 1}, sounds = sound_gravel, drawtype = "mesh", mesh = "moreblocks_slope_third_top.obj", collision_box = box_slope_third_top, selection_box = box_slope_third_top, sunlight_propagates = false, light_source = 0, paramtype = "light", paramtype2 = "facedir", -- neu on_rotate = screwdriver.rotate_simple , -- neu is_ground_content = false, --neu -- buildable_to = true; }, } --------------- local tinted_glass_1 = { -- tinted glass from dyes { "blue", "Blue", "blue1" }, { "cyan", "Cyan", "cyan1" }, { "green", "Green", "green1" }, { "grey", "Grey", "grey1" }, { "red", "Red", "red1" }, { "magenta", "Magenta", "magenta1" }, { "white", "White", "white1" }, { "yellow", "Yellow", "yellow1" }, { "brown", "Brown", "brown2" }, { "dark_green", "Dark Green", "dark_green2" }, { "dark_grey", "Dark Grey", "dark_grey2" }, { "orange", "Orange", "orange2" }, { "pink", "Pink", "pink2" }, { "violet", "Violet", "violet2" }, -- tinted glass from dyes + black { "dark_magenta" , "Dark Magenta", "dark_magenta2" }, { "dark_orange" , "Dark Orange", "dark_orange2" }, { "dark_pink" , "Dark Pink", "dark_pink2" }, { "dark_red" , "Dark Red", "dark_red2" }, { "dark_violet" , "Dark Violet", "dark_violet2" }, { "dark_yellow" , "Dark Yellow", "dark_yellow2" }, } for _,f in pairs(tinted_glass_1) do iname = f[1].."_tinted_glass" desc = S(f[2].." Tinted Glass") t_name = {"moreblocks_"..f[3]..".png^moreblocks_clean_glass.png"} neu = {} neu.description = desc neu.drawtype = "glasslike_framed_optional" neu.tiles = t_name neu.one_texture = true neu.use_texture_alpha = true neu.paramtype = "light" neu.sunlight_propagates = true neu.groups = {snappy = 2, cracky = 3, oddly_breakable_by_hand = 3} neu.sounds = sound_glass nodes[iname] = neu end --------------- if minetest.get_modpath("ethereal") then nodes["all_faces_mushroom_tree"] = { description = S("All-faces Mushroom Tree"), tiles = {"mushroom_trunk_top.png"}, groups = {tree = 1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 3}, sounds = sound_wood, furnace_burntime = 22, } end for name, def in pairs(nodes) do def.tiles = def.tiles or {"moreblocks_" ..name.. ".png"} minetest.register_node("moreblocks:" ..name, def) minetest.register_alias(name, "moreblocks:" ..name) local groups = {} local temp_tiles = def.tiles if def.one_texture then temp_tiles = { def.tiles[1]} end for k, v in pairs(def.groups) do groups[k] = v end if not def.no_stairs then stairsplus:register_all("moreblocks", name, "moreblocks:" ..name, { description = def.description, groups = groups, tiles = temp_tiles, sunlight_propagates = def.sunlight_propagates, light_source = def.light_source, sounds = def.sounds, use_texture_alpha = def.use_texture_alpha }) else if def.train_slopes then end if def.minimal_shapes then