1 -- mods/default/nodes.lua
3 minetest.register_node("default:stone", {
5 tiles = {"default_stone.png"},
6 is_ground_content = true,
7 groups = {cracky=3, stone=1},
8 drop = 'default:cobble',
10 sounds = default.node_sound_stone_defaults(),
13 minetest.register_node("default:desert_stone", {
14 description = "Desert Stone",
15 tiles = {"default_desert_stone.png"},
16 is_ground_content = true,
17 groups = {cracky=3, stone=1},
18 drop = 'default:desert_stone',
19 legacy_mineral = true,
20 sounds = default.node_sound_stone_defaults(),
23 minetest.register_node("default:stone_with_coal", {
24 description = "Coal Ore",
25 tiles = {"default_stone.png^default_mineral_coal.png"},
26 is_ground_content = true,
28 drop = 'default:coal_lump',
29 sounds = default.node_sound_stone_defaults(),
32 minetest.register_node("default:stone_with_iron", {
33 description = "Iron Ore",
34 tiles = {"default_stone.png^default_mineral_iron.png"},
35 is_ground_content = true,
37 drop = 'default:iron_lump',
38 sounds = default.node_sound_stone_defaults(),
41 minetest.register_node("default:stone_with_copper", {
42 description = "Copper Ore",
43 tiles = {"default_stone.png^default_mineral_copper.png"},
44 is_ground_content = true,
46 drop = 'default:copper_lump',
47 sounds = default.node_sound_stone_defaults(),
50 minetest.register_node("default:stone_with_mese", {
51 description = "Mese Ore",
52 tiles = {"default_stone.png^default_mineral_mese.png"},
53 is_ground_content = true,
55 drop = "default:mese_crystal",
56 sounds = default.node_sound_stone_defaults(),
59 minetest.register_node("default:stone_with_gold", {
60 description = "Gold Ore",
61 tiles = {"default_stone.png^default_mineral_gold.png"},
62 is_ground_content = true,
64 drop = "default:gold_lump",
65 sounds = default.node_sound_stone_defaults(),
68 minetest.register_node("default:stone_with_diamond", {
69 description = "Diamond Ore",
70 tiles = {"default_stone.png^default_mineral_diamond.png"},
71 is_ground_content = true,
73 drop = "default:diamond",
74 sounds = default.node_sound_stone_defaults(),
77 minetest.register_node("default:stonebrick", {
78 description = "Stone Brick",
79 tiles = {"default_stone_brick.png"},
80 groups = {cracky=2, stone=1},
81 sounds = default.node_sound_stone_defaults(),
84 minetest.register_node("default:desert_stonebrick", {
85 description = "Desert Stone Brick",
86 tiles = {"default_desert_stone_brick.png"},
87 groups = {cracky=2, stone=1},
88 sounds = default.node_sound_stone_defaults(),
91 minetest.register_node("default:dirt_with_grass", {
92 description = "Dirt with Grass",
93 tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
94 is_ground_content = true,
95 groups = {crumbly=3,soil=1},
96 drop = 'default:dirt',
97 sounds = default.node_sound_dirt_defaults({
98 footstep = {name="default_grass_footstep", gain=0.25},
102 minetest.register_node("default:dirt_with_grass_footsteps", {
103 description = "Dirt with Grass and Footsteps",
104 tiles = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
105 is_ground_content = true,
106 groups = {crumbly=3,soil=1,not_in_creative_inventory=1},
107 drop = 'default:dirt',
108 sounds = default.node_sound_dirt_defaults({
109 footstep = {name="default_grass_footstep", gain=0.25},
113 minetest.register_node("default:dirt_with_snow", {
114 description = "Dirt with Snow",
115 tiles = {"default_snow.png", "default_dirt.png", "default_dirt.png^default_snow_side.png"},
116 is_ground_content = true,
117 groups = {crumbly=3},
118 drop = 'default:dirt',
119 sounds = default.node_sound_dirt_defaults({
120 footstep = {name="default_snow_footstep", gain=0.25},
124 minetest.register_node("default:dirt", {
125 description = "Dirt",
126 tiles = {"default_dirt.png"},
127 is_ground_content = true,
128 groups = {crumbly=3,soil=1},
129 sounds = default.node_sound_dirt_defaults(),
132 minetest.register_abm({
133 nodenames = {"default:dirt"},
136 action = function(pos, node)
137 local above = {x=pos.x, y=pos.y+1, z=pos.z}
138 local name = minetest.get_node(above).name
139 local nodedef = minetest.registered_nodes[name]
140 if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light")
141 and nodedef.liquidtype == "none"
142 and (minetest.get_node_light(above) or 0) >= 13 then
143 if name == "default:snow" or name == "default:snowblock" then
144 minetest.set_node(pos, {name = "default:dirt_with_snow"})
146 minetest.set_node(pos, {name = "default:dirt_with_grass"})
152 minetest.register_abm({
153 nodenames = {"default:dirt_with_grass"},
156 action = function(pos, node)
157 local above = {x=pos.x, y=pos.y+1, z=pos.z}
158 local name = minetest.get_node(above).name
159 local nodedef = minetest.registered_nodes[name]
160 if name ~= "ignore" and nodedef
161 and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light")
162 and nodedef.liquidtype == "none") then
163 minetest.set_node(pos, {name = "default:dirt"})
168 minetest.register_node("default:sand", {
169 description = "Sand",
170 tiles = {"default_sand.png"},
171 is_ground_content = true,
172 groups = {crumbly=3, falling_node=1, sand=1},
173 sounds = default.node_sound_sand_defaults(),
176 minetest.register_node("default:desert_sand", {
177 description = "Desert Sand",
178 tiles = {"default_desert_sand.png"},
179 is_ground_content = true,
180 groups = {crumbly=3, falling_node=1, sand=1},
181 sounds = default.node_sound_sand_defaults(),
184 minetest.register_node("default:gravel", {
185 description = "Gravel",
186 tiles = {"default_gravel.png"},
187 is_ground_content = true,
188 groups = {crumbly=2, falling_node=1},
189 sounds = default.node_sound_dirt_defaults({
190 footstep = {name="default_gravel_footstep", gain=0.5},
191 dug = {name="default_gravel_footstep", gain=1.0},
195 minetest.register_node("default:sandstone", {
196 description = "Sandstone",
197 tiles = {"default_sandstone.png"},
198 is_ground_content = true,
199 groups = {crumbly=2,cracky=3},
200 sounds = default.node_sound_stone_defaults(),
203 minetest.register_node("default:sandstonebrick", {
204 description = "Sandstone Brick",
205 tiles = {"default_sandstone_brick.png"},
206 is_ground_content = true,
208 sounds = default.node_sound_stone_defaults(),
211 minetest.register_node("default:clay", {
212 description = "Clay",
213 tiles = {"default_clay.png"},
214 is_ground_content = true,
215 groups = {crumbly=3},
216 drop = 'default:clay_lump 4',
217 sounds = default.node_sound_dirt_defaults(),
220 minetest.register_node("default:brick", {
221 description = "Brick Block",
222 tiles = {"default_brick.png"},
224 sounds = default.node_sound_stone_defaults(),
227 minetest.register_node("default:tree", {
228 description = "Tree",
229 tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
230 paramtype2 = "facedir",
231 groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
232 sounds = default.node_sound_wood_defaults(),
233 on_place = minetest.rotate_node
236 minetest.register_node("default:jungletree", {
237 description = "Jungle Tree",
238 tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
239 paramtype2 = "facedir",
240 groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
241 sounds = default.node_sound_wood_defaults(),
242 on_place = minetest.rotate_node
245 minetest.register_node("default:junglewood", {
246 description = "Junglewood Planks",
247 tiles = {"default_junglewood.png"},
248 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
249 sounds = default.node_sound_wood_defaults(),
252 minetest.register_node("default:jungleleaves", {
253 description = "Jungle Leaves",
254 drawtype = "allfaces_optional",
256 tiles = {"default_jungleleaves.png"},
258 groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
263 -- player will get sapling with 1/20 chance
264 items = {'default:junglesapling'},
268 -- player will get leaves only if he get no saplings,
269 -- this is because max_items is 1
270 items = {'default:jungleleaves'},
274 sounds = default.node_sound_leaves_defaults(),
277 minetest.register_node("default:junglesapling", {
278 description = "Jungle Sapling",
279 drawtype = "plantlike",
281 tiles = {"default_junglesapling.png"},
282 inventory_image = "default_junglesapling.png",
283 wield_image = "default_junglesapling.png",
288 fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
290 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
291 sounds = default.node_sound_leaves_defaults(),
294 minetest.register_node("default:junglegrass", {
295 description = "Jungle Grass",
296 drawtype = "plantlike",
298 tiles = {"default_junglegrass.png"},
299 inventory_image = "default_junglegrass.png",
300 wield_image = "default_junglegrass.png",
304 is_ground_content = true,
305 groups = {snappy=3,flammable=2,flora=1,attached_node=1},
306 sounds = default.node_sound_leaves_defaults(),
309 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
313 minetest.register_node("default:leaves", {
314 description = "Leaves",
315 drawtype = "allfaces_optional",
317 tiles = {"default_leaves.png"},
319 groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
324 -- player will get sapling with 1/20 chance
325 items = {'default:sapling'},
329 -- player will get leaves only if he get no saplings,
330 -- this is because max_items is 1
331 items = {'default:leaves'},
335 sounds = default.node_sound_leaves_defaults(),
338 minetest.register_node("default:cactus", {
339 description = "Cactus",
340 tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
341 paramtype2 = "facedir",
342 is_ground_content = true,
343 groups = {snappy=1,choppy=3,flammable=2},
344 sounds = default.node_sound_wood_defaults(),
345 on_place = minetest.rotate_node
348 minetest.register_node("default:papyrus", {
349 description = "Papyrus",
350 drawtype = "plantlike",
351 tiles = {"default_papyrus.png"},
352 inventory_image = "default_papyrus.png",
353 wield_image = "default_papyrus.png",
356 is_ground_content = true,
359 fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
361 groups = {snappy=3,flammable=2},
362 sounds = default.node_sound_leaves_defaults(),
365 minetest.register_node("default:bookshelf", {
366 description = "Bookshelf",
367 tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
368 groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
369 sounds = default.node_sound_wood_defaults(),
372 minetest.register_node("default:glass", {
373 description = "Glass",
374 drawtype = "glasslike",
375 tiles = {"default_glass.png"},
376 inventory_image = minetest.inventorycube("default_glass.png"),
378 sunlight_propagates = true,
379 groups = {cracky=3,oddly_breakable_by_hand=3},
380 sounds = default.node_sound_glass_defaults(),
383 minetest.register_node("default:fence_wood", {
384 description = "Wooden Fence",
385 drawtype = "fencelike",
386 tiles = {"default_wood.png"},
387 inventory_image = "default_fence.png",
388 wield_image = "default_fence.png",
392 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
394 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
395 sounds = default.node_sound_wood_defaults(),
398 minetest.register_node("default:rail", {
399 description = "Rail",
400 drawtype = "raillike",
401 tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
402 inventory_image = "default_rail.png",
403 wield_image = "default_rail.png",
408 -- but how to specify the dimensions for curved and sideways rails?
409 fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
411 groups = {bendy=2,dig_immediate=2,attached_node=1},
414 minetest.register_node("default:ladder", {
415 description = "Ladder",
416 drawtype = "signlike",
417 tiles = {"default_ladder.png"},
418 inventory_image = "default_ladder.png",
419 wield_image = "default_ladder.png",
421 paramtype2 = "wallmounted",
425 type = "wallmounted",
426 --wall_top = = <default>
427 --wall_bottom = = <default>
428 --wall_side = = <default>
430 groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2},
431 legacy_wallmounted = true,
432 sounds = default.node_sound_wood_defaults(),
435 minetest.register_node("default:wood", {
436 description = "Wooden Planks",
437 tiles = {"default_wood.png"},
438 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
439 sounds = default.node_sound_wood_defaults(),
442 minetest.register_node("default:cloud", {
443 description = "Cloud",
444 tiles = {"default_cloud.png"},
445 sounds = default.node_sound_defaults(),
446 groups = {not_in_creative_inventory=1},
449 minetest.register_node("default:water_flowing", {
450 description = "Flowing Water",
451 inventory_image = minetest.inventorycube("default_water.png"),
452 drawtype = "flowingliquid",
453 tiles = {"default_water.png"},
456 image="default_water_flowing_animated.png",
457 backface_culling=false,
458 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
461 image="default_water_flowing_animated.png",
462 backface_culling=true,
463 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
468 paramtype2 = "flowingliquid",
475 liquidtype = "flowing",
476 liquid_alternative_flowing = "default:water_flowing",
477 liquid_alternative_source = "default:water_source",
478 liquid_viscosity = WATER_VISC,
479 freezemelt = "default:snow",
480 post_effect_color = {a=64, r=100, g=100, b=200},
481 groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1},
484 minetest.register_node("default:water_source", {
485 description = "Water Source",
486 inventory_image = minetest.inventorycube("default_water.png"),
489 {name="default_water_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
492 -- New-style water source material (mostly unused)
494 name="default_water_source_animated.png",
495 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
496 backface_culling = false,
507 liquidtype = "source",
508 liquid_alternative_flowing = "default:water_flowing",
509 liquid_alternative_source = "default:water_source",
510 liquid_viscosity = WATER_VISC,
511 freezemelt = "default:ice",
512 post_effect_color = {a=64, r=100, g=100, b=200},
513 groups = {water=3, liquid=3, puts_out_fire=1, freezes=1},
516 minetest.register_node("default:lava_flowing", {
517 description = "Flowing Lava",
518 inventory_image = minetest.inventorycube("default_lava.png"),
519 drawtype = "flowingliquid",
520 tiles = {"default_lava.png"},
523 image="default_lava_flowing_animated.png",
524 backface_culling=false,
525 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
528 image="default_lava_flowing_animated.png",
529 backface_culling=true,
530 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
534 paramtype2 = "flowingliquid",
535 light_source = LIGHT_MAX - 1,
542 liquidtype = "flowing",
543 liquid_alternative_flowing = "default:lava_flowing",
544 liquid_alternative_source = "default:lava_source",
545 liquid_viscosity = LAVA_VISC,
546 liquid_renewable = false,
547 damage_per_second = 4*2,
548 post_effect_color = {a=192, r=255, g=64, b=0},
549 groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},
552 minetest.register_node("default:lava_source", {
553 description = "Lava Source",
554 inventory_image = minetest.inventorycube("default_lava.png"),
557 {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
560 -- New-style lava source material (mostly unused)
562 name="default_lava_source_animated.png",
563 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0},
564 backface_culling = false,
568 light_source = LIGHT_MAX - 1,
575 liquidtype = "source",
576 liquid_alternative_flowing = "default:lava_flowing",
577 liquid_alternative_source = "default:lava_source",
578 liquid_viscosity = LAVA_VISC,
579 liquid_renewable = false,
580 damage_per_second = 4*2,
581 post_effect_color = {a=192, r=255, g=64, b=0},
582 groups = {lava=3, liquid=2, hot=3, igniter=1},
585 minetest.register_node("default:torch", {
586 description = "Torch",
587 drawtype = "torchlike",
588 --tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
590 {name="default_torch_on_floor_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
591 {name="default_torch_on_ceiling_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
592 {name="default_torch_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
594 inventory_image = "default_torch_on_floor.png",
595 wield_image = "default_torch_on_floor.png",
597 paramtype2 = "wallmounted",
598 sunlight_propagates = true,
600 light_source = LIGHT_MAX-1,
602 type = "wallmounted",
603 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
604 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
605 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
607 groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1,hot=2},
608 legacy_wallmounted = true,
609 sounds = default.node_sound_defaults(),
612 minetest.register_node("default:sign_wall", {
613 description = "Sign",
614 drawtype = "signlike",
615 tiles = {"default_sign_wall.png"},
616 inventory_image = "default_sign_wall.png",
617 wield_image = "default_sign_wall.png",
619 paramtype2 = "wallmounted",
620 sunlight_propagates = true,
623 type = "wallmounted",
624 --wall_top = <default>
625 --wall_bottom = <default>
626 --wall_side = <default>
628 groups = {choppy=2,dig_immediate=2,attached_node=1},
629 legacy_wallmounted = true,
630 sounds = default.node_sound_defaults(),
631 on_construct = function(pos)
632 --local n = minetest.get_node(pos)
633 local meta = minetest.get_meta(pos)
634 meta:set_string("formspec", "field[text;;${text}]")
635 meta:set_string("infotext", "\"\"")
637 on_receive_fields = function(pos, formname, fields, sender)
638 --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
639 local meta = minetest.get_meta(pos)
640 fields.text = fields.text or ""
641 minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
642 "\" to sign at "..minetest.pos_to_string(pos))
643 meta:set_string("text", fields.text)
644 meta:set_string("infotext", '"'..fields.text..'"')
648 default.chest_formspec =
650 "list[current_name;main;0,0;8,4;]"..
651 "list[current_player;main;0,5;8,4;]"
653 function default.get_locked_chest_formspec(pos)
654 local spos = pos.x .. "," .. pos.y .. "," ..pos.z
657 "list[nodemeta:".. spos .. ";main;0,0;8,4;]"..
658 "list[current_player;main;0,5;8,4;]"
663 minetest.register_node("default:chest", {
664 description = "Chest",
665 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
666 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
667 paramtype2 = "facedir",
668 groups = {choppy=2,oddly_breakable_by_hand=2},
669 legacy_facedir_simple = true,
670 sounds = default.node_sound_wood_defaults(),
671 on_construct = function(pos)
672 local meta = minetest.get_meta(pos)
673 meta:set_string("formspec",default.chest_formspec)
674 meta:set_string("infotext", "Chest")
675 local inv = meta:get_inventory()
676 inv:set_size("main", 8*4)
678 can_dig = function(pos,player)
679 local meta = minetest.get_meta(pos);
680 local inv = meta:get_inventory()
681 return inv:is_empty("main")
683 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
684 minetest.log("action", player:get_player_name()..
685 " moves stuff in chest at "..minetest.pos_to_string(pos))
687 on_metadata_inventory_put = function(pos, listname, index, stack, player)
688 minetest.log("action", player:get_player_name()..
689 " moves stuff to chest at "..minetest.pos_to_string(pos))
691 on_metadata_inventory_take = function(pos, listname, index, stack, player)
692 minetest.log("action", player:get_player_name()..
693 " takes stuff from chest at "..minetest.pos_to_string(pos))
697 local function has_locked_chest_privilege(meta, player)
698 if player:get_player_name() ~= meta:get_string("owner") then
704 minetest.register_node("default:chest_locked", {
705 description = "Locked Chest",
706 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
707 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
708 paramtype2 = "facedir",
709 groups = {choppy=2,oddly_breakable_by_hand=2},
710 legacy_facedir_simple = true,
711 sounds = default.node_sound_wood_defaults(),
712 after_place_node = function(pos, placer)
713 local meta = minetest.get_meta(pos)
714 meta:set_string("owner", placer:get_player_name() or "")
715 meta:set_string("infotext", "Locked Chest (owned by "..
716 meta:get_string("owner")..")")
718 on_construct = function(pos)
719 local meta = minetest.get_meta(pos)
720 meta:set_string("infotext", "Locked Chest")
721 meta:set_string("owner", "")
722 local inv = meta:get_inventory()
723 inv:set_size("main", 8*4)
725 can_dig = function(pos,player)
726 local meta = minetest.get_meta(pos);
727 local inv = meta:get_inventory()
728 return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
730 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
731 local meta = minetest.get_meta(pos)
732 if not has_locked_chest_privilege(meta, player) then
733 minetest.log("action", player:get_player_name()..
734 " tried to access a locked chest belonging to "..
735 meta:get_string("owner").." at "..
736 minetest.pos_to_string(pos))
741 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
742 local meta = minetest.get_meta(pos)
743 if not has_locked_chest_privilege(meta, player) then
744 minetest.log("action", player:get_player_name()..
745 " tried to access a locked chest belonging to "..
746 meta:get_string("owner").." at "..
747 minetest.pos_to_string(pos))
750 return stack:get_count()
752 allow_metadata_inventory_take = function(pos, listname, index, stack, player)
753 local meta = minetest.get_meta(pos)
754 if not has_locked_chest_privilege(meta, player) then
755 minetest.log("action", player:get_player_name()..
756 " tried to access a locked chest belonging to "..
757 meta:get_string("owner").." at "..
758 minetest.pos_to_string(pos))
761 return stack:get_count()
763 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
764 minetest.log("action", player:get_player_name()..
765 " moves stuff in locked chest at "..minetest.pos_to_string(pos))
767 on_metadata_inventory_put = function(pos, listname, index, stack, player)
768 minetest.log("action", player:get_player_name()..
769 " moves stuff to locked chest at "..minetest.pos_to_string(pos))
771 on_metadata_inventory_take = function(pos, listname, index, stack, player)
772 minetest.log("action", player:get_player_name()..
773 " takes stuff from locked chest at "..minetest.pos_to_string(pos))
775 on_rightclick = function(pos, node, clicker)
776 local meta = minetest.get_meta(pos)
777 if has_locked_chest_privilege(meta, clicker) then
778 minetest.show_formspec(
779 clicker:get_player_name(),
780 "default:chest_locked",
781 default.get_locked_chest_formspec(pos)
787 function default.get_furnace_active_formspec(pos, percent)
790 "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
791 (100-percent)..":default_furnace_fire_fg.png]"..
792 "list[current_name;fuel;2,3;1,1;]"..
793 "list[current_name;src;2,1;1,1;]"..
794 "list[current_name;dst;5,1;2,2;]"..
795 "list[current_player;main;0,5;8,4;]"
799 default.furnace_inactive_formspec =
801 "image[2,2;1,1;default_furnace_fire_bg.png]"..
802 "list[current_name;fuel;2,3;1,1;]"..
803 "list[current_name;src;2,1;1,1;]"..
804 "list[current_name;dst;5,1;2,2;]"..
805 "list[current_player;main;0,5;8,4;]"
807 minetest.register_node("default:furnace", {
808 description = "Furnace",
809 tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
810 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
811 paramtype2 = "facedir",
813 legacy_facedir_simple = true,
814 sounds = default.node_sound_stone_defaults(),
815 on_construct = function(pos)
816 local meta = minetest.get_meta(pos)
817 meta:set_string("formspec", default.furnace_inactive_formspec)
818 meta:set_string("infotext", "Furnace")
819 local inv = meta:get_inventory()
820 inv:set_size("fuel", 1)
821 inv:set_size("src", 1)
822 inv:set_size("dst", 4)
824 can_dig = function(pos,player)
825 local meta = minetest.get_meta(pos);
826 local inv = meta:get_inventory()
827 if not inv:is_empty("fuel") then
829 elseif not inv:is_empty("dst") then
831 elseif not inv:is_empty("src") then
836 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
837 local meta = minetest.get_meta(pos)
838 local inv = meta:get_inventory()
839 if listname == "fuel" then
840 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
841 if inv:is_empty("src") then
842 meta:set_string("infotext","Furnace is empty")
844 return stack:get_count()
848 elseif listname == "src" then
849 return stack:get_count()
850 elseif listname == "dst" then
854 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
855 local meta = minetest.get_meta(pos)
856 local inv = meta:get_inventory()
857 local stack = inv:get_stack(from_list, from_index)
858 if to_list == "fuel" then
859 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
860 if inv:is_empty("src") then
861 meta:set_string("infotext","Furnace is empty")
867 elseif to_list == "src" then
869 elseif to_list == "dst" then
875 minetest.register_node("default:furnace_active", {
876 description = "Furnace",
877 tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
878 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
879 paramtype2 = "facedir",
881 drop = "default:furnace",
882 groups = {cracky=2, not_in_creative_inventory=1,hot=1},
883 legacy_facedir_simple = true,
884 sounds = default.node_sound_stone_defaults(),
885 on_construct = function(pos)
886 local meta = minetest.get_meta(pos)
887 meta:set_string("formspec", default.furnace_inactive_formspec)
888 meta:set_string("infotext", "Furnace");
889 local inv = meta:get_inventory()
890 inv:set_size("fuel", 1)
891 inv:set_size("src", 1)
892 inv:set_size("dst", 4)
894 can_dig = function(pos,player)
895 local meta = minetest.get_meta(pos);
896 local inv = meta:get_inventory()
897 if not inv:is_empty("fuel") then
899 elseif not inv:is_empty("dst") then
901 elseif not inv:is_empty("src") then
906 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
907 local meta = minetest.get_meta(pos)
908 local inv = meta:get_inventory()
909 if listname == "fuel" then
910 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
911 if inv:is_empty("src") then
912 meta:set_string("infotext","Furnace is empty")
914 return stack:get_count()
918 elseif listname == "src" then
919 return stack:get_count()
920 elseif listname == "dst" then
924 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
925 local meta = minetest.get_meta(pos)
926 local inv = meta:get_inventory()
927 local stack = inv:get_stack(from_list, from_index)
928 if to_list == "fuel" then
929 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
930 if inv:is_empty("src") then
931 meta:set_string("infotext","Furnace is empty")
937 elseif to_list == "src" then
939 elseif to_list == "dst" then
945 function hacky_swap_node(pos,name)
946 local node = minetest.get_node(pos)
947 local meta = minetest.get_meta(pos)
948 local meta0 = meta:to_table()
949 if node.name == name then
953 local meta0 = meta:to_table()
954 minetest.set_node(pos,node)
955 meta = minetest.get_meta(pos)
956 meta:from_table(meta0)
959 minetest.register_abm({
960 nodenames = {"default:furnace","default:furnace_active"},
963 action = function(pos, node, active_object_count, active_object_count_wider)
964 local meta = minetest.get_meta(pos)
965 for i, name in ipairs({
971 if meta:get_string(name) == "" then
972 meta:set_float(name, 0.0)
976 local inv = meta:get_inventory()
978 local srclist = inv:get_list("src")
983 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
986 local was_active = false
988 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
990 meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
991 meta:set_float("src_time", meta:get_float("src_time") + 1)
992 if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
993 -- check if there's room for output in "dst" list
994 if inv:room_for_item("dst",cooked.item) then
995 -- Put result in "dst" list
996 inv:add_item("dst", cooked.item)
997 -- take stuff from "src" list
998 inv:set_stack("src", 1, aftercooked.items[1])
1000 --print("Could not insert '"..cooked.item:to_string().."'")
1002 meta:set_string("src_time", 0)
1006 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
1007 local percent = math.floor(meta:get_float("fuel_time") /
1008 meta:get_float("fuel_totaltime") * 100)
1009 meta:set_string("infotext","Furnace active: "..percent.."%")
1010 hacky_swap_node(pos,"default:furnace_active")
1011 meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent))
1018 local fuellist = inv:get_list("fuel")
1019 local srclist = inv:get_list("src")
1022 cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
1025 fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
1028 if fuel.time <= 0 then
1029 meta:set_string("infotext","Furnace out of fuel")
1030 hacky_swap_node(pos,"default:furnace")
1031 meta:set_string("formspec", default.furnace_inactive_formspec)
1035 if cooked.item:is_empty() then
1037 meta:set_string("infotext","Furnace is empty")
1038 hacky_swap_node(pos,"default:furnace")
1039 meta:set_string("formspec", default.furnace_inactive_formspec)
1044 meta:set_string("fuel_totaltime", fuel.time)
1045 meta:set_string("fuel_time", 0)
1047 inv:set_stack("fuel", 1, afterfuel.items[1])
1051 minetest.register_node("default:cobble", {
1052 description = "Cobblestone",
1053 tiles = {"default_cobble.png"},
1054 is_ground_content = true,
1055 groups = {cracky=3, stone=2},
1056 sounds = default.node_sound_stone_defaults(),
1059 minetest.register_node("default:mossycobble", {
1060 description = "Mossy Cobblestone",
1061 tiles = {"default_mossycobble.png"},
1062 is_ground_content = true,
1063 groups = {cracky=3},
1064 sounds = default.node_sound_stone_defaults(),
1067 minetest.register_node("default:coalblock", {
1068 description = "Coal Block",
1069 tiles = {"default_coal_block.png"},
1070 is_ground_content = true,
1071 groups = {cracky=3},
1072 sounds = default.node_sound_stone_defaults(),
1075 minetest.register_node("default:steelblock", {
1076 description = "Steel Block",
1077 tiles = {"default_steel_block.png"},
1078 is_ground_content = true,
1079 groups = {cracky=1,level=2},
1080 sounds = default.node_sound_stone_defaults(),
1083 minetest.register_node("default:copperblock", {
1084 description = "Copper Block",
1085 tiles = {"default_copper_block.png"},
1086 is_ground_content = true,
1087 groups = {cracky=1,level=2},
1088 sounds = default.node_sound_stone_defaults(),
1091 minetest.register_node("default:bronzeblock", {
1092 description = "Bronze Block",
1093 tiles = {"default_bronze_block.png"},
1094 is_ground_content = true,
1095 groups = {cracky=1,level=2},
1096 sounds = default.node_sound_stone_defaults(),
1099 minetest.register_node("default:mese", {
1100 description = "Mese Block",
1101 tiles = {"default_mese_block.png"},
1102 is_ground_content = true,
1103 groups = {cracky=1,level=2},
1104 sounds = default.node_sound_stone_defaults(),
1106 minetest.register_alias("default:mese_block", "default:mese")
1108 minetest.register_node("default:goldblock", {
1109 description = "Gold Block",
1110 tiles = {"default_gold_block.png"},
1111 is_ground_content = true,
1112 groups = {cracky=1},
1113 sounds = default.node_sound_stone_defaults(),
1116 minetest.register_node("default:diamondblock", {
1117 description = "Diamond Block",
1118 tiles = {"default_diamond_block.png"},
1119 is_ground_content = true,
1120 groups = {cracky=1,level=3},
1121 sounds = default.node_sound_stone_defaults(),
1124 minetest.register_node("default:obsidian_glass", {
1125 description = "Obsidian Glass",
1126 drawtype = "glasslike",
1127 tiles = {"default_obsidian_glass.png"},
1128 paramtype = "light",
1129 sunlight_propagates = true,
1130 sounds = default.node_sound_glass_defaults(),
1131 groups = {cracky=3,oddly_breakable_by_hand=3},
1134 minetest.register_node("default:obsidian", {
1135 description = "Obsidian",
1136 tiles = {"default_obsidian.png"},
1137 is_ground_content = true,
1138 sounds = default.node_sound_stone_defaults(),
1139 groups = {cracky=1,level=2},
1142 minetest.register_node("default:nyancat", {
1143 description = "Nyan Cat",
1144 tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1145 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1146 paramtype2 = "facedir",
1147 groups = {cracky=2},
1148 legacy_facedir_simple = true,
1149 sounds = default.node_sound_defaults(),
1152 minetest.register_node("default:nyancat_rainbow", {
1153 description = "Nyan Cat Rainbow",
1154 tiles = {"default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
1155 "default_nc_rb.png", "default_nc_rb.png"},
1156 paramtype2 = "facedir",
1157 groups = {cracky=2},
1158 sounds = default.node_sound_defaults(),
1161 minetest.register_node("default:sapling", {
1162 description = "Sapling",
1163 drawtype = "plantlike",
1165 tiles = {"default_sapling.png"},
1166 inventory_image = "default_sapling.png",
1167 wield_image = "default_sapling.png",
1168 paramtype = "light",
1170 is_ground_content = true,
1173 fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
1175 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
1176 sounds = default.node_sound_leaves_defaults(),
1179 minetest.register_node("default:apple", {
1180 description = "Apple",
1181 drawtype = "plantlike",
1183 tiles = {"default_apple.png"},
1184 inventory_image = "default_apple.png",
1185 paramtype = "light",
1186 sunlight_propagates = true,
1188 is_ground_content = true,
1191 fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
1193 groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
1194 on_use = minetest.item_eat(1),
1195 sounds = default.node_sound_leaves_defaults(),
1196 after_place_node = function(pos, placer, itemstack)
1197 if placer:is_player() then
1198 minetest.set_node(pos, {name="default:apple", param2=1})
1203 minetest.register_node("default:dry_shrub", {
1204 description = "Dry Shrub",
1205 drawtype = "plantlike",
1207 tiles = {"default_dry_shrub.png"},
1208 inventory_image = "default_dry_shrub.png",
1209 wield_image = "default_dry_shrub.png",
1210 paramtype = "light",
1212 is_ground_content = true,
1213 buildable_to = true,
1214 groups = {snappy=3,flammable=3,attached_node=1},
1215 sounds = default.node_sound_leaves_defaults(),
1218 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1222 minetest.register_node("default:grass_1", {
1223 description = "Grass",
1224 drawtype = "plantlike",
1225 tiles = {"default_grass_1.png"},
1226 -- use a bigger inventory image
1227 inventory_image = "default_grass_3.png",
1228 wield_image = "default_grass_3.png",
1229 paramtype = "light",
1231 is_ground_content = true,
1232 buildable_to = true,
1233 groups = {snappy=3,flammable=3,flora=1,attached_node=1},
1234 sounds = default.node_sound_leaves_defaults(),
1237 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1239 on_place = function(itemstack, placer, pointed_thing)
1240 -- place a random grass node
1241 local stack = ItemStack("default:grass_"..math.random(1,5))
1242 local ret = minetest.item_place(stack, placer, pointed_thing)
1243 return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
1247 minetest.register_node("default:grass_2", {
1248 description = "Grass",
1249 drawtype = "plantlike",
1250 tiles = {"default_grass_2.png"},
1251 inventory_image = "default_grass_2.png",
1252 wield_image = "default_grass_2.png",
1253 paramtype = "light",
1255 buildable_to = true,
1256 is_ground_content = true,
1257 drop = "default:grass_1",
1258 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1259 sounds = default.node_sound_leaves_defaults(),
1262 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1265 minetest.register_node("default:grass_3", {
1266 description = "Grass",
1267 drawtype = "plantlike",
1268 tiles = {"default_grass_3.png"},
1269 inventory_image = "default_grass_3.png",
1270 wield_image = "default_grass_3.png",
1271 paramtype = "light",
1273 buildable_to = true,
1274 is_ground_content = true,
1275 drop = "default:grass_1",
1276 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1277 sounds = default.node_sound_leaves_defaults(),
1280 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1284 minetest.register_node("default:grass_4", {
1285 description = "Grass",
1286 drawtype = "plantlike",
1287 tiles = {"default_grass_4.png"},
1288 inventory_image = "default_grass_4.png",
1289 wield_image = "default_grass_4.png",
1290 paramtype = "light",
1292 buildable_to = true,
1293 is_ground_content = true,
1294 drop = "default:grass_1",
1295 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1296 sounds = default.node_sound_leaves_defaults(),
1299 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1303 minetest.register_node("default:grass_5", {
1304 description = "Grass",
1305 drawtype = "plantlike",
1306 tiles = {"default_grass_5.png"},
1307 inventory_image = "default_grass_5.png",
1308 wield_image = "default_grass_5.png",
1309 paramtype = "light",
1311 buildable_to = true,
1312 is_ground_content = true,
1313 drop = "default:grass_1",
1314 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1315 sounds = default.node_sound_leaves_defaults(),
1318 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1322 minetest.register_node("default:ice", {
1323 description = "Ice",
1324 tiles = {"default_ice.png"},
1325 is_ground_content = true,
1326 paramtype = "light",
1327 freezemelt = "default:water_source",
1328 groups = {cracky=3, melts=1},
1329 sounds = default.node_sound_glass_defaults(),
1332 minetest.register_node("default:snow", {
1333 description = "Snow",
1334 tiles = {"default_snow.png"},
1335 inventory_image = "default_snowball.png",
1336 wield_image = "default_snowball.png",
1337 is_ground_content = true,
1338 paramtype = "light",
1339 buildable_to = true,
1341 drawtype = "nodebox",
1342 freezemelt = "default:water_flowing",
1346 {-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
1349 groups = {crumbly=3,falling_node=1, melts=1, float=1},
1350 sounds = default.node_sound_dirt_defaults({
1351 footstep = {name="default_snow_footstep", gain=0.25},
1352 dug = {name="default_snow_footstep", gain=0.75},
1354 on_construct = function(pos)
1356 if minetest.get_node(pos).name == "default:dirt_with_grass" then
1357 minetest.set_node(pos, {name="default:dirt_with_snow"})
1361 minetest.register_alias("snow", "default:snow")
1363 minetest.register_node("default:snowblock", {
1364 description = "Snow Block",
1365 tiles = {"default_snow.png"},
1366 is_ground_content = true,
1367 freezemelt = "default:water_source",
1368 groups = {crumbly=3, melts=1},
1369 sounds = default.node_sound_dirt_defaults({
1370 footstep = {name="default_snow_footstep", gain=0.25},
1371 dug = {name="default_snow_footstep", gain=0.75},