1 -- Helper functions defined by builtin.lua:
2 -- dump2(obj, name="_", dumped={})
3 -- dump(obj, dumped={})
6 -- Mods should prefix their textures with modname_, eg. given the mod
7 -- name "foomod", a texture could be called "foomod_superfurnace.png"
8 -- Due to historical reasons, the default mod does not follow this rule.
11 -- minetest.register_entity(name, prototype_table)
12 -- minetest.register_tool(name, {lots of stuff})
13 -- minetest.register_node(name, {lots of stuff})
14 -- minetest.register_craftitem(name, {lots of stuff})
15 -- minetest.register_craft({output=item, recipe={...})
16 -- minetest.register_globalstep(func)
17 -- minetest.register_on_placenode(func(pos, newnode, placer))
18 -- minetest.register_on_dignode(func(pos, oldnode, digger))
19 -- minetest.register_on_punchnode(func(pos, node, puncher))
20 -- minetest.register_on_generated(func(minp, maxp))
21 -- minetest.register_on_newplayer(func(ObjectRef))
22 -- minetest.register_on_respawnplayer(func(ObjectRef))
23 -- ^ return true in func to disable regular player placement
24 -- minetest.register_on_chat_message(func(name, message))
25 -- minetest.setting_get(name)
26 -- minetest.setting_getbool(name)
27 -- minetest.chat_send_all(text)
28 -- minetest.chat_send_player(name, text)
31 -- minetest.env - environment reference
34 -- minetest.registered_nodes
35 -- ^ List of registered node definitions, indexed by name
36 -- minetest.registered_craftitems
37 -- ^ List of registered craft item definitions, indexed by name
38 -- minetest.registered_entities
39 -- ^ List of registered entity prototypes, indexed by name
40 -- minetest.object_refs
41 -- ^ List of object references, indexed by active object id
42 -- minetest.luaentities
43 -- ^ List of lua entities, indexed by active object id
45 -- EnvRef is basically ServerEnvironment and ServerMap combined.
47 -- - add_node(pos, node)
50 -- - add_luaentity(pos, name)
51 -- - add_item(pos, itemstring)
54 -- - get_meta(pos) -- Get a NodeMetaRef at that position
58 -- - allows_text_input()
59 -- - set_text(text) -- eg. set the text of a sign
62 -- - set_infotext(infotext)
63 -- - inventory_set_list(name, {item1, item2, ...})
64 -- - inventory_get_list(name)
65 -- - set_inventory_draw_spec(string)
66 -- - set_allow_text_input(bool)
67 -- - set_allow_removal(bool)
68 -- - set_enforce_owner(bool)
69 -- - is_inventory_modified()
70 -- - reset_inventory_modified()
71 -- - is_text_modified()
72 -- - reset_text_modified()
73 -- - set_string(name, value)
76 -- ObjectRef is basically ServerActiveObject.
78 -- - remove(): remove object (after returning from Lua)
79 -- - getpos(): returns {x=num, y=num, z=num}
80 -- - setpos(pos); pos={x=num, y=num, z=num}
81 -- - moveto(pos, continuous=false): interpolated move
82 -- - add_to_inventory(itemstring): add an item to object inventory
83 -- - add_to_inventory_later(itemstring): like above, but after callback returns (only allowed for craftitem callbacks)
84 -- - get_hp(): returns number of hitpoints (2 * number of hearts)
85 -- - set_hp(hp): set number of hitpoints (2 * number of hearts)
86 -- - settexturemod(mod)
87 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
88 -- - select_horiz_by_yawpitch=false)
90 -- Registered entities:
91 -- - Functions receive a "luaentity" as self:
92 -- - It has the member .object, which is an ObjectRef pointing to the object
93 -- - The original prototype stuff is visible directly via a metatable
95 -- - on_activate(self, staticdata)
96 -- - on_step(self, dtime)
97 -- - on_punch(self, hitter)
98 -- - on_rightclick(self, clicker)
99 -- - get_staticdata(self): return string
101 -- MapNode representation:
102 -- {name="name", param1=num, param2=num}
104 -- Position representation:
105 -- {x=num, y=num, z=num}
108 -- print("minetest dump: "..dump(minetest))
119 minetest.register_tool("WPick", {
120 image = "tool_woodpick.png",
123 dt_crackiness = -0.5,
132 minetest.register_tool("STPick", {
133 image = "tool_stonepick.png",
136 dt_crackiness = -0.5,
139 basedurability = 100,
145 minetest.register_tool("SteelPick", {
146 image = "tool_steelpick.png",
149 dt_crackiness = -0.5,
152 basedurability = 333,
158 minetest.register_tool("MesePick", {
159 image = "tool_mesepick.png",
165 basedurability = 1337,
171 minetest.register_tool("WShovel", {
172 image = "tool_woodshovel.png",
176 dt_crumbliness = -1.5,
177 dt_cuttability = 0.3,
184 minetest.register_tool("STShovel", {
185 image = "tool_stoneshovel.png",
189 dt_crumbliness = -1.5,
190 dt_cuttability = 0.1,
191 basedurability = 100,
197 minetest.register_tool("SteelShovel", {
198 image = "tool_steelshovel.png",
202 dt_crumbliness = -1.5,
203 dt_cuttability = 0.0,
204 basedurability = 330,
210 minetest.register_tool("WAxe", {
211 image = "tool_woodaxe.png",
214 dt_crackiness = -0.2,
216 dt_cuttability = -0.5,
223 minetest.register_tool("STAxe", {
224 image = "tool_stoneaxe.png",
227 dt_crackiness = -0.2,
229 dt_cuttability = -0.5,
230 basedurability = 100,
236 minetest.register_tool("SteelAxe", {
237 image = "tool_steelaxe.png",
240 dt_crackiness = -0.2,
242 dt_cuttability = -0.5,
243 basedurability = 330,
249 minetest.register_tool("WSword", {
250 image = "tool_woodsword.png",
262 minetest.register_tool("STSword", {
263 image = "tool_stonesword.png",
269 basedurability = 100,
275 minetest.register_tool("SteelSword", {
276 image = "tool_steelsword.png",
282 basedurability = 330,
289 minetest.register_tool("", {
304 -- Crafting definition
307 minetest.register_craft({
308 output = 'NodeItem "wood" 4',
314 minetest.register_craft({
315 output = 'CraftItem "Stick" 4',
321 minetest.register_craft({
322 output = 'NodeItem "wooden_fence" 2',
324 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
325 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
329 minetest.register_craft({
330 output = 'NodeItem "sign_wall" 1',
332 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
333 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
334 {'', 'CraftItem "Stick"', ''},
338 minetest.register_craft({
339 output = 'NodeItem "torch" 4',
341 {'CraftItem "lump_of_coal"'},
342 {'CraftItem "Stick"'},
346 minetest.register_craft({
347 output = 'ToolItem "WPick"',
349 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
350 {'', 'CraftItem "Stick"', ''},
351 {'', 'CraftItem "Stick"', ''},
355 minetest.register_craft({
356 output = 'ToolItem "STPick"',
358 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
359 {'', 'CraftItem "Stick"', ''},
360 {'', 'CraftItem "Stick"', ''},
364 minetest.register_craft({
365 output = 'ToolItem "SteelPick"',
367 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
368 {'', 'CraftItem "Stick"', ''},
369 {'', 'CraftItem "Stick"', ''},
373 minetest.register_craft({
374 output = 'ToolItem "MesePick"',
376 {'NodeItem "mese"', 'NodeItem "mese"', 'NodeItem "mese"'},
377 {'', 'CraftItem "Stick"', ''},
378 {'', 'CraftItem "Stick"', ''},
382 minetest.register_craft({
383 output = 'ToolItem "WShovel"',
386 {'CraftItem "Stick"'},
387 {'CraftItem "Stick"'},
391 minetest.register_craft({
392 output = 'ToolItem "STShovel"',
394 {'NodeItem "cobble"'},
395 {'CraftItem "Stick"'},
396 {'CraftItem "Stick"'},
400 minetest.register_craft({
401 output = 'ToolItem "SteelShovel"',
403 {'CraftItem "steel_ingot"'},
404 {'CraftItem "Stick"'},
405 {'CraftItem "Stick"'},
409 minetest.register_craft({
410 output = 'ToolItem "WAxe"',
412 {'NodeItem "wood"', 'NodeItem "wood"'},
413 {'NodeItem "wood"', 'CraftItem "Stick"'},
414 {'', 'CraftItem "Stick"'},
418 minetest.register_craft({
419 output = 'ToolItem "STAxe"',
421 {'NodeItem "cobble"', 'NodeItem "cobble"'},
422 {'NodeItem "cobble"', 'CraftItem "Stick"'},
423 {'', 'CraftItem "Stick"'},
427 minetest.register_craft({
428 output = 'ToolItem "SteelAxe"',
430 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
431 {'CraftItem "steel_ingot"', 'CraftItem "Stick"'},
432 {'', 'CraftItem "Stick"'},
436 minetest.register_craft({
437 output = 'ToolItem "WSword"',
441 {'CraftItem "Stick"'},
445 minetest.register_craft({
446 output = 'ToolItem "STSword"',
448 {'NodeItem "cobble"'},
449 {'NodeItem "cobble"'},
450 {'CraftItem "Stick"'},
454 minetest.register_craft({
455 output = 'ToolItem "SteelSword"',
457 {'CraftItem "steel_ingot"'},
458 {'CraftItem "steel_ingot"'},
459 {'CraftItem "Stick"'},
463 minetest.register_craft({
464 output = 'NodeItem "rail" 15',
466 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
467 {'CraftItem "steel_ingot"', 'CraftItem "Stick"', 'CraftItem "steel_ingot"'},
468 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
472 minetest.register_craft({
473 output = 'NodeItem "chest" 1',
475 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
476 {'NodeItem "wood"', '', 'NodeItem "wood"'},
477 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
481 minetest.register_craft({
482 output = 'NodeItem "locked_chest" 1',
484 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
485 {'NodeItem "wood"', 'CraftItem "steel_ingot"', 'NodeItem "wood"'},
486 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
490 minetest.register_craft({
491 output = 'NodeItem "furnace" 1',
493 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
494 {'NodeItem "cobble"', '', 'NodeItem "cobble"'},
495 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
499 minetest.register_craft({
500 output = 'NodeItem "steelblock" 1',
502 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
503 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
504 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
508 minetest.register_craft({
509 output = 'NodeItem "sandstone" 1',
511 {'NodeItem "sand"', 'NodeItem "sand"'},
512 {'NodeItem "sand"', 'NodeItem "sand"'},
516 minetest.register_craft({
517 output = 'NodeItem "clay" 1',
519 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
520 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
524 minetest.register_craft({
525 output = 'NodeItem "brick" 1',
527 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
528 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
532 minetest.register_craft({
533 output = 'CraftItem "paper" 1',
535 {'NodeItem "papyrus"', 'NodeItem "papyrus"', 'NodeItem "papyrus"'},
539 minetest.register_craft({
540 output = 'CraftItem "book" 1',
542 {'CraftItem "paper"'},
543 {'CraftItem "paper"'},
544 {'CraftItem "paper"'},
548 minetest.register_craft({
549 output = 'NodeItem "bookshelf" 1',
551 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
552 {'CraftItem "book"', 'CraftItem "book"', 'CraftItem "book"'},
553 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
557 minetest.register_craft({
558 output = 'NodeItem "ladder" 1',
560 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
561 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
562 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
566 minetest.register_craft({
567 output = 'CraftItem "apple_iron" 1',
569 {'', 'CraftItem "steel_ingot"', ''},
570 {'CraftItem "steel_ingot"', 'CraftItem "apple"', 'CraftItem "steel_ingot"'},
571 {'', 'CraftItem "steel_ingot"', ''},
579 function digprop_constanttime(time)
581 diggability = "constant",
582 constant_time = time,
586 function digprop_stonelike(toughness)
588 diggablity = "normal",
589 weight = toughness * 5,
596 function digprop_dirtlike(toughness)
598 diggablity = "normal",
599 weight = toughness * 1.2,
606 function digprop_gravellike(toughness)
608 diggablity = "normal",
609 weight = toughness * 2,
616 function digprop_woodlike(toughness)
618 diggablity = "normal",
619 weight = toughness * 1.0,
626 function digprop_leaveslike(toughness)
628 diggablity = "normal",
629 weight = toughness * (-0.5),
636 function digprop_glasslike(toughness)
638 diggablity = "normal",
639 weight = toughness * 0.1,
646 function inventorycube(img1, img2, img3)
649 return "[inventorycube"
650 .. "{" .. img1:gsub("%^", "&")
651 .. "{" .. img2:gsub("%^", "&")
652 .. "{" .. img3:gsub("%^", "&")
657 minetest.register_node("stone", {
658 tile_images = {"stone.png"},
659 inventory_image = inventorycube("stone.png"),
660 paramtype = "mineral",
661 is_ground_content = true,
662 often_contains_mineral = true, -- Texture atlas hint
663 material = digprop_stonelike(1.0),
664 dug_item = 'NodeItem "cobble" 1',
667 minetest.register_node("dirt_with_grass", {
668 tile_images = {"grass.png", "mud.png", "mud.png^grass_side.png"},
669 inventory_image = inventorycube("mud.png^grass_side.png"),
670 is_ground_content = true,
671 material = digprop_dirtlike(1.0),
672 dug_item = 'NodeItem "dirt" 1',
675 minetest.register_node("dirt_with_grass_footsteps", {
676 tile_images = {"grass_footsteps.png", "mud.png", "mud.png^grass_side.png"},
677 inventory_image = "grass_footsteps.png",
678 is_ground_content = true,
679 material = digprop_dirtlike(1.0),
680 dug_item = 'NodeItem "dirt" 1',
683 minetest.register_node("dirt", {
684 tile_images = {"mud.png"},
685 inventory_image = inventorycube("mud.png"),
686 is_ground_content = true,
687 material = digprop_dirtlike(1.0),
690 minetest.register_node("sand", {
691 tile_images = {"sand.png"},
692 inventory_image = inventorycube("sand.png"),
693 is_ground_content = true,
694 material = digprop_dirtlike(1.0),
697 minetest.register_node("gravel", {
698 tile_images = {"gravel.png"},
699 inventory_image = inventorycube("gravel.png"),
700 is_ground_content = true,
701 material = digprop_gravellike(1.0),
704 minetest.register_node("sandstone", {
705 tile_images = {"sandstone.png"},
706 inventory_image = inventorycube("sandstone.png"),
707 is_ground_content = true,
708 material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
709 dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional?
712 minetest.register_node("clay", {
713 tile_images = {"clay.png"},
714 inventory_image = inventorycube("clay.png"),
715 is_ground_content = true,
716 material = digprop_dirtlike(1.0),
717 dug_item = 'CraftItem "lump_of_clay" 4',
720 minetest.register_node("brick", {
721 tile_images = {"brick.png"},
722 inventory_image = inventorycube("brick.png"),
723 is_ground_content = true,
724 material = digprop_stonelike(1.0),
725 dug_item = 'CraftItem "clay_brick" 4',
728 minetest.register_node("tree", {
729 tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
730 inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
731 is_ground_content = true,
732 material = digprop_woodlike(1.0),
733 cookresult_item = 'CraftItem "lump_of_coal" 1',
734 furnace_burntime = 30,
737 minetest.register_node("jungletree", {
738 tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
739 inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
740 is_ground_content = true,
741 material = digprop_woodlike(1.0),
742 cookresult_item = 'CraftItem "lump_of_coal" 1',
743 furnace_burntime = 30,
746 minetest.register_node("junglegrass", {
747 drawtype = "plantlike",
749 tile_images = {"junglegrass.png"},
750 inventory_image = "junglegrass.png",
751 light_propagates = true,
754 material = digprop_leaveslike(1.0),
755 furnace_burntime = 2,
758 minetest.register_node("leaves", {
759 drawtype = "allfaces_optional",
761 tile_images = {"leaves.png"},
762 inventory_image = "leaves.png",
763 light_propagates = true,
765 material = digprop_leaveslike(1.0),
766 extra_dug_item = 'NodeItem "sapling" 1',
767 extra_dug_item_rarity = 20,
768 furnace_burntime = 1,
771 minetest.register_node("cactus", {
772 tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
773 inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
774 is_ground_content = true,
775 material = digprop_woodlike(0.75),
776 furnace_burntime = 15,
779 minetest.register_node("papyrus", {
780 drawtype = "plantlike",
781 tile_images = {"papyrus.png"},
782 inventory_image = "papyrus.png",
783 light_propagates = true,
785 is_ground_content = true,
787 material = digprop_leaveslike(0.5),
788 furnace_burntime = 1,
791 minetest.register_node("bookshelf", {
792 tile_images = {"wood.png", "wood.png", "bookshelf.png"},
793 -- FIXME: inventorycube only cares for the first texture
794 --inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
795 inventory_image = inventorycube("bookshelf.png"),
796 is_ground_content = true,
797 material = digprop_woodlike(0.75),
798 furnace_burntime = 30,
801 minetest.register_node("glass", {
802 drawtype = "glasslike",
803 tile_images = {"glass.png"},
804 inventory_image = inventorycube("glass.png"),
805 light_propagates = true,
807 sunlight_propagates = true,
808 is_ground_content = true,
809 material = digprop_glasslike(1.0),
812 minetest.register_node("wooden_fence", {
813 drawtype = "fencelike",
814 tile_images = {"wood.png"},
815 inventory_image = "fence.png",
816 light_propagates = true,
818 is_ground_content = true,
821 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
823 furnace_burntime = 15,
824 material = digprop_woodlike(0.75),
827 minetest.register_node("rail", {
828 drawtype = "raillike",
829 tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
830 inventory_image = "rail.png",
831 light_propagates = true,
833 is_ground_content = true,
839 material = digprop_dirtlike(0.75),
842 minetest.register_node("ladder", {
843 drawtype = "signlike",
844 tile_images = {"ladder.png"},
845 inventory_image = "ladder.png",
846 light_propagates = true,
848 is_ground_content = true,
853 type = "wallmounted",
854 --wall_top = = <default>
855 --wall_bottom = = <default>
856 --wall_side = = <default>
858 furnace_burntime = 5,
859 material = digprop_woodlike(0.5),
862 minetest.register_node("coalstone", {
863 tile_images = {"stone.png^mineral_coal.png"},
864 inventory_image = "stone.png^mineral_coal.png",
865 is_ground_content = true,
866 material = digprop_stonelike(1.5),
869 minetest.register_node("wood", {
870 tile_images = {"wood.png"},
871 inventory_image = inventorycube("wood.png"),
872 is_ground_content = true,
873 furnace_burntime = 7,
874 material = digprop_woodlike(0.75),
877 minetest.register_node("mese", {
878 tile_images = {"mese.png"},
879 inventory_image = inventorycube("mese.png"),
880 is_ground_content = true,
881 furnace_burntime = 30,
882 material = digprop_stonelike(0.5),
885 minetest.register_node("cloud", {
886 tile_images = {"cloud.png"},
887 inventory_image = inventorycube("cloud.png"),
888 is_ground_content = true,
891 minetest.register_node("water_flowing", {
892 drawtype = "flowingliquid",
893 tile_images = {"water.png"},
895 inventory_image = inventorycube("water.png"),
897 light_propagates = true,
902 liquidtype = "flowing",
903 liquid_alternative_flowing = "water_flowing",
904 liquid_alternative_source = "water_source",
905 liquid_viscosity = WATER_VISC,
906 post_effect_color = {a=64, r=100, g=100, b=200},
907 special_materials = {
908 {image="water.png", backface_culling=false},
909 {image="water.png", backface_culling=true},
913 minetest.register_node("water_source", {
915 tile_images = {"water.png"},
917 inventory_image = inventorycube("water.png"),
919 light_propagates = true,
924 liquidtype = "source",
925 liquid_alternative_flowing = "water_flowing",
926 liquid_alternative_source = "water_source",
927 liquid_viscosity = WATER_VISC,
928 post_effect_color = {a=64, r=100, g=100, b=200},
929 special_materials = {
930 -- New-style water source material (mostly unused)
931 {image="water.png", backface_culling=false},
935 minetest.register_node("lava_flowing", {
936 drawtype = "flowingliquid",
937 tile_images = {"lava.png"},
938 inventory_image = inventorycube("lava.png"),
940 light_propagates = false,
941 light_source = LIGHT_MAX - 1,
946 liquidtype = "flowing",
947 liquid_alternative_flowing = "lava_flowing",
948 liquid_alternative_source = "lava_source",
949 liquid_viscosity = LAVA_VISC,
950 damage_per_second = 4*2,
951 post_effect_color = {a=192, r=255, g=64, b=0},
952 special_materials = {
953 {image="lava.png", backface_culling=false},
954 {image="lava.png", backface_culling=true},
958 minetest.register_node("lava_source", {
960 tile_images = {"lava.png"},
961 inventory_image = inventorycube("lava.png"),
963 light_propagates = false,
964 light_source = LIGHT_MAX - 1,
969 liquidtype = "source",
970 liquid_alternative_flowing = "lava_flowing",
971 liquid_alternative_source = "lava_source",
972 liquid_viscosity = LAVA_VISC,
973 damage_per_second = 4*2,
974 post_effect_color = {a=192, r=255, g=64, b=0},
975 special_materials = {
976 -- New-style lava source material (mostly unused)
977 {image="lava.png", backface_culling=false},
979 furnace_burntime = 60,
982 minetest.register_node("torch", {
983 drawtype = "torchlike",
984 tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
985 inventory_image = "torch_on_floor.png",
987 light_propagates = true,
988 sunlight_propagates = true,
991 light_source = LIGHT_MAX-1,
993 type = "wallmounted",
994 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
995 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
996 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
998 material = digprop_constanttime(0.0),
999 furnace_burntime = 4,
1002 minetest.register_node("sign_wall", {
1003 drawtype = "signlike",
1004 tile_images = {"sign_wall.png"},
1005 inventory_image = "sign_wall.png",
1006 paramtype = "light",
1007 light_propagates = true,
1008 sunlight_propagates = true,
1010 wall_mounted = true,
1011 metadata_name = "sign",
1013 type = "wallmounted",
1014 --wall_top = <default>
1015 --wall_bottom = <default>
1016 --wall_side = <default>
1018 material = digprop_constanttime(0.5),
1019 furnace_burntime = 10,
1022 minetest.register_node("chest", {
1023 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1024 "chest_side.png", "chest_side.png", "chest_front.png"},
1025 inventory_image = "chest_top.png",
1026 --inventory_image = inventorycube("chest_top.png", "chest_side.png", "chest_front.png"),
1027 paramtype = "facedir_simple",
1028 metadata_name = "chest",
1029 material = digprop_woodlike(1.0),
1030 furnace_burntime = 30,
1033 minetest.register_node("locked_chest", {
1034 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1035 "chest_side.png", "chest_side.png", "chest_lock.png"},
1036 inventory_image = "chest_lock.png",
1037 paramtype = "facedir_simple",
1038 metadata_name = "locked_chest",
1039 material = digprop_woodlike(1.0),
1040 furnace_burntime = 30,
1043 minetest.register_node("furnace", {
1044 tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
1045 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1046 inventory_image = "furnace_front.png",
1047 paramtype = "facedir_simple",
1048 metadata_name = "furnace",
1049 material = digprop_stonelike(3.0),
1052 minetest.register_node("cobble", {
1053 tile_images = {"cobble.png"},
1054 inventory_image = inventorycube("cobble.png"),
1055 is_ground_content = true,
1056 cookresult_item = 'NodeItem "stone" 1',
1057 material = digprop_stonelike(0.9),
1060 minetest.register_node("mossycobble", {
1061 tile_images = {"mossycobble.png"},
1062 inventory_image = inventorycube("mossycobble.png"),
1063 is_ground_content = true,
1064 material = digprop_stonelike(0.8),
1067 minetest.register_node("steelblock", {
1068 tile_images = {"steel_block.png"},
1069 inventory_image = inventorycube("steel_block.png"),
1070 is_ground_content = true,
1071 material = digprop_stonelike(5.0),
1074 minetest.register_node("nyancat", {
1075 tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
1076 "nc_side.png", "nc_back.png", "nc_front.png"},
1077 inventory_image = "nc_front.png",
1078 paramtype = "facedir_simple",
1079 material = digprop_stonelike(3.0),
1080 furnace_burntime = 1,
1083 minetest.register_node("nyancat_rainbow", {
1084 tile_images = {"nc_rb.png"},
1085 inventory_image = "nc_rb.png",
1086 material = digprop_stonelike(3.0),
1087 furnace_burntime = 1,
1090 minetest.register_node("sapling", {
1091 drawtype = "plantlike",
1093 tile_images = {"sapling.png"},
1094 inventory_image = "sapling.png",
1095 paramtype = "light",
1096 light_propagates = true,
1098 material = digprop_constanttime(0.0),
1099 furnace_burntime = 10,
1102 minetest.register_node("apple", {
1103 drawtype = "plantlike",
1105 tile_images = {"apple.png"},
1106 inventory_image = "apple.png",
1107 paramtype = "light",
1108 light_propagates = true,
1109 sunlight_propagates = true,
1111 dug_item = 'CraftItem "apple" 1',
1112 material = digprop_constanttime(0.0),
1113 furnace_burntime = 3,
1120 local craftitem_place_item = function(item, placer, pos)
1121 --print("craftitem_place_item")
1122 --print("item: " .. dump(item))
1123 --print("placer: " .. dump(placer))
1124 --print("pos: " .. dump(pos))
1125 minetest.env:add_item(pos, 'CraftItem "' .. item .. '" 1')
1129 local craftitem_eat = function(hp_change)
1130 return function(item, user, pointed_thing) -- closure
1131 --print("craftitem_eat(" .. hp_change .. ")")
1132 --print("item: " .. dump(item))
1133 --print("user: " .. dump(user))
1134 --print("pointed_thing: " .. dump(pointed_thing))
1135 user:set_hp(user:get_hp() + hp_change)
1140 minetest.register_craftitem("Stick", {
1141 image = "stick.png",
1142 --furnace_burntime = ...,
1143 on_place_on_ground = craftitem_place_item,
1146 minetest.register_craftitem("paper", {
1147 image = "paper.png",
1148 on_place_on_ground = craftitem_place_item,
1151 minetest.register_craftitem("book", {
1153 on_place_on_ground = craftitem_place_item,
1156 minetest.register_craftitem("lump_of_coal", {
1157 image = "lump_of_coal.png",
1158 furnace_burntime = 40;
1159 on_place_on_ground = craftitem_place_item,
1162 minetest.register_craftitem("lump_of_iron", {
1163 image = "lump_of_iron.png",
1164 cookresult_item = 'CraftItem "steel_ingot" 1',
1165 on_place_on_ground = craftitem_place_item,
1168 minetest.register_craftitem("lump_of_clay", {
1169 image = "lump_of_clay.png",
1170 cookresult_item = 'CraftItem "clay_brick" 1',
1171 on_place_on_ground = craftitem_place_item,
1174 minetest.register_craftitem("steel_ingot", {
1175 image = "steel_ingot.png",
1176 on_place_on_ground = craftitem_place_item,
1179 minetest.register_craftitem("clay_brick", {
1180 image = "clay_brick.png",
1181 on_place_on_ground = craftitem_place_item,
1184 minetest.register_craftitem("rat", {
1186 cookresult_item = 'CraftItem "cooked_rat" 1',
1187 on_drop = function(item, dropper, pos)
1188 minetest.env:add_rat(pos)
1193 minetest.register_craftitem("cooked_rat", {
1194 image = "cooked_rat.png",
1195 cookresult_item = 'CraftItem "scorched_stuff" 1',
1196 on_place_on_ground = craftitem_place_item,
1197 on_use = craftitem_eat(6),
1200 minetest.register_craftitem("scorched_stuff", {
1201 image = "scorched_stuff.png",
1202 on_place_on_ground = craftitem_place_item,
1205 minetest.register_craftitem("firefly", {
1206 image = "firefly.png",
1207 on_drop = function(item, dropper, pos)
1208 minetest.env:add_firefly(pos)
1213 minetest.register_craftitem("apple", {
1214 image = "apple.png",
1215 on_place_on_ground = craftitem_place_item,
1216 on_use = craftitem_eat(4),
1219 minetest.register_craftitem("apple_iron", {
1220 image = "apple_iron.png",
1221 on_place_on_ground = craftitem_place_item,
1222 on_use = craftitem_eat(8),
1225 print(dump(minetest.registered_craftitems))
1229 -- Some common functions
1232 function nodeupdate_single(p)
1233 n = minetest.env:get_node(p)
1234 if n.name == "sand" or n.name == "gravel" then
1235 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1236 n_bottom = minetest.env:get_node(p_bottom)
1237 if n_bottom.name == "air" then
1238 minetest.env:remove_node(p)
1239 minetest.env:add_luaentity(p, "falling_"..n.name)
1245 function nodeupdate(p)
1249 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1250 nodeupdate_single(p2)
1260 function register_falling_node(nodename, texture)
1261 minetest.register_entity("falling_"..nodename, {
1262 -- Static definition
1264 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1266 textures = {texture,texture,texture,texture,texture,texture},
1269 on_step = function(self, dtime)
1271 self.object:setacceleration({x=0, y=-10, z=0})
1272 -- Turn to actual sand when collides to ground or just move
1273 local pos = self.object:getpos()
1274 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1275 local bcn = minetest.env:get_node(bcp)
1276 if bcn.name ~= "air" then
1277 -- Turn to a sand node
1278 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1279 minetest.env:add_node(np, {name=nodename})
1280 self.object:remove()
1288 register_falling_node("sand", "sand.png")
1289 register_falling_node("gravel", "gravel.png")
1295 -- Global environment step function
1296 function on_step(dtime)
1299 minetest.register_globalstep(on_step)
1301 function on_placenode(p, node)
1302 print("on_placenode")
1305 minetest.register_on_placenode(on_placenode)
1307 function on_dignode(p, node)
1311 minetest.register_on_dignode(on_dignode)
1313 function on_punchnode(p, node)
1314 print("on_punchnode")
1315 if node.name == "TNT" then
1316 minetest.env:remove_node(p)
1317 minetest.env:add_luaentity(p, "TNT")
1318 --minetest.env:add_luaentity(p, "testentity")
1319 --minetest.env:add_firefly(p)
1323 minetest.register_on_punchnode(on_punchnode)
1326 -- Done, print some random stuff
1329 --print("minetest.registered_entities:")
1330 --dump2(minetest.registered_entities)