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_cobble',
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"},
223 is_ground_content = false,
225 sounds = default.node_sound_stone_defaults(),
228 minetest.register_node("default:tree", {
229 description = "Tree",
230 tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
231 paramtype2 = "facedir",
232 is_ground_content = false,
233 groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
234 sounds = default.node_sound_wood_defaults(),
235 on_place = minetest.rotate_node
238 minetest.register_node("default:jungletree", {
239 description = "Jungle Tree",
240 tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
241 paramtype2 = "facedir",
242 is_ground_content = false,
243 groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
244 sounds = default.node_sound_wood_defaults(),
245 on_place = minetest.rotate_node
248 minetest.register_node("default:junglewood", {
249 description = "Junglewood Planks",
250 tiles = {"default_junglewood.png"},
251 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
252 sounds = default.node_sound_wood_defaults(),
255 minetest.register_node("default:jungleleaves", {
256 description = "Jungle Leaves",
257 drawtype = "allfaces_optional",
260 tiles = {"default_jungleleaves.png"},
262 is_ground_content = false,
263 groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
268 -- player will get sapling with 1/20 chance
269 items = {'default:junglesapling'},
273 -- player will get leaves only if he get no saplings,
274 -- this is because max_items is 1
275 items = {'default:jungleleaves'},
279 sounds = default.node_sound_leaves_defaults(),
282 minetest.register_node("default:junglesapling", {
283 description = "Jungle Sapling",
284 drawtype = "plantlike",
286 tiles = {"default_junglesapling.png"},
287 inventory_image = "default_junglesapling.png",
288 wield_image = "default_junglesapling.png",
293 fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
295 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
296 sounds = default.node_sound_leaves_defaults(),
299 minetest.register_node("default:junglegrass", {
300 description = "Jungle Grass",
301 drawtype = "plantlike",
304 tiles = {"default_junglegrass.png"},
305 inventory_image = "default_junglegrass.png",
306 wield_image = "default_junglegrass.png",
310 is_ground_content = true,
311 groups = {snappy=3,flammable=2,flora=1,attached_node=1},
312 sounds = default.node_sound_leaves_defaults(),
315 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
319 minetest.register_node("default:leaves", {
320 description = "Leaves",
321 drawtype = "allfaces_optional",
324 tiles = {"default_leaves.png"},
326 is_ground_content = false,
327 groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
332 -- player will get sapling with 1/20 chance
333 items = {'default:sapling'},
337 -- player will get leaves only if he get no saplings,
338 -- this is because max_items is 1
339 items = {'default:leaves'},
343 sounds = default.node_sound_leaves_defaults(),
346 minetest.register_node("default:cactus", {
347 description = "Cactus",
348 tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
349 paramtype2 = "facedir",
350 is_ground_content = true,
351 groups = {snappy=1,choppy=3,flammable=2},
352 sounds = default.node_sound_wood_defaults(),
353 on_place = minetest.rotate_node,
354 after_dig_node = function(pos, node, metadata, digger)
355 default.dig_up(pos, node, digger)
359 minetest.register_node("default:papyrus", {
360 description = "Papyrus",
361 drawtype = "plantlike",
362 tiles = {"default_papyrus.png"},
363 inventory_image = "default_papyrus.png",
364 wield_image = "default_papyrus.png",
367 is_ground_content = true,
370 fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
372 groups = {snappy=3,flammable=2},
373 sounds = default.node_sound_leaves_defaults(),
374 after_dig_node = function(pos, node, metadata, digger)
375 default.dig_up(pos, node, digger)
379 default.bookshelf_formspec =
384 "list[context;books;0,0.3;8,2;]"..
385 "list[current_player;main;0,2.85;8,1;]"..
386 "list[current_player;main;0,4.08;8,3;8]"..
387 default.get_hotbar_bg(0,2.85)
389 minetest.register_node("default:bookshelf", {
390 description = "Bookshelf",
391 tiles = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
392 is_ground_content = false,
393 groups = {choppy=3,oddly_breakable_by_hand=2,flammable=3},
394 sounds = default.node_sound_wood_defaults(),
395 on_construct = function(pos)
396 local meta = minetest.env:get_meta(pos)
397 meta:set_string("formspec", default.bookshelf_formspec)
398 local inv = meta:get_inventory()
399 inv:set_size("books", 8*2)
401 can_dig = function(pos,player)
402 local meta = minetest.env:get_meta(pos);
403 local inv = meta:get_inventory()
404 return inv:is_empty("books")
407 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
408 local meta = minetest.env:get_meta(pos)
409 local inv = meta:get_inventory()
410 if listname == "books" then
411 if stack:get_name() == "default:book" then
419 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
420 local meta = minetest.env:get_meta(pos)
421 local inv = meta:get_inventory()
422 local stack = inv:get_stack(from_list, from_index)
423 local to_stack = inv:get_stack(to_list, to_index)
424 if to_list == "books" then
425 if stack:get_name() == "default:book" and to_stack:is_empty() then
433 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
434 minetest.log("action", player:get_player_name()..
435 " moves stuff in bookshelf at "..minetest.pos_to_string(pos))
437 on_metadata_inventory_put = function(pos, listname, index, stack, player)
438 minetest.log("action", player:get_player_name()..
439 " moves stuff to bookshelf at "..minetest.pos_to_string(pos))
441 on_metadata_inventory_take = function(pos, listname, index, stack, player)
442 minetest.log("action", player:get_player_name()..
443 " takes stuff from bookshelf at "..minetest.pos_to_string(pos))
447 minetest.register_node("default:glass", {
448 description = "Glass",
449 drawtype = "glasslike",
450 tiles = {"default_glass.png"},
451 inventory_image = minetest.inventorycube("default_glass.png"),
453 sunlight_propagates = true,
454 is_ground_content = false,
455 groups = {cracky=3,oddly_breakable_by_hand=3},
456 sounds = default.node_sound_glass_defaults(),
459 minetest.register_node("default:fence_wood", {
460 description = "Wooden Fence",
461 drawtype = "fencelike",
462 tiles = {"default_wood.png"},
463 inventory_image = "default_fence.png",
464 wield_image = "default_fence.png",
466 is_ground_content = false,
469 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
471 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
472 sounds = default.node_sound_wood_defaults(),
475 minetest.register_node("default:rail", {
476 description = "Rail",
477 drawtype = "raillike",
478 tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
479 inventory_image = "default_rail.png",
480 wield_image = "default_rail.png",
483 is_ground_content = false,
486 -- but how to specify the dimensions for curved and sideways rails?
487 fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
489 groups = {bendy=2,dig_immediate=2,attached_node=1},
492 minetest.register_node("default:ladder", {
493 description = "Ladder",
494 drawtype = "signlike",
495 tiles = {"default_ladder.png"},
496 inventory_image = "default_ladder.png",
497 wield_image = "default_ladder.png",
499 paramtype2 = "wallmounted",
502 is_ground_content = false,
504 type = "wallmounted",
505 --wall_top = = <default>
506 --wall_bottom = = <default>
507 --wall_side = = <default>
509 groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2},
510 legacy_wallmounted = true,
511 sounds = default.node_sound_wood_defaults(),
514 minetest.register_node("default:wood", {
515 description = "Wooden Planks",
516 tiles = {"default_wood.png"},
517 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
518 sounds = default.node_sound_wood_defaults(),
521 minetest.register_node("default:cloud", {
522 description = "Cloud",
523 tiles = {"default_cloud.png"},
524 sounds = default.node_sound_defaults(),
525 groups = {not_in_creative_inventory=1},
528 minetest.register_node("default:water_flowing", {
529 description = "Flowing Water",
530 inventory_image = minetest.inventorycube("default_water.png"),
531 drawtype = "flowingliquid",
532 tiles = {"default_water.png"},
535 image="default_water_flowing_animated.png",
536 backface_culling=false,
537 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
540 image="default_water_flowing_animated.png",
541 backface_culling=true,
542 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
547 paramtype2 = "flowingliquid",
554 liquidtype = "flowing",
555 liquid_alternative_flowing = "default:water_flowing",
556 liquid_alternative_source = "default:water_source",
557 liquid_viscosity = WATER_VISC,
558 freezemelt = "default:snow",
559 post_effect_color = {a=64, r=100, g=100, b=200},
560 groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1},
563 minetest.register_node("default:water_source", {
564 description = "Water Source",
565 inventory_image = minetest.inventorycube("default_water.png"),
568 {name="default_water_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
571 -- New-style water source material (mostly unused)
573 name="default_water_source_animated.png",
574 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
575 backface_culling = false,
586 liquidtype = "source",
587 liquid_alternative_flowing = "default:water_flowing",
588 liquid_alternative_source = "default:water_source",
589 liquid_viscosity = WATER_VISC,
590 freezemelt = "default:ice",
591 post_effect_color = {a=64, r=100, g=100, b=200},
592 groups = {water=3, liquid=3, puts_out_fire=1, freezes=1},
595 minetest.register_node("default:lava_flowing", {
596 description = "Flowing Lava",
597 inventory_image = minetest.inventorycube("default_lava.png"),
598 drawtype = "flowingliquid",
599 tiles = {"default_lava.png"},
602 image="default_lava_flowing_animated.png",
603 backface_culling=false,
604 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
607 image="default_lava_flowing_animated.png",
608 backface_culling=true,
609 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
613 paramtype2 = "flowingliquid",
614 light_source = LIGHT_MAX - 1,
621 liquidtype = "flowing",
622 liquid_alternative_flowing = "default:lava_flowing",
623 liquid_alternative_source = "default:lava_source",
624 liquid_viscosity = LAVA_VISC,
625 liquid_renewable = false,
626 damage_per_second = 4*2,
627 post_effect_color = {a=192, r=255, g=64, b=0},
628 groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},
631 minetest.register_node("default:lava_source", {
632 description = "Lava Source",
633 inventory_image = minetest.inventorycube("default_lava.png"),
636 {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
639 -- New-style lava source material (mostly unused)
641 name="default_lava_source_animated.png",
642 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0},
643 backface_culling = false,
647 light_source = LIGHT_MAX - 1,
654 liquidtype = "source",
655 liquid_alternative_flowing = "default:lava_flowing",
656 liquid_alternative_source = "default:lava_source",
657 liquid_viscosity = LAVA_VISC,
658 liquid_renewable = false,
659 damage_per_second = 4*2,
660 post_effect_color = {a=192, r=255, g=64, b=0},
661 groups = {lava=3, liquid=2, hot=3, igniter=1},
664 minetest.register_node("default:torch", {
665 description = "Torch",
666 drawtype = "torchlike",
667 --tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
669 {name="default_torch_on_floor_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
670 {name="default_torch_on_ceiling_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
671 {name="default_torch_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
673 inventory_image = "default_torch_on_floor.png",
674 wield_image = "default_torch_on_floor.png",
676 paramtype2 = "wallmounted",
677 sunlight_propagates = true,
678 is_ground_content = false,
680 light_source = LIGHT_MAX-1,
682 type = "wallmounted",
683 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
684 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
685 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
687 groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1,hot=2},
688 legacy_wallmounted = true,
689 sounds = default.node_sound_defaults(),
692 minetest.register_node("default:sign_wall", {
693 description = "Sign",
694 drawtype = "signlike",
695 tiles = {"default_sign_wall.png"},
696 inventory_image = "default_sign_wall.png",
697 wield_image = "default_sign_wall.png",
699 paramtype2 = "wallmounted",
700 sunlight_propagates = true,
701 is_ground_content = false,
704 type = "wallmounted",
705 --wall_top = <default>
706 --wall_bottom = <default>
707 --wall_side = <default>
709 groups = {choppy=2,dig_immediate=2,attached_node=1},
710 legacy_wallmounted = true,
711 sounds = default.node_sound_defaults(),
712 on_construct = function(pos)
713 --local n = minetest.get_node(pos)
714 local meta = minetest.get_meta(pos)
715 meta:set_string("formspec", "field[text;;${text}]")
716 meta:set_string("infotext", "\"\"")
718 on_receive_fields = function(pos, formname, fields, sender)
719 --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
720 if minetest.is_protected(pos, sender:get_player_name()) then
721 minetest.record_protection_violation(pos, sender:get_player_name())
724 local meta = minetest.get_meta(pos)
725 fields.text = fields.text or ""
726 minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
727 "\" to sign at "..minetest.pos_to_string(pos))
728 meta:set_string("text", fields.text)
729 meta:set_string("infotext", '"'..fields.text..'"')
733 default.chest_formspec =
738 "list[current_name;main;0,0.3;8,4;]"..
739 "list[current_player;main;0,4.85;8,1;]"..
740 "list[current_player;main;0,6.08;8,3;8]"..
741 default.get_hotbar_bg(0,4.85)
743 function default.get_locked_chest_formspec(pos)
744 local spos = pos.x .. "," .. pos.y .. "," ..pos.z
750 "list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"..
751 "list[current_player;main;0,4.85;8,1;]"..
752 "list[current_player;main;0,6.08;8,3;8]"..
753 default.get_hotbar_bg(0,4.85)
758 minetest.register_node("default:chest", {
759 description = "Chest",
760 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
761 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
762 paramtype2 = "facedir",
763 groups = {choppy=2,oddly_breakable_by_hand=2},
764 legacy_facedir_simple = true,
765 is_ground_content = false,
766 sounds = default.node_sound_wood_defaults(),
767 on_construct = function(pos)
768 local meta = minetest.get_meta(pos)
769 meta:set_string("formspec",default.chest_formspec)
770 meta:set_string("infotext", "Chest")
771 local inv = meta:get_inventory()
772 inv:set_size("main", 8*4)
774 can_dig = function(pos,player)
775 local meta = minetest.get_meta(pos);
776 local inv = meta:get_inventory()
777 return inv:is_empty("main")
779 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
780 minetest.log("action", player:get_player_name()..
781 " moves stuff in chest at "..minetest.pos_to_string(pos))
783 on_metadata_inventory_put = function(pos, listname, index, stack, player)
784 minetest.log("action", player:get_player_name()..
785 " moves stuff to chest at "..minetest.pos_to_string(pos))
787 on_metadata_inventory_take = function(pos, listname, index, stack, player)
788 minetest.log("action", player:get_player_name()..
789 " takes stuff from chest at "..minetest.pos_to_string(pos))
793 local function has_locked_chest_privilege(meta, player)
794 if player:get_player_name() ~= meta:get_string("owner") then
800 minetest.register_node("default:chest_locked", {
801 description = "Locked Chest",
802 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
803 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
804 paramtype2 = "facedir",
805 groups = {choppy=2,oddly_breakable_by_hand=2},
806 legacy_facedir_simple = true,
807 is_ground_content = false,
808 sounds = default.node_sound_wood_defaults(),
809 after_place_node = function(pos, placer)
810 local meta = minetest.get_meta(pos)
811 meta:set_string("owner", placer:get_player_name() or "")
812 meta:set_string("infotext", "Locked Chest (owned by "..
813 meta:get_string("owner")..")")
815 on_construct = function(pos)
816 local meta = minetest.get_meta(pos)
817 meta:set_string("infotext", "Locked Chest")
818 meta:set_string("owner", "")
819 local inv = meta:get_inventory()
820 inv:set_size("main", 8*4)
822 can_dig = function(pos,player)
823 local meta = minetest.get_meta(pos);
824 local inv = meta:get_inventory()
825 return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
827 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
828 local meta = minetest.get_meta(pos)
829 if not has_locked_chest_privilege(meta, player) then
830 minetest.log("action", player:get_player_name()..
831 " tried to access a locked chest belonging to "..
832 meta:get_string("owner").." at "..
833 minetest.pos_to_string(pos))
838 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
839 local meta = minetest.get_meta(pos)
840 if not has_locked_chest_privilege(meta, player) then
841 minetest.log("action", player:get_player_name()..
842 " tried to access a locked chest belonging to "..
843 meta:get_string("owner").." at "..
844 minetest.pos_to_string(pos))
847 return stack:get_count()
849 allow_metadata_inventory_take = function(pos, listname, index, stack, player)
850 local meta = minetest.get_meta(pos)
851 if not has_locked_chest_privilege(meta, player) then
852 minetest.log("action", player:get_player_name()..
853 " tried to access a locked chest belonging to "..
854 meta:get_string("owner").." at "..
855 minetest.pos_to_string(pos))
858 return stack:get_count()
860 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
861 minetest.log("action", player:get_player_name()..
862 " moves stuff in locked chest at "..minetest.pos_to_string(pos))
864 on_metadata_inventory_put = function(pos, listname, index, stack, player)
865 minetest.log("action", player:get_player_name()..
866 " moves stuff to locked chest at "..minetest.pos_to_string(pos))
868 on_metadata_inventory_take = function(pos, listname, index, stack, player)
869 minetest.log("action", player:get_player_name()..
870 " takes stuff from locked chest at "..minetest.pos_to_string(pos))
872 on_rightclick = function(pos, node, clicker)
873 local meta = minetest.get_meta(pos)
874 if has_locked_chest_privilege(meta, clicker) then
875 minetest.show_formspec(
876 clicker:get_player_name(),
877 "default:chest_locked",
878 default.get_locked_chest_formspec(pos)
884 function default.furnace_active(pos, percent, item_percent)
890 "list[current_name;src;2.75,0.5;1,1;]"..
891 "list[current_name;fuel;2.75,2.5;1,1;]"..
892 "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
893 (100-percent)..":default_furnace_fire_fg.png]"..
894 "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
895 (item_percent*100)..":gui_furnace_arrow_fg.png^[transformR270]"..
896 "list[current_name;dst;4.75,0.96;2,2;]"..
897 "list[current_player;main;0,4.25;8,1;]"..
898 "list[current_player;main;0,5.5;8,3;8]"..
899 default.get_hotbar_bg(0,4.25)
903 function default.get_furnace_active_formspec(pos, percent)
904 local meta = minetest.get_meta(pos)local inv = meta:get_inventory()
905 local srclist = inv:get_list("src")
907 local aftercooked = nil
909 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
911 local item_percent = 0
913 item_percent = meta:get_float("src_time")/cooked.time
916 return default.furnace_active(pos, percent, item_percent)
919 default.furnace_inactive_formspec =
924 "list[current_name;src;2.75,0.5;1,1;]"..
925 "list[current_name;fuel;2.75,2.5;1,1;]"..
926 "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
927 "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
928 "list[current_name;dst;4.75,0.96;2,2;]"..
929 "list[current_player;main;0,4.25;8,1;]"..
930 "list[current_player;main;0,5.5;8,3;8]"..
931 default.get_hotbar_bg(0,4.25)
933 minetest.register_node("default:furnace", {
934 description = "Furnace",
935 tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
936 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
937 paramtype2 = "facedir",
939 legacy_facedir_simple = true,
940 is_ground_content = false,
941 sounds = default.node_sound_stone_defaults(),
942 on_construct = function(pos)
943 local meta = minetest.get_meta(pos)
944 meta:set_string("formspec", default.furnace_inactive_formspec)
945 meta:set_string("infotext", "Furnace")
946 local inv = meta:get_inventory()
947 inv:set_size("fuel", 1)
948 inv:set_size("src", 1)
949 inv:set_size("dst", 4)
951 can_dig = function(pos,player)
952 local meta = minetest.get_meta(pos);
953 local inv = meta:get_inventory()
954 if not inv:is_empty("fuel") then
956 elseif not inv:is_empty("dst") then
958 elseif not inv:is_empty("src") then
963 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
964 local meta = minetest.get_meta(pos)
965 local inv = meta:get_inventory()
966 if listname == "fuel" then
967 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
968 if inv:is_empty("src") then
969 meta:set_string("infotext","Furnace is empty")
971 return stack:get_count()
975 elseif listname == "src" then
976 return stack:get_count()
977 elseif listname == "dst" then
981 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
982 local meta = minetest.get_meta(pos)
983 local inv = meta:get_inventory()
984 local stack = inv:get_stack(from_list, from_index)
985 if to_list == "fuel" then
986 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
987 if inv:is_empty("src") then
988 meta:set_string("infotext","Furnace is empty")
994 elseif to_list == "src" then
996 elseif to_list == "dst" then
1002 minetest.register_node("default:furnace_active", {
1003 description = "Furnace",
1005 "default_furnace_top.png",
1006 "default_furnace_bottom.png",
1007 "default_furnace_side.png",
1008 "default_furnace_side.png",
1009 "default_furnace_side.png",
1011 image = "default_furnace_front_active.png",
1012 backface_culling = false,
1014 type = "vertical_frames",
1021 paramtype2 = "facedir",
1023 drop = "default:furnace",
1024 groups = {cracky=2, not_in_creative_inventory=1,hot=1},
1025 legacy_facedir_simple = true,
1026 is_ground_content = false,
1027 sounds = default.node_sound_stone_defaults(),
1028 on_construct = function(pos)
1029 local meta = minetest.get_meta(pos)
1030 meta:set_string("formspec", default.furnace_inactive_formspec)
1031 meta:set_string("infotext", "Furnace");
1032 local inv = meta:get_inventory()
1033 inv:set_size("fuel", 1)
1034 inv:set_size("src", 1)
1035 inv:set_size("dst", 4)
1037 can_dig = function(pos,player)
1038 local meta = minetest.get_meta(pos);
1039 local inv = meta:get_inventory()
1040 if not inv:is_empty("fuel") then
1042 elseif not inv:is_empty("dst") then
1044 elseif not inv:is_empty("src") then
1049 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
1050 local meta = minetest.get_meta(pos)
1051 local inv = meta:get_inventory()
1052 if listname == "fuel" then
1053 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
1054 if inv:is_empty("src") then
1055 meta:set_string("infotext","Furnace is empty")
1057 return stack:get_count()
1061 elseif listname == "src" then
1062 return stack:get_count()
1063 elseif listname == "dst" then
1067 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
1068 local meta = minetest.get_meta(pos)
1069 local inv = meta:get_inventory()
1070 local stack = inv:get_stack(from_list, from_index)
1071 if to_list == "fuel" then
1072 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
1073 if inv:is_empty("src") then
1074 meta:set_string("infotext","Furnace is empty")
1080 elseif to_list == "src" then
1082 elseif to_list == "dst" then
1088 local function swap_node(pos,name)
1089 local node = minetest.get_node(pos)
1090 if node.name == name then
1094 minetest.swap_node(pos,node)
1097 minetest.register_abm({
1098 nodenames = {"default:furnace","default:furnace_active"},
1101 action = function(pos, node, active_object_count, active_object_count_wider)
1102 local meta = minetest.get_meta(pos)
1103 for i, name in ipairs({
1109 if meta:get_string(name) == "" then
1110 meta:set_float(name, 0.0)
1114 local inv = meta:get_inventory()
1116 local srclist = inv:get_list("src")
1121 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
1124 local was_active = false
1126 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
1128 meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
1129 meta:set_float("src_time", meta:get_float("src_time") + 1)
1130 if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
1131 -- check if there's room for output in "dst" list
1132 if inv:room_for_item("dst",cooked.item) then
1133 -- Put result in "dst" list
1134 inv:add_item("dst", cooked.item)
1135 -- take stuff from "src" list
1136 inv:set_stack("src", 1, aftercooked.items[1])
1138 --print("Could not insert '"..cooked.item:to_string().."'")
1140 meta:set_string("src_time", 0)
1144 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
1145 local percent = math.floor(meta:get_float("fuel_time") /
1146 meta:get_float("fuel_totaltime") * 100)
1147 meta:set_string("infotext","Furnace active: "..percent.."%")
1148 swap_node(pos,"default:furnace_active")
1149 meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent))
1156 local fuellist = inv:get_list("fuel")
1157 local srclist = inv:get_list("src")
1160 cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
1163 fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
1166 if not fuel or fuel.time <= 0 then
1167 meta:set_string("infotext","Furnace out of fuel")
1168 swap_node(pos,"default:furnace")
1169 meta:set_string("formspec", default.furnace_inactive_formspec)
1173 if cooked.item:is_empty() then
1175 meta:set_string("infotext","Furnace is empty")
1176 swap_node(pos,"default:furnace")
1177 meta:set_string("formspec", default.furnace_inactive_formspec)
1182 meta:set_string("fuel_totaltime", fuel.time)
1183 meta:set_string("fuel_time", 0)
1185 inv:set_stack("fuel", 1, afterfuel.items[1])
1189 minetest.register_node("default:cobble", {
1190 description = "Cobblestone",
1191 tiles = {"default_cobble.png"},
1192 is_ground_content = true,
1193 groups = {cracky=3, stone=2},
1194 sounds = default.node_sound_stone_defaults(),
1197 minetest.register_node("default:desert_cobble", {
1198 description = "Desert Cobblestone",
1199 tiles = {"default_desert_cobble.png"},
1200 is_ground_content = true,
1201 groups = {cracky=3, stone=2},
1202 sounds = default.node_sound_stone_defaults(),
1205 minetest.register_node("default:mossycobble", {
1206 description = "Mossy Cobblestone",
1207 tiles = {"default_mossycobble.png"},
1208 is_ground_content = true,
1209 groups = {cracky=3},
1210 sounds = default.node_sound_stone_defaults(),
1213 minetest.register_node("default:coalblock", {
1214 description = "Coal Block",
1215 tiles = {"default_coal_block.png"},
1216 is_ground_content = true,
1217 groups = {cracky=3},
1218 sounds = default.node_sound_stone_defaults(),
1221 minetest.register_node("default:steelblock", {
1222 description = "Steel Block",
1223 tiles = {"default_steel_block.png"},
1224 is_ground_content = true,
1225 groups = {cracky=1,level=2},
1226 sounds = default.node_sound_stone_defaults(),
1229 minetest.register_node("default:copperblock", {
1230 description = "Copper Block",
1231 tiles = {"default_copper_block.png"},
1232 is_ground_content = true,
1233 groups = {cracky=1,level=2},
1234 sounds = default.node_sound_stone_defaults(),
1237 minetest.register_node("default:bronzeblock", {
1238 description = "Bronze Block",
1239 tiles = {"default_bronze_block.png"},
1240 is_ground_content = true,
1241 groups = {cracky=1,level=2},
1242 sounds = default.node_sound_stone_defaults(),
1245 minetest.register_node("default:mese", {
1246 description = "Mese Block",
1247 tiles = {"default_mese_block.png"},
1248 is_ground_content = true,
1249 groups = {cracky=1,level=2},
1250 sounds = default.node_sound_stone_defaults(),
1252 minetest.register_alias("default:mese_block", "default:mese")
1254 minetest.register_node("default:goldblock", {
1255 description = "Gold Block",
1256 tiles = {"default_gold_block.png"},
1257 is_ground_content = true,
1258 groups = {cracky=1},
1259 sounds = default.node_sound_stone_defaults(),
1262 minetest.register_node("default:diamondblock", {
1263 description = "Diamond Block",
1264 tiles = {"default_diamond_block.png"},
1265 is_ground_content = true,
1266 groups = {cracky=1,level=3},
1267 sounds = default.node_sound_stone_defaults(),
1270 minetest.register_node("default:obsidian_glass", {
1271 description = "Obsidian Glass",
1272 drawtype = "glasslike",
1273 tiles = {"default_obsidian_glass.png"},
1274 paramtype = "light",
1275 is_ground_content = false,
1276 sunlight_propagates = true,
1277 sounds = default.node_sound_glass_defaults(),
1278 groups = {cracky=3,oddly_breakable_by_hand=3},
1281 minetest.register_node("default:obsidian", {
1282 description = "Obsidian",
1283 tiles = {"default_obsidian.png"},
1284 is_ground_content = true,
1285 sounds = default.node_sound_stone_defaults(),
1286 groups = {cracky=1,level=2},
1289 minetest.register_node("default:nyancat", {
1290 description = "Nyan Cat",
1291 tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1292 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1293 paramtype2 = "facedir",
1294 groups = {cracky=2},
1295 is_ground_content = false,
1296 legacy_facedir_simple = true,
1297 sounds = default.node_sound_defaults(),
1300 minetest.register_node("default:nyancat_rainbow", {
1301 description = "Nyan Cat Rainbow",
1302 tiles = {"default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
1303 "default_nc_rb.png", "default_nc_rb.png"},
1304 paramtype2 = "facedir",
1305 groups = {cracky=2},
1306 is_ground_content = false,
1307 sounds = default.node_sound_defaults(),
1310 minetest.register_node("default:sapling", {
1311 description = "Sapling",
1312 drawtype = "plantlike",
1314 tiles = {"default_sapling.png"},
1315 inventory_image = "default_sapling.png",
1316 wield_image = "default_sapling.png",
1317 paramtype = "light",
1319 is_ground_content = true,
1322 fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
1324 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
1325 sounds = default.node_sound_leaves_defaults(),
1328 minetest.register_node("default:apple", {
1329 description = "Apple",
1330 drawtype = "plantlike",
1332 tiles = {"default_apple.png"},
1333 inventory_image = "default_apple.png",
1334 paramtype = "light",
1335 sunlight_propagates = true,
1337 is_ground_content = true,
1340 fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
1342 groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
1343 on_use = minetest.item_eat(1),
1344 sounds = default.node_sound_leaves_defaults(),
1345 after_place_node = function(pos, placer, itemstack)
1346 if placer:is_player() then
1347 minetest.set_node(pos, {name="default:apple", param2=1})
1352 minetest.register_node("default:dry_shrub", {
1353 description = "Dry Shrub",
1354 drawtype = "plantlike",
1357 tiles = {"default_dry_shrub.png"},
1358 inventory_image = "default_dry_shrub.png",
1359 wield_image = "default_dry_shrub.png",
1360 paramtype = "light",
1362 is_ground_content = true,
1363 buildable_to = true,
1364 groups = {snappy=3,flammable=3,attached_node=1},
1365 sounds = default.node_sound_leaves_defaults(),
1368 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1372 minetest.register_node("default:grass_1", {
1373 description = "Grass",
1374 drawtype = "plantlike",
1376 tiles = {"default_grass_1.png"},
1377 -- use a bigger inventory image
1378 inventory_image = "default_grass_3.png",
1379 wield_image = "default_grass_3.png",
1380 paramtype = "light",
1382 is_ground_content = true,
1383 buildable_to = true,
1384 groups = {snappy=3,flammable=3,flora=1,attached_node=1},
1385 sounds = default.node_sound_leaves_defaults(),
1388 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1390 on_place = function(itemstack, placer, pointed_thing)
1391 -- place a random grass node
1392 local stack = ItemStack("default:grass_"..math.random(1,5))
1393 local ret = minetest.item_place(stack, placer, pointed_thing)
1394 return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
1398 minetest.register_node("default:grass_2", {
1399 description = "Grass",
1400 drawtype = "plantlike",
1402 tiles = {"default_grass_2.png"},
1403 inventory_image = "default_grass_2.png",
1404 wield_image = "default_grass_2.png",
1405 paramtype = "light",
1407 buildable_to = true,
1408 is_ground_content = true,
1409 drop = "default:grass_1",
1410 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1411 sounds = default.node_sound_leaves_defaults(),
1414 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1417 minetest.register_node("default:grass_3", {
1418 description = "Grass",
1419 drawtype = "plantlike",
1421 tiles = {"default_grass_3.png"},
1422 inventory_image = "default_grass_3.png",
1423 wield_image = "default_grass_3.png",
1424 paramtype = "light",
1426 buildable_to = true,
1427 is_ground_content = true,
1428 drop = "default:grass_1",
1429 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1430 sounds = default.node_sound_leaves_defaults(),
1433 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1437 minetest.register_node("default:grass_4", {
1438 description = "Grass",
1439 drawtype = "plantlike",
1441 tiles = {"default_grass_4.png"},
1442 inventory_image = "default_grass_4.png",
1443 wield_image = "default_grass_4.png",
1444 paramtype = "light",
1446 buildable_to = true,
1447 is_ground_content = true,
1448 drop = "default:grass_1",
1449 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1450 sounds = default.node_sound_leaves_defaults(),
1453 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1457 minetest.register_node("default:grass_5", {
1458 description = "Grass",
1459 drawtype = "plantlike",
1461 tiles = {"default_grass_5.png"},
1462 inventory_image = "default_grass_5.png",
1463 wield_image = "default_grass_5.png",
1464 paramtype = "light",
1466 buildable_to = true,
1467 is_ground_content = true,
1468 drop = "default:grass_1",
1469 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1470 sounds = default.node_sound_leaves_defaults(),
1473 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1477 minetest.register_node("default:ice", {
1478 description = "Ice",
1479 tiles = {"default_ice.png"},
1480 is_ground_content = true,
1481 paramtype = "light",
1482 freezemelt = "default:water_source",
1483 groups = {cracky=3, melts=1},
1484 sounds = default.node_sound_glass_defaults(),
1487 minetest.register_node("default:snow", {
1488 description = "Snow",
1489 tiles = {"default_snow.png"},
1490 inventory_image = "default_snowball.png",
1491 wield_image = "default_snowball.png",
1492 is_ground_content = true,
1493 paramtype = "light",
1494 buildable_to = true,
1496 drawtype = "nodebox",
1497 freezemelt = "default:water_flowing",
1501 {-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
1504 groups = {crumbly=3,falling_node=1, melts=1, float=1},
1505 sounds = default.node_sound_dirt_defaults({
1506 footstep = {name="default_snow_footstep", gain=0.25},
1507 dug = {name="default_snow_footstep", gain=0.75},
1509 on_construct = function(pos)
1511 if minetest.get_node(pos).name == "default:dirt_with_grass" then
1512 minetest.set_node(pos, {name="default:dirt_with_snow"})
1516 minetest.register_alias("snow", "default:snow")
1518 minetest.register_node("default:snowblock", {
1519 description = "Snow Block",
1520 tiles = {"default_snow.png"},
1521 is_ground_content = true,
1522 freezemelt = "default:water_source",
1523 groups = {crumbly=3, melts=1},
1524 sounds = default.node_sound_dirt_defaults({
1525 footstep = {name="default_snow_footstep", gain=0.25},
1526 dug = {name="default_snow_footstep", gain=0.75},