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 local fence_texture = "default_fence_overlay.png^default_wood.png^default_fence_overlay.png^[makealpha:255,126,126"
460 minetest.register_node("default:fence_wood", {
461 description = "Wooden Fence",
462 drawtype = "fencelike",
463 tiles = {"default_wood.png"},
464 inventory_image = fence_texture,
465 wield_image = fence_texture,
467 is_ground_content = false,
470 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
472 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
473 sounds = default.node_sound_wood_defaults(),
476 minetest.register_node("default:rail", {
477 description = "Rail",
478 drawtype = "raillike",
479 tiles = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
480 inventory_image = "default_rail.png",
481 wield_image = "default_rail.png",
484 is_ground_content = false,
487 -- but how to specify the dimensions for curved and sideways rails?
488 fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
490 groups = {bendy=2,dig_immediate=2,attached_node=1},
493 minetest.register_node("default:ladder", {
494 description = "Ladder",
495 drawtype = "signlike",
496 tiles = {"default_ladder.png"},
497 inventory_image = "default_ladder.png",
498 wield_image = "default_ladder.png",
500 paramtype2 = "wallmounted",
503 is_ground_content = false,
505 type = "wallmounted",
506 --wall_top = = <default>
507 --wall_bottom = = <default>
508 --wall_side = = <default>
510 groups = {choppy=2,oddly_breakable_by_hand=3,flammable=2},
511 legacy_wallmounted = true,
512 sounds = default.node_sound_wood_defaults(),
515 minetest.register_node("default:wood", {
516 description = "Wooden Planks",
517 tiles = {"default_wood.png"},
518 groups = {choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
519 sounds = default.node_sound_wood_defaults(),
522 minetest.register_node("default:cloud", {
523 description = "Cloud",
524 tiles = {"default_cloud.png"},
525 sounds = default.node_sound_defaults(),
526 groups = {not_in_creative_inventory=1},
529 minetest.register_node("default:water_flowing", {
530 description = "Flowing Water",
531 inventory_image = minetest.inventorycube("default_water.png"),
532 drawtype = "flowingliquid",
533 tiles = {"default_water.png"},
536 image="default_water_flowing_animated.png",
537 backface_culling=false,
538 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
541 image="default_water_flowing_animated.png",
542 backface_culling=true,
543 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8}
548 paramtype2 = "flowingliquid",
555 liquidtype = "flowing",
556 liquid_alternative_flowing = "default:water_flowing",
557 liquid_alternative_source = "default:water_source",
558 liquid_viscosity = WATER_VISC,
559 freezemelt = "default:snow",
560 post_effect_color = {a=64, r=100, g=100, b=200},
561 groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1, freezes=1, melt_around=1},
564 minetest.register_node("default:water_source", {
565 description = "Water Source",
566 inventory_image = minetest.inventorycube("default_water.png"),
569 {name="default_water_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0}}
572 -- New-style water source material (mostly unused)
574 name="default_water_source_animated.png",
575 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=2.0},
576 backface_culling = false,
587 liquidtype = "source",
588 liquid_alternative_flowing = "default:water_flowing",
589 liquid_alternative_source = "default:water_source",
590 liquid_viscosity = WATER_VISC,
591 freezemelt = "default:ice",
592 post_effect_color = {a=64, r=100, g=100, b=200},
593 groups = {water=3, liquid=3, puts_out_fire=1, freezes=1},
596 minetest.register_node("default:lava_flowing", {
597 description = "Flowing Lava",
598 inventory_image = minetest.inventorycube("default_lava.png"),
599 drawtype = "flowingliquid",
600 tiles = {"default_lava.png"},
603 image="default_lava_flowing_animated.png",
604 backface_culling=false,
605 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
608 image="default_lava_flowing_animated.png",
609 backface_culling=true,
610 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.3}
614 paramtype2 = "flowingliquid",
615 light_source = LIGHT_MAX - 1,
622 liquidtype = "flowing",
623 liquid_alternative_flowing = "default:lava_flowing",
624 liquid_alternative_source = "default:lava_source",
625 liquid_viscosity = LAVA_VISC,
626 liquid_renewable = false,
627 damage_per_second = 4*2,
628 post_effect_color = {a=192, r=255, g=64, b=0},
629 groups = {lava=3, liquid=2, hot=3, igniter=1, not_in_creative_inventory=1},
632 minetest.register_node("default:lava_source", {
633 description = "Lava Source",
634 inventory_image = minetest.inventorycube("default_lava.png"),
637 {name="default_lava_source_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
640 -- New-style lava source material (mostly unused)
642 name="default_lava_source_animated.png",
643 animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0},
644 backface_culling = false,
648 light_source = LIGHT_MAX - 1,
655 liquidtype = "source",
656 liquid_alternative_flowing = "default:lava_flowing",
657 liquid_alternative_source = "default:lava_source",
658 liquid_viscosity = LAVA_VISC,
659 liquid_renewable = false,
660 damage_per_second = 4*2,
661 post_effect_color = {a=192, r=255, g=64, b=0},
662 groups = {lava=3, liquid=2, hot=3, igniter=1},
665 minetest.register_node("default:torch", {
666 description = "Torch",
667 drawtype = "torchlike",
668 --tiles = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
670 {name="default_torch_on_floor_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
671 {name="default_torch_on_ceiling_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}},
672 {name="default_torch_animated.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}
674 inventory_image = "default_torch_on_floor.png",
675 wield_image = "default_torch_on_floor.png",
677 paramtype2 = "wallmounted",
678 sunlight_propagates = true,
679 is_ground_content = false,
681 light_source = LIGHT_MAX-1,
683 type = "wallmounted",
684 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
685 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
686 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
688 groups = {choppy=2,dig_immediate=3,flammable=1,attached_node=1,hot=2},
689 legacy_wallmounted = true,
690 sounds = default.node_sound_defaults(),
693 minetest.register_node("default:sign_wall", {
694 description = "Sign",
695 drawtype = "signlike",
696 tiles = {"default_sign_wall.png"},
697 inventory_image = "default_sign_wall.png",
698 wield_image = "default_sign_wall.png",
700 paramtype2 = "wallmounted",
701 sunlight_propagates = true,
702 is_ground_content = false,
705 type = "wallmounted",
706 --wall_top = <default>
707 --wall_bottom = <default>
708 --wall_side = <default>
710 groups = {choppy=2,dig_immediate=2,attached_node=1},
711 legacy_wallmounted = true,
712 sounds = default.node_sound_defaults(),
713 on_construct = function(pos)
714 --local n = minetest.get_node(pos)
715 local meta = minetest.get_meta(pos)
716 meta:set_string("formspec", "field[text;;${text}]")
717 meta:set_string("infotext", "\"\"")
719 on_receive_fields = function(pos, formname, fields, sender)
720 --print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
721 if minetest.is_protected(pos, sender:get_player_name()) then
722 minetest.record_protection_violation(pos, sender:get_player_name())
725 local meta = minetest.get_meta(pos)
726 if not fields.text then return end
727 minetest.log("action", (sender:get_player_name() or "").." wrote \""..fields.text..
728 "\" to sign at "..minetest.pos_to_string(pos))
729 meta:set_string("text", fields.text)
730 meta:set_string("infotext", '"'..fields.text..'"')
734 default.chest_formspec =
739 "list[current_name;main;0,0.3;8,4;]"..
740 "list[current_player;main;0,4.85;8,1;]"..
741 "list[current_player;main;0,6.08;8,3;8]"..
742 default.get_hotbar_bg(0,4.85)
744 function default.get_locked_chest_formspec(pos)
745 local spos = pos.x .. "," .. pos.y .. "," ..pos.z
751 "list[nodemeta:".. spos .. ";main;0,0.3;8,4;]"..
752 "list[current_player;main;0,4.85;8,1;]"..
753 "list[current_player;main;0,6.08;8,3;8]"..
754 default.get_hotbar_bg(0,4.85)
759 minetest.register_node("default:chest", {
760 description = "Chest",
761 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
762 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
763 paramtype2 = "facedir",
764 groups = {choppy=2,oddly_breakable_by_hand=2},
765 legacy_facedir_simple = true,
766 is_ground_content = false,
767 sounds = default.node_sound_wood_defaults(),
768 on_construct = function(pos)
769 local meta = minetest.get_meta(pos)
770 meta:set_string("formspec",default.chest_formspec)
771 meta:set_string("infotext", "Chest")
772 local inv = meta:get_inventory()
773 inv:set_size("main", 8*4)
775 can_dig = function(pos,player)
776 local meta = minetest.get_meta(pos);
777 local inv = meta:get_inventory()
778 return inv:is_empty("main")
780 on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
781 minetest.log("action", player:get_player_name()..
782 " moves stuff in chest at "..minetest.pos_to_string(pos))
784 on_metadata_inventory_put = function(pos, listname, index, stack, player)
785 minetest.log("action", player:get_player_name()..
786 " moves stuff to chest at "..minetest.pos_to_string(pos))
788 on_metadata_inventory_take = function(pos, listname, index, stack, player)
789 minetest.log("action", player:get_player_name()..
790 " takes stuff from chest at "..minetest.pos_to_string(pos))
794 local function has_locked_chest_privilege(meta, player)
795 if player:get_player_name() ~= meta:get_string("owner") then
801 minetest.register_node("default:chest_locked", {
802 description = "Locked Chest",
803 tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
804 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
805 paramtype2 = "facedir",
806 groups = {choppy=2,oddly_breakable_by_hand=2},
807 legacy_facedir_simple = true,
808 is_ground_content = false,
809 sounds = default.node_sound_wood_defaults(),
810 after_place_node = function(pos, placer)
811 local meta = minetest.get_meta(pos)
812 meta:set_string("owner", placer:get_player_name() or "")
813 meta:set_string("infotext", "Locked Chest (owned by "..
814 meta:get_string("owner")..")")
816 on_construct = function(pos)
817 local meta = minetest.get_meta(pos)
818 meta:set_string("infotext", "Locked Chest")
819 meta:set_string("owner", "")
820 local inv = meta:get_inventory()
821 inv:set_size("main", 8*4)
823 can_dig = function(pos,player)
824 local meta = minetest.get_meta(pos);
825 local inv = meta:get_inventory()
826 return inv:is_empty("main") and has_locked_chest_privilege(meta, player)
828 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
829 local meta = minetest.get_meta(pos)
830 if not has_locked_chest_privilege(meta, player) then
835 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
836 local meta = minetest.get_meta(pos)
837 if not has_locked_chest_privilege(meta, player) then
840 return stack:get_count()
842 allow_metadata_inventory_take = function(pos, listname, index, stack, player)
843 local meta = minetest.get_meta(pos)
844 if not has_locked_chest_privilege(meta, player) then
847 return stack:get_count()
849 on_metadata_inventory_put = function(pos, listname, index, stack, player)
850 minetest.log("action", player:get_player_name()..
851 " moves stuff to locked chest at "..minetest.pos_to_string(pos))
853 on_metadata_inventory_take = function(pos, listname, index, stack, player)
854 minetest.log("action", player:get_player_name()..
855 " takes stuff from locked chest at "..minetest.pos_to_string(pos))
857 on_rightclick = function(pos, node, clicker)
858 local meta = minetest.get_meta(pos)
859 if has_locked_chest_privilege(meta, clicker) then
860 minetest.show_formspec(
861 clicker:get_player_name(),
862 "default:chest_locked",
863 default.get_locked_chest_formspec(pos)
869 function default.furnace_active(pos, percent, item_percent)
875 "list[current_name;src;2.75,0.5;1,1;]"..
876 "list[current_name;fuel;2.75,2.5;1,1;]"..
877 "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
878 (100-percent)..":default_furnace_fire_fg.png]"..
879 "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
880 (item_percent*100)..":gui_furnace_arrow_fg.png^[transformR270]"..
881 "list[current_name;dst;4.75,0.96;2,2;]"..
882 "list[current_player;main;0,4.25;8,1;]"..
883 "list[current_player;main;0,5.5;8,3;8]"..
884 default.get_hotbar_bg(0,4.25)
888 function default.get_furnace_active_formspec(pos, percent)
889 local meta = minetest.get_meta(pos)local inv = meta:get_inventory()
890 local srclist = inv:get_list("src")
892 local aftercooked = nil
894 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
896 local item_percent = 0
898 item_percent = meta:get_float("src_time")/cooked.time
901 return default.furnace_active(pos, percent, item_percent)
904 default.furnace_inactive_formspec =
909 "list[current_name;src;2.75,0.5;1,1;]"..
910 "list[current_name;fuel;2.75,2.5;1,1;]"..
911 "image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
912 "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
913 "list[current_name;dst;4.75,0.96;2,2;]"..
914 "list[current_player;main;0,4.25;8,1;]"..
915 "list[current_player;main;0,5.5;8,3;8]"..
916 default.get_hotbar_bg(0,4.25)
918 minetest.register_node("default:furnace", {
919 description = "Furnace",
920 tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png",
921 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
922 paramtype2 = "facedir",
924 legacy_facedir_simple = true,
925 is_ground_content = false,
926 sounds = default.node_sound_stone_defaults(),
927 on_construct = function(pos)
928 local meta = minetest.get_meta(pos)
929 meta:set_string("formspec", default.furnace_inactive_formspec)
930 meta:set_string("infotext", "Furnace")
931 local inv = meta:get_inventory()
932 inv:set_size("fuel", 1)
933 inv:set_size("src", 1)
934 inv:set_size("dst", 4)
936 can_dig = function(pos,player)
937 local meta = minetest.get_meta(pos);
938 local inv = meta:get_inventory()
939 if not inv:is_empty("fuel") then
941 elseif not inv:is_empty("dst") then
943 elseif not inv:is_empty("src") then
948 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
949 if minetest.is_protected(pos, player:get_player_name()) then
952 local meta = minetest.get_meta(pos)
953 local inv = meta:get_inventory()
954 if listname == "fuel" then
955 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
956 if inv:is_empty("src") then
957 meta:set_string("infotext","Furnace is empty")
959 return stack:get_count()
963 elseif listname == "src" then
964 return stack:get_count()
965 elseif listname == "dst" then
969 allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
970 if minetest.is_protected(pos, player:get_player_name()) then
973 local meta = minetest.get_meta(pos)
974 local inv = meta:get_inventory()
975 local stack = inv:get_stack(from_list, from_index)
976 if to_list == "fuel" then
977 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
978 if inv:is_empty("src") then
979 meta:set_string("infotext","Furnace is empty")
985 elseif to_list == "src" then
987 elseif to_list == "dst" then
991 allow_metadata_inventory_take = function(pos, listname, index, stack, player)
992 if minetest.is_protected(pos, player:get_player_name()) then
995 return stack:get_count()
999 minetest.register_node("default:furnace_active", {
1000 description = "Furnace",
1002 "default_furnace_top.png",
1003 "default_furnace_bottom.png",
1004 "default_furnace_side.png",
1005 "default_furnace_side.png",
1006 "default_furnace_side.png",
1008 image = "default_furnace_front_active.png",
1009 backface_culling = false,
1011 type = "vertical_frames",
1018 paramtype2 = "facedir",
1020 drop = "default:furnace",
1021 groups = {cracky=2, not_in_creative_inventory=1,hot=1},
1022 legacy_facedir_simple = true,
1023 is_ground_content = false,
1024 sounds = default.node_sound_stone_defaults(),
1025 on_construct = function(pos)
1026 local meta = minetest.get_meta(pos)
1027 meta:set_string("formspec", default.furnace_inactive_formspec)
1028 meta:set_string("infotext", "Furnace");
1029 local inv = meta:get_inventory()
1030 inv:set_size("fuel", 1)
1031 inv:set_size("src", 1)
1032 inv:set_size("dst", 4)
1034 can_dig = function(pos,player)
1035 local meta = minetest.get_meta(pos);
1036 local inv = meta:get_inventory()
1037 if not inv:is_empty("fuel") then
1039 elseif not inv:is_empty("dst") then
1041 elseif not inv:is_empty("src") then
1046 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
1047 if minetest.is_protected(pos, player:get_player_name()) then
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 if minetest.is_protected(pos, player:get_player_name()) then
1071 local meta = minetest.get_meta(pos)
1072 local inv = meta:get_inventory()
1073 local stack = inv:get_stack(from_list, from_index)
1074 if to_list == "fuel" then
1075 if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
1076 if inv:is_empty("src") then
1077 meta:set_string("infotext","Furnace is empty")
1083 elseif to_list == "src" then
1085 elseif to_list == "dst" then
1089 allow_metadata_inventory_take = function(pos, listname, index, stack, player)
1090 if minetest.is_protected(pos, player:get_player_name()) then
1093 return stack:get_count()
1097 local function swap_node(pos,name)
1098 local node = minetest.get_node(pos)
1099 if node.name == name then
1103 minetest.swap_node(pos,node)
1106 minetest.register_abm({
1107 nodenames = {"default:furnace","default:furnace_active"},
1110 action = function(pos, node, active_object_count, active_object_count_wider)
1111 local meta = minetest.get_meta(pos)
1112 for i, name in ipairs({
1118 if meta:get_string(name) == "" then
1119 meta:set_float(name, 0.0)
1123 local inv = meta:get_inventory()
1125 local srclist = inv:get_list("src")
1130 cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
1133 local was_active = false
1135 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
1137 meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
1138 meta:set_float("src_time", meta:get_float("src_time") + 1)
1139 if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
1140 -- check if there's room for output in "dst" list
1141 if inv:room_for_item("dst",cooked.item) then
1142 -- Put result in "dst" list
1143 inv:add_item("dst", cooked.item)
1144 -- take stuff from "src" list
1145 inv:set_stack("src", 1, aftercooked.items[1])
1147 --print("Could not insert '"..cooked.item:to_string().."'")
1149 meta:set_string("src_time", 0)
1153 if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
1154 local percent = math.floor(meta:get_float("fuel_time") /
1155 meta:get_float("fuel_totaltime") * 100)
1156 meta:set_string("infotext","Furnace active: "..percent.."%")
1157 swap_node(pos,"default:furnace_active")
1158 meta:set_string("formspec",default.get_furnace_active_formspec(pos, percent))
1165 local fuellist = inv:get_list("fuel")
1166 local srclist = inv:get_list("src")
1169 cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
1172 fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
1175 if not fuel or fuel.time <= 0 then
1176 meta:set_string("infotext","Furnace out of fuel")
1177 swap_node(pos,"default:furnace")
1178 meta:set_string("formspec", default.furnace_inactive_formspec)
1182 if cooked.item:is_empty() then
1184 meta:set_string("infotext","Furnace is empty")
1185 swap_node(pos,"default:furnace")
1186 meta:set_string("formspec", default.furnace_inactive_formspec)
1191 meta:set_string("fuel_totaltime", fuel.time)
1192 meta:set_string("fuel_time", 0)
1194 inv:set_stack("fuel", 1, afterfuel.items[1])
1198 minetest.register_node("default:cobble", {
1199 description = "Cobblestone",
1200 tiles = {"default_cobble.png"},
1201 is_ground_content = true,
1202 groups = {cracky=3, stone=2},
1203 sounds = default.node_sound_stone_defaults(),
1206 minetest.register_node("default:desert_cobble", {
1207 description = "Desert Cobblestone",
1208 tiles = {"default_desert_cobble.png"},
1209 is_ground_content = true,
1210 groups = {cracky=3, stone=2},
1211 sounds = default.node_sound_stone_defaults(),
1214 minetest.register_node("default:mossycobble", {
1215 description = "Mossy Cobblestone",
1216 tiles = {"default_mossycobble.png"},
1217 is_ground_content = true,
1218 groups = {cracky=3},
1219 sounds = default.node_sound_stone_defaults(),
1222 minetest.register_node("default:coalblock", {
1223 description = "Coal Block",
1224 tiles = {"default_coal_block.png"},
1225 is_ground_content = true,
1226 groups = {cracky=3},
1227 sounds = default.node_sound_stone_defaults(),
1230 minetest.register_node("default:steelblock", {
1231 description = "Steel Block",
1232 tiles = {"default_steel_block.png"},
1233 is_ground_content = true,
1234 groups = {cracky=1,level=2},
1235 sounds = default.node_sound_stone_defaults(),
1238 minetest.register_node("default:copperblock", {
1239 description = "Copper Block",
1240 tiles = {"default_copper_block.png"},
1241 is_ground_content = true,
1242 groups = {cracky=1,level=2},
1243 sounds = default.node_sound_stone_defaults(),
1246 minetest.register_node("default:bronzeblock", {
1247 description = "Bronze Block",
1248 tiles = {"default_bronze_block.png"},
1249 is_ground_content = true,
1250 groups = {cracky=1,level=2},
1251 sounds = default.node_sound_stone_defaults(),
1254 minetest.register_node("default:mese", {
1255 description = "Mese Block",
1256 tiles = {"default_mese_block.png"},
1257 is_ground_content = true,
1258 groups = {cracky=1,level=2},
1259 sounds = default.node_sound_stone_defaults(),
1261 minetest.register_alias("default:mese_block", "default:mese")
1263 minetest.register_node("default:goldblock", {
1264 description = "Gold Block",
1265 tiles = {"default_gold_block.png"},
1266 is_ground_content = true,
1267 groups = {cracky=1},
1268 sounds = default.node_sound_stone_defaults(),
1271 minetest.register_node("default:diamondblock", {
1272 description = "Diamond Block",
1273 tiles = {"default_diamond_block.png"},
1274 is_ground_content = true,
1275 groups = {cracky=1,level=3},
1276 sounds = default.node_sound_stone_defaults(),
1279 minetest.register_node("default:obsidian_glass", {
1280 description = "Obsidian Glass",
1281 drawtype = "glasslike",
1282 tiles = {"default_obsidian_glass.png"},
1283 paramtype = "light",
1284 is_ground_content = false,
1285 sunlight_propagates = true,
1286 sounds = default.node_sound_glass_defaults(),
1287 groups = {cracky=3,oddly_breakable_by_hand=3},
1290 minetest.register_node("default:obsidian", {
1291 description = "Obsidian",
1292 tiles = {"default_obsidian.png"},
1293 is_ground_content = true,
1294 sounds = default.node_sound_stone_defaults(),
1295 groups = {cracky=1,level=2},
1298 minetest.register_node("default:nyancat", {
1299 description = "Nyan Cat",
1300 tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1301 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1302 paramtype2 = "facedir",
1303 groups = {cracky=2},
1304 is_ground_content = false,
1305 legacy_facedir_simple = true,
1306 sounds = default.node_sound_defaults(),
1309 minetest.register_node("default:nyancat_rainbow", {
1310 description = "Nyan Cat Rainbow",
1311 tiles = {"default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
1312 "default_nc_rb.png", "default_nc_rb.png"},
1313 paramtype2 = "facedir",
1314 groups = {cracky=2},
1315 is_ground_content = false,
1316 sounds = default.node_sound_defaults(),
1319 minetest.register_node("default:sapling", {
1320 description = "Sapling",
1321 drawtype = "plantlike",
1323 tiles = {"default_sapling.png"},
1324 inventory_image = "default_sapling.png",
1325 wield_image = "default_sapling.png",
1326 paramtype = "light",
1328 is_ground_content = true,
1331 fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
1333 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
1334 sounds = default.node_sound_leaves_defaults(),
1337 minetest.register_node("default:apple", {
1338 description = "Apple",
1339 drawtype = "plantlike",
1341 tiles = {"default_apple.png"},
1342 inventory_image = "default_apple.png",
1343 paramtype = "light",
1344 sunlight_propagates = true,
1346 is_ground_content = true,
1349 fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
1351 groups = {fleshy=3,dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1},
1352 on_use = minetest.item_eat(1),
1353 sounds = default.node_sound_leaves_defaults(),
1354 after_place_node = function(pos, placer, itemstack)
1355 if placer:is_player() then
1356 minetest.set_node(pos, {name="default:apple", param2=1})
1361 minetest.register_node("default:dry_shrub", {
1362 description = "Dry Shrub",
1363 drawtype = "plantlike",
1366 tiles = {"default_dry_shrub.png"},
1367 inventory_image = "default_dry_shrub.png",
1368 wield_image = "default_dry_shrub.png",
1369 paramtype = "light",
1371 is_ground_content = true,
1372 buildable_to = true,
1373 groups = {snappy=3,flammable=3,attached_node=1},
1374 sounds = default.node_sound_leaves_defaults(),
1377 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1381 minetest.register_node("default:grass_1", {
1382 description = "Grass",
1383 drawtype = "plantlike",
1385 tiles = {"default_grass_1.png"},
1386 -- use a bigger inventory image
1387 inventory_image = "default_grass_3.png",
1388 wield_image = "default_grass_3.png",
1389 paramtype = "light",
1391 is_ground_content = true,
1392 buildable_to = true,
1393 groups = {snappy=3,flammable=3,flora=1,attached_node=1},
1394 sounds = default.node_sound_leaves_defaults(),
1397 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1399 on_place = function(itemstack, placer, pointed_thing)
1400 -- place a random grass node
1401 local stack = ItemStack("default:grass_"..math.random(1,5))
1402 local ret = minetest.item_place(stack, placer, pointed_thing)
1403 return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
1408 minetest.register_node("default:grass_"..i, {
1409 description = "Grass",
1410 drawtype = "plantlike",
1412 tiles = {"default_grass_"..i..".png"},
1413 inventory_image = "default_grass_"..i..".png",
1414 wield_image = "default_grass_"..i..".png",
1415 paramtype = "light",
1417 buildable_to = true,
1418 is_ground_content = true,
1419 drop = "default:grass_1",
1420 groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
1421 sounds = default.node_sound_leaves_defaults(),
1424 fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
1429 minetest.register_node("default:ice", {
1430 description = "Ice",
1431 tiles = {"default_ice.png"},
1432 is_ground_content = true,
1433 paramtype = "light",
1434 freezemelt = "default:water_source",
1435 groups = {cracky=3, melts=1},
1436 sounds = default.node_sound_glass_defaults(),
1439 minetest.register_node("default:snow", {
1440 description = "Snow",
1441 tiles = {"default_snow.png"},
1442 inventory_image = "default_snowball.png",
1443 wield_image = "default_snowball.png",
1444 is_ground_content = true,
1445 paramtype = "light",
1446 buildable_to = true,
1448 drawtype = "nodebox",
1449 freezemelt = "default:water_flowing",
1453 {-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
1456 groups = {crumbly=3,falling_node=1, melts=1, float=1},
1457 sounds = default.node_sound_dirt_defaults({
1458 footstep = {name="default_snow_footstep", gain=0.25},
1459 dug = {name="default_snow_footstep", gain=0.75},
1461 on_construct = function(pos)
1463 if minetest.get_node(pos).name == "default:dirt_with_grass" then
1464 minetest.set_node(pos, {name="default:dirt_with_snow"})
1468 minetest.register_alias("snow", "default:snow")
1470 minetest.register_node("default:snowblock", {
1471 description = "Snow Block",
1472 tiles = {"default_snow.png"},
1473 is_ground_content = true,
1474 freezemelt = "default:water_source",
1475 groups = {crumbly=3, melts=1},
1476 sounds = default.node_sound_dirt_defaults({
1477 footstep = {name="default_snow_footstep", gain=0.25},
1478 dug = {name="default_snow_footstep", gain=0.75},