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)
29 -- minetest.get_player_privs(name)
32 -- minetest.env - environment reference
35 -- minetest.registered_nodes
36 -- ^ List of registered node definitions, indexed by name
37 -- minetest.registered_craftitems
38 -- ^ List of registered craft item definitions, indexed by name
39 -- minetest.registered_entities
40 -- ^ List of registered entity prototypes, indexed by name
41 -- minetest.object_refs
42 -- ^ List of object references, indexed by active object id
43 -- minetest.luaentities
44 -- ^ List of lua entities, indexed by active object id
46 -- EnvRef is basically ServerEnvironment and ServerMap combined.
48 -- - add_node(pos, node)
51 -- - add_luaentity(pos, name)
52 -- - add_item(pos, itemstring)
55 -- - get_meta(pos) -- Get a NodeMetaRef at that position
56 -- - get_player_by_name(name) -- Get an ObjectRef to a player
60 -- - allows_text_input()
61 -- - set_text(text) -- eg. set the text of a sign
64 -- - set_infotext(infotext)
65 -- - inventory_set_list(name, {item1, item2, ...})
66 -- - inventory_get_list(name)
67 -- - set_inventory_draw_spec(string)
68 -- - set_allow_text_input(bool)
69 -- - set_allow_removal(bool)
70 -- - set_enforce_owner(bool)
71 -- - is_inventory_modified()
72 -- - reset_inventory_modified()
73 -- - is_text_modified()
74 -- - reset_text_modified()
75 -- - set_string(name, value)
78 -- ObjectRef is basically ServerActiveObject.
80 -- - remove(): remove object (after returning from Lua)
81 -- - getpos(): returns {x=num, y=num, z=num}
82 -- - setpos(pos); pos={x=num, y=num, z=num}
83 -- - moveto(pos, continuous=false): interpolated move
84 -- - punch(puncher); puncher = an another ObjectRef
85 -- - right_click(clicker); clicker = an another ObjectRef
86 -- - get_wielded_itemstring()
87 -- - get_wielded_item()
88 -- - damage_wielded_item(num) (item damage/wear range is 0-65535)
89 -- - add_to_inventory(itemstring): add an item to object inventory
90 -- - add_to_inventory_later(itemstring): like above, but after callback returns (only allowed for craftitem callbacks)
91 -- - get_hp(): returns number of hitpoints (2 * number of hearts)
92 -- - set_hp(hp): set number of hitpoints (2 * number of hearts)
94 -- - setvelocity({x=num, y=num, z=num})
95 -- - setacceleration({x=num, y=num, z=num})
96 -- - getacceleration()
97 -- - settexturemod(mod)
98 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
99 -- - select_horiz_by_yawpitch=false)
101 -- - get_player_name(): will return nil if is not a player
102 -- - inventory_set_list(name, {item1, item2, ...})
103 -- - inventory_get_list(name)
105 -- Registered entities:
106 -- - Functions receive a "luaentity" as self:
107 -- - It has the member .object, which is an ObjectRef pointing to the object
108 -- - The original prototype stuff is visible directly via a metatable
110 -- - on_activate(self, staticdata)
111 -- - on_step(self, dtime)
112 -- - on_punch(self, hitter)
113 -- - on_rightclick(self, clicker)
114 -- - get_staticdata(self): return string
116 -- MapNode representation:
117 -- {name="name", param1=num, param2=num}
119 -- Position representation:
120 -- {x=num, y=num, z=num}
123 -- print("minetest dump: "..dump(minetest))
134 minetest.register_tool("WPick", {
135 image = "tool_woodpick.png",
138 dt_crackiness = -0.5,
147 minetest.register_tool("STPick", {
148 image = "tool_stonepick.png",
151 dt_crackiness = -0.5,
154 basedurability = 100,
160 minetest.register_tool("SteelPick", {
161 image = "tool_steelpick.png",
164 dt_crackiness = -0.5,
167 basedurability = 333,
173 minetest.register_tool("MesePick", {
174 image = "tool_mesepick.png",
180 basedurability = 1337,
186 minetest.register_tool("WShovel", {
187 image = "tool_woodshovel.png",
191 dt_crumbliness = -1.5,
192 dt_cuttability = 0.3,
199 minetest.register_tool("STShovel", {
200 image = "tool_stoneshovel.png",
204 dt_crumbliness = -1.5,
205 dt_cuttability = 0.1,
206 basedurability = 100,
212 minetest.register_tool("SteelShovel", {
213 image = "tool_steelshovel.png",
217 dt_crumbliness = -1.5,
218 dt_cuttability = 0.0,
219 basedurability = 330,
225 minetest.register_tool("WAxe", {
226 image = "tool_woodaxe.png",
229 dt_crackiness = -0.2,
231 dt_cuttability = -0.5,
238 minetest.register_tool("STAxe", {
239 image = "tool_stoneaxe.png",
242 dt_crackiness = -0.2,
244 dt_cuttability = -0.5,
245 basedurability = 100,
251 minetest.register_tool("SteelAxe", {
252 image = "tool_steelaxe.png",
255 dt_crackiness = -0.2,
257 dt_cuttability = -0.5,
258 basedurability = 330,
264 minetest.register_tool("WSword", {
265 image = "tool_woodsword.png",
277 minetest.register_tool("STSword", {
278 image = "tool_stonesword.png",
284 basedurability = 100,
290 minetest.register_tool("SteelSword", {
291 image = "tool_steelsword.png",
297 basedurability = 330,
304 minetest.register_tool("", {
319 -- Crafting definition
322 minetest.register_craft({
323 output = 'NodeItem "wood" 4',
329 minetest.register_craft({
330 output = 'CraftItem "Stick" 4',
336 minetest.register_craft({
337 output = 'NodeItem "wooden_fence" 2',
339 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
340 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
344 minetest.register_craft({
345 output = 'NodeItem "sign_wall" 1',
347 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
348 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
349 {'', 'CraftItem "Stick"', ''},
353 minetest.register_craft({
354 output = 'NodeItem "torch" 4',
356 {'CraftItem "lump_of_coal"'},
357 {'CraftItem "Stick"'},
361 minetest.register_craft({
362 output = 'ToolItem "WPick"',
364 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
365 {'', 'CraftItem "Stick"', ''},
366 {'', 'CraftItem "Stick"', ''},
370 minetest.register_craft({
371 output = 'ToolItem "STPick"',
373 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
374 {'', 'CraftItem "Stick"', ''},
375 {'', 'CraftItem "Stick"', ''},
379 minetest.register_craft({
380 output = 'ToolItem "SteelPick"',
382 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
383 {'', 'CraftItem "Stick"', ''},
384 {'', 'CraftItem "Stick"', ''},
388 minetest.register_craft({
389 output = 'ToolItem "MesePick"',
391 {'NodeItem "mese"', 'NodeItem "mese"', 'NodeItem "mese"'},
392 {'', 'CraftItem "Stick"', ''},
393 {'', 'CraftItem "Stick"', ''},
397 minetest.register_craft({
398 output = 'ToolItem "WShovel"',
401 {'CraftItem "Stick"'},
402 {'CraftItem "Stick"'},
406 minetest.register_craft({
407 output = 'ToolItem "STShovel"',
409 {'NodeItem "cobble"'},
410 {'CraftItem "Stick"'},
411 {'CraftItem "Stick"'},
415 minetest.register_craft({
416 output = 'ToolItem "SteelShovel"',
418 {'CraftItem "steel_ingot"'},
419 {'CraftItem "Stick"'},
420 {'CraftItem "Stick"'},
424 minetest.register_craft({
425 output = 'ToolItem "WAxe"',
427 {'NodeItem "wood"', 'NodeItem "wood"'},
428 {'NodeItem "wood"', 'CraftItem "Stick"'},
429 {'', 'CraftItem "Stick"'},
433 minetest.register_craft({
434 output = 'ToolItem "STAxe"',
436 {'NodeItem "cobble"', 'NodeItem "cobble"'},
437 {'NodeItem "cobble"', 'CraftItem "Stick"'},
438 {'', 'CraftItem "Stick"'},
442 minetest.register_craft({
443 output = 'ToolItem "SteelAxe"',
445 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
446 {'CraftItem "steel_ingot"', 'CraftItem "Stick"'},
447 {'', 'CraftItem "Stick"'},
451 minetest.register_craft({
452 output = 'ToolItem "WSword"',
456 {'CraftItem "Stick"'},
460 minetest.register_craft({
461 output = 'ToolItem "STSword"',
463 {'NodeItem "cobble"'},
464 {'NodeItem "cobble"'},
465 {'CraftItem "Stick"'},
469 minetest.register_craft({
470 output = 'ToolItem "SteelSword"',
472 {'CraftItem "steel_ingot"'},
473 {'CraftItem "steel_ingot"'},
474 {'CraftItem "Stick"'},
478 minetest.register_craft({
479 output = 'NodeItem "rail" 15',
481 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
482 {'CraftItem "steel_ingot"', 'CraftItem "Stick"', 'CraftItem "steel_ingot"'},
483 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
487 minetest.register_craft({
488 output = 'NodeItem "chest" 1',
490 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
491 {'NodeItem "wood"', '', 'NodeItem "wood"'},
492 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
496 minetest.register_craft({
497 output = 'NodeItem "locked_chest" 1',
499 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
500 {'NodeItem "wood"', 'CraftItem "steel_ingot"', 'NodeItem "wood"'},
501 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
505 minetest.register_craft({
506 output = 'NodeItem "furnace" 1',
508 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
509 {'NodeItem "cobble"', '', 'NodeItem "cobble"'},
510 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
514 minetest.register_craft({
515 output = 'NodeItem "steelblock" 1',
517 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
518 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
519 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
523 minetest.register_craft({
524 output = 'NodeItem "sandstone" 1',
526 {'NodeItem "sand"', 'NodeItem "sand"'},
527 {'NodeItem "sand"', 'NodeItem "sand"'},
531 minetest.register_craft({
532 output = 'NodeItem "clay" 1',
534 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
535 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
539 minetest.register_craft({
540 output = 'NodeItem "brick" 1',
542 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
543 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
547 minetest.register_craft({
548 output = 'CraftItem "paper" 1',
550 {'NodeItem "papyrus"', 'NodeItem "papyrus"', 'NodeItem "papyrus"'},
554 minetest.register_craft({
555 output = 'CraftItem "book" 1',
557 {'CraftItem "paper"'},
558 {'CraftItem "paper"'},
559 {'CraftItem "paper"'},
563 minetest.register_craft({
564 output = 'NodeItem "bookshelf" 1',
566 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
567 {'CraftItem "book"', 'CraftItem "book"', 'CraftItem "book"'},
568 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
572 minetest.register_craft({
573 output = 'NodeItem "ladder" 1',
575 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
576 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
577 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
581 minetest.register_craft({
582 output = 'CraftItem "apple_iron" 1',
584 {'', 'CraftItem "steel_ingot"', ''},
585 {'CraftItem "steel_ingot"', 'CraftItem "apple"', 'CraftItem "steel_ingot"'},
586 {'', 'CraftItem "steel_ingot"', ''},
594 function digprop_constanttime(time)
596 diggability = "constant",
597 constant_time = time,
601 function digprop_stonelike(toughness)
603 diggablity = "normal",
604 weight = toughness * 5,
611 function digprop_dirtlike(toughness)
613 diggablity = "normal",
614 weight = toughness * 1.2,
621 function digprop_gravellike(toughness)
623 diggablity = "normal",
624 weight = toughness * 2,
631 function digprop_woodlike(toughness)
633 diggablity = "normal",
634 weight = toughness * 1.0,
641 function digprop_leaveslike(toughness)
643 diggablity = "normal",
644 weight = toughness * (-0.5),
651 function digprop_glasslike(toughness)
653 diggablity = "normal",
654 weight = toughness * 0.1,
661 function inventorycube(img1, img2, img3)
664 return "[inventorycube"
665 .. "{" .. img1:gsub("%^", "&")
666 .. "{" .. img2:gsub("%^", "&")
667 .. "{" .. img3:gsub("%^", "&")
672 minetest.register_node("stone", {
673 tile_images = {"stone.png"},
674 inventory_image = inventorycube("stone.png"),
675 paramtype = "mineral",
676 is_ground_content = true,
677 often_contains_mineral = true, -- Texture atlas hint
678 material = digprop_stonelike(1.0),
679 dug_item = 'NodeItem "cobble" 1',
682 minetest.register_node("dirt_with_grass", {
683 tile_images = {"grass.png", "mud.png", "mud.png^grass_side.png"},
684 inventory_image = inventorycube("mud.png^grass_side.png"),
685 is_ground_content = true,
686 material = digprop_dirtlike(1.0),
687 dug_item = 'NodeItem "dirt" 1',
690 minetest.register_node("dirt_with_grass_footsteps", {
691 tile_images = {"grass_footsteps.png", "mud.png", "mud.png^grass_side.png"},
692 inventory_image = "grass_footsteps.png",
693 is_ground_content = true,
694 material = digprop_dirtlike(1.0),
695 dug_item = 'NodeItem "dirt" 1',
698 minetest.register_node("dirt", {
699 tile_images = {"mud.png"},
700 inventory_image = inventorycube("mud.png"),
701 is_ground_content = true,
702 material = digprop_dirtlike(1.0),
705 minetest.register_node("sand", {
706 tile_images = {"sand.png"},
707 inventory_image = inventorycube("sand.png"),
708 is_ground_content = true,
709 material = digprop_dirtlike(1.0),
710 cookresult_item = 'NodeItem "glass" 1',
713 minetest.register_node("gravel", {
714 tile_images = {"gravel.png"},
715 inventory_image = inventorycube("gravel.png"),
716 is_ground_content = true,
717 material = digprop_gravellike(1.0),
720 minetest.register_node("sandstone", {
721 tile_images = {"sandstone.png"},
722 inventory_image = inventorycube("sandstone.png"),
723 is_ground_content = true,
724 material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
725 dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional?
728 minetest.register_node("clay", {
729 tile_images = {"clay.png"},
730 inventory_image = inventorycube("clay.png"),
731 is_ground_content = true,
732 material = digprop_dirtlike(1.0),
733 dug_item = 'CraftItem "lump_of_clay" 4',
736 minetest.register_node("brick", {
737 tile_images = {"brick.png"},
738 inventory_image = inventorycube("brick.png"),
739 is_ground_content = true,
740 material = digprop_stonelike(1.0),
741 dug_item = 'CraftItem "clay_brick" 4',
744 minetest.register_node("tree", {
745 tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
746 inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
747 is_ground_content = true,
748 material = digprop_woodlike(1.0),
749 cookresult_item = 'CraftItem "lump_of_coal" 1',
750 furnace_burntime = 30,
753 minetest.register_node("jungletree", {
754 tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
755 inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
756 is_ground_content = true,
757 material = digprop_woodlike(1.0),
758 cookresult_item = 'CraftItem "lump_of_coal" 1',
759 furnace_burntime = 30,
762 minetest.register_node("junglegrass", {
763 drawtype = "plantlike",
765 tile_images = {"junglegrass.png"},
766 inventory_image = "junglegrass.png",
767 light_propagates = true,
770 material = digprop_leaveslike(1.0),
771 furnace_burntime = 2,
774 minetest.register_node("leaves", {
775 drawtype = "allfaces_optional",
777 tile_images = {"leaves.png"},
778 inventory_image = "leaves.png",
779 light_propagates = true,
781 material = digprop_leaveslike(1.0),
782 extra_dug_item = 'NodeItem "sapling" 1',
783 extra_dug_item_rarity = 20,
784 furnace_burntime = 1,
787 minetest.register_node("cactus", {
788 tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
789 inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
790 is_ground_content = true,
791 material = digprop_woodlike(0.75),
792 furnace_burntime = 15,
795 minetest.register_node("papyrus", {
796 drawtype = "plantlike",
797 tile_images = {"papyrus.png"},
798 inventory_image = "papyrus.png",
799 light_propagates = true,
801 is_ground_content = true,
803 material = digprop_leaveslike(0.5),
804 furnace_burntime = 1,
807 minetest.register_node("bookshelf", {
808 tile_images = {"wood.png", "wood.png", "bookshelf.png"},
809 -- FIXME: inventorycube only cares for the first texture
810 --inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
811 inventory_image = inventorycube("bookshelf.png"),
812 is_ground_content = true,
813 material = digprop_woodlike(0.75),
814 furnace_burntime = 30,
817 minetest.register_node("glass", {
818 drawtype = "glasslike",
819 tile_images = {"glass.png"},
820 inventory_image = inventorycube("glass.png"),
821 light_propagates = true,
823 sunlight_propagates = true,
824 is_ground_content = true,
825 material = digprop_glasslike(1.0),
828 minetest.register_node("wooden_fence", {
829 drawtype = "fencelike",
830 tile_images = {"wood.png"},
831 inventory_image = "fence.png",
832 light_propagates = true,
834 is_ground_content = true,
837 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
839 furnace_burntime = 15,
840 material = digprop_woodlike(0.75),
843 minetest.register_node("rail", {
844 drawtype = "raillike",
845 tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
846 inventory_image = "rail.png",
847 light_propagates = true,
849 is_ground_content = true,
855 material = digprop_dirtlike(0.75),
858 minetest.register_node("ladder", {
859 drawtype = "signlike",
860 tile_images = {"ladder.png"},
861 inventory_image = "ladder.png",
862 light_propagates = true,
864 is_ground_content = true,
869 type = "wallmounted",
870 --wall_top = = <default>
871 --wall_bottom = = <default>
872 --wall_side = = <default>
874 furnace_burntime = 5,
875 material = digprop_woodlike(0.5),
878 minetest.register_node("coalstone", {
879 tile_images = {"stone.png^mineral_coal.png"},
880 inventory_image = "stone.png^mineral_coal.png",
881 is_ground_content = true,
882 material = digprop_stonelike(1.5),
885 minetest.register_node("wood", {
886 tile_images = {"wood.png"},
887 inventory_image = inventorycube("wood.png"),
888 is_ground_content = true,
889 furnace_burntime = 7,
890 material = digprop_woodlike(0.75),
893 minetest.register_node("mese", {
894 tile_images = {"mese.png"},
895 inventory_image = inventorycube("mese.png"),
896 is_ground_content = true,
897 furnace_burntime = 30,
898 material = digprop_stonelike(0.5),
901 minetest.register_node("cloud", {
902 tile_images = {"cloud.png"},
903 inventory_image = inventorycube("cloud.png"),
904 is_ground_content = true,
907 minetest.register_node("water_flowing", {
908 drawtype = "flowingliquid",
909 tile_images = {"water.png"},
911 inventory_image = inventorycube("water.png"),
913 light_propagates = true,
918 liquidtype = "flowing",
919 liquid_alternative_flowing = "water_flowing",
920 liquid_alternative_source = "water_source",
921 liquid_viscosity = WATER_VISC,
922 post_effect_color = {a=64, r=100, g=100, b=200},
923 special_materials = {
924 {image="water.png", backface_culling=false},
925 {image="water.png", backface_culling=true},
929 minetest.register_node("water_source", {
931 tile_images = {"water.png"},
933 inventory_image = inventorycube("water.png"),
935 light_propagates = true,
940 liquidtype = "source",
941 liquid_alternative_flowing = "water_flowing",
942 liquid_alternative_source = "water_source",
943 liquid_viscosity = WATER_VISC,
944 post_effect_color = {a=64, r=100, g=100, b=200},
945 special_materials = {
946 -- New-style water source material (mostly unused)
947 {image="water.png", backface_culling=false},
951 minetest.register_node("lava_flowing", {
952 drawtype = "flowingliquid",
953 tile_images = {"lava.png"},
954 inventory_image = inventorycube("lava.png"),
956 light_propagates = false,
957 light_source = LIGHT_MAX - 1,
962 liquidtype = "flowing",
963 liquid_alternative_flowing = "lava_flowing",
964 liquid_alternative_source = "lava_source",
965 liquid_viscosity = LAVA_VISC,
966 damage_per_second = 4*2,
967 post_effect_color = {a=192, r=255, g=64, b=0},
968 special_materials = {
969 {image="lava.png", backface_culling=false},
970 {image="lava.png", backface_culling=true},
974 minetest.register_node("lava_source", {
976 tile_images = {"lava.png"},
977 inventory_image = inventorycube("lava.png"),
979 light_propagates = false,
980 light_source = LIGHT_MAX - 1,
985 liquidtype = "source",
986 liquid_alternative_flowing = "lava_flowing",
987 liquid_alternative_source = "lava_source",
988 liquid_viscosity = LAVA_VISC,
989 damage_per_second = 4*2,
990 post_effect_color = {a=192, r=255, g=64, b=0},
991 special_materials = {
992 -- New-style lava source material (mostly unused)
993 {image="lava.png", backface_culling=false},
995 furnace_burntime = 60,
998 minetest.register_node("torch", {
999 drawtype = "torchlike",
1000 tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
1001 inventory_image = "torch_on_floor.png",
1002 paramtype = "light",
1003 light_propagates = true,
1004 sunlight_propagates = true,
1006 wall_mounted = true,
1007 light_source = LIGHT_MAX-1,
1009 type = "wallmounted",
1010 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1011 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1012 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1014 material = digprop_constanttime(0.0),
1015 furnace_burntime = 4,
1018 minetest.register_node("sign_wall", {
1019 drawtype = "signlike",
1020 tile_images = {"sign_wall.png"},
1021 inventory_image = "sign_wall.png",
1022 paramtype = "light",
1023 light_propagates = true,
1024 sunlight_propagates = true,
1026 wall_mounted = true,
1027 metadata_name = "sign",
1029 type = "wallmounted",
1030 --wall_top = <default>
1031 --wall_bottom = <default>
1032 --wall_side = <default>
1034 material = digprop_constanttime(0.5),
1035 furnace_burntime = 10,
1038 minetest.register_node("chest", {
1039 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1040 "chest_side.png", "chest_side.png", "chest_front.png"},
1041 inventory_image = "chest_top.png",
1042 --inventory_image = inventorycube("chest_top.png", "chest_side.png", "chest_front.png"),
1043 paramtype = "facedir_simple",
1044 metadata_name = "chest",
1045 material = digprop_woodlike(1.0),
1046 furnace_burntime = 30,
1049 minetest.register_node("locked_chest", {
1050 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1051 "chest_side.png", "chest_side.png", "chest_lock.png"},
1052 inventory_image = "chest_lock.png",
1053 paramtype = "facedir_simple",
1054 metadata_name = "locked_chest",
1055 material = digprop_woodlike(1.0),
1056 furnace_burntime = 30,
1059 minetest.register_node("furnace", {
1060 tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
1061 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1062 inventory_image = "furnace_front.png",
1063 paramtype = "facedir_simple",
1064 metadata_name = "furnace",
1065 material = digprop_stonelike(3.0),
1068 minetest.register_node("cobble", {
1069 tile_images = {"cobble.png"},
1070 inventory_image = inventorycube("cobble.png"),
1071 is_ground_content = true,
1072 cookresult_item = 'NodeItem "stone" 1',
1073 material = digprop_stonelike(0.9),
1076 minetest.register_node("mossycobble", {
1077 tile_images = {"mossycobble.png"},
1078 inventory_image = inventorycube("mossycobble.png"),
1079 is_ground_content = true,
1080 material = digprop_stonelike(0.8),
1083 minetest.register_node("steelblock", {
1084 tile_images = {"steel_block.png"},
1085 inventory_image = inventorycube("steel_block.png"),
1086 is_ground_content = true,
1087 material = digprop_stonelike(5.0),
1090 minetest.register_node("nyancat", {
1091 tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
1092 "nc_side.png", "nc_back.png", "nc_front.png"},
1093 inventory_image = "nc_front.png",
1094 paramtype = "facedir_simple",
1095 material = digprop_stonelike(3.0),
1096 furnace_burntime = 1,
1099 minetest.register_node("nyancat_rainbow", {
1100 tile_images = {"nc_rb.png"},
1101 inventory_image = "nc_rb.png",
1102 material = digprop_stonelike(3.0),
1103 furnace_burntime = 1,
1106 minetest.register_node("sapling", {
1107 drawtype = "plantlike",
1109 tile_images = {"sapling.png"},
1110 inventory_image = "sapling.png",
1111 paramtype = "light",
1112 light_propagates = true,
1114 material = digprop_constanttime(0.0),
1115 furnace_burntime = 10,
1118 minetest.register_node("apple", {
1119 drawtype = "plantlike",
1121 tile_images = {"apple.png"},
1122 inventory_image = "apple.png",
1123 paramtype = "light",
1124 light_propagates = true,
1125 sunlight_propagates = true,
1127 dug_item = 'CraftItem "apple" 1',
1128 material = digprop_constanttime(0.0),
1129 furnace_burntime = 3,
1136 minetest.register_craftitem("Stick", {
1137 image = "stick.png",
1138 --furnace_burntime = ...,
1139 on_place_on_ground = minetest.craftitem_place_item,
1142 minetest.register_craftitem("paper", {
1143 image = "paper.png",
1144 on_place_on_ground = minetest.craftitem_place_item,
1147 minetest.register_craftitem("book", {
1149 on_place_on_ground = minetest.craftitem_place_item,
1152 minetest.register_craftitem("lump_of_coal", {
1153 image = "lump_of_coal.png",
1154 furnace_burntime = 40;
1155 on_place_on_ground = minetest.craftitem_place_item,
1158 minetest.register_craftitem("lump_of_iron", {
1159 image = "lump_of_iron.png",
1160 cookresult_item = 'CraftItem "steel_ingot" 1',
1161 on_place_on_ground = minetest.craftitem_place_item,
1164 minetest.register_craftitem("lump_of_clay", {
1165 image = "lump_of_clay.png",
1166 cookresult_item = 'CraftItem "clay_brick" 1',
1167 on_place_on_ground = minetest.craftitem_place_item,
1170 minetest.register_craftitem("steel_ingot", {
1171 image = "steel_ingot.png",
1172 on_place_on_ground = minetest.craftitem_place_item,
1175 minetest.register_craftitem("clay_brick", {
1176 image = "clay_brick.png",
1177 on_place_on_ground = minetest.craftitem_place_item,
1180 minetest.register_craftitem("rat", {
1182 cookresult_item = 'CraftItem "cooked_rat" 1',
1183 on_drop = function(item, dropper, pos)
1184 minetest.env:add_rat(pos)
1189 minetest.register_craftitem("cooked_rat", {
1190 image = "cooked_rat.png",
1191 cookresult_item = 'CraftItem "scorched_stuff" 1',
1192 on_place_on_ground = minetest.craftitem_place_item,
1193 on_use = minetest.craftitem_eat(6),
1196 minetest.register_craftitem("scorched_stuff", {
1197 image = "scorched_stuff.png",
1198 on_place_on_ground = minetest.craftitem_place_item,
1201 minetest.register_craftitem("firefly", {
1202 image = "firefly.png",
1203 on_drop = function(item, dropper, pos)
1204 minetest.env:add_firefly(pos)
1209 minetest.register_craftitem("apple", {
1210 image = "apple.png",
1211 on_place_on_ground = minetest.craftitem_place_item,
1212 on_use = minetest.craftitem_eat(4),
1215 minetest.register_craftitem("apple_iron", {
1216 image = "apple_iron.png",
1217 on_place_on_ground = minetest.craftitem_place_item,
1218 on_use = minetest.craftitem_eat(8),
1221 print(dump(minetest.registered_craftitems))
1225 -- Some common functions
1228 function nodeupdate_single(p)
1229 n = minetest.env:get_node(p)
1230 if n.name == "sand" or n.name == "gravel" then
1231 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1232 n_bottom = minetest.env:get_node(p_bottom)
1233 if n_bottom.name == "air" then
1234 minetest.env:remove_node(p)
1235 minetest.env:add_luaentity(p, "falling_"..n.name)
1241 function nodeupdate(p)
1245 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1246 nodeupdate_single(p2)
1256 function register_falling_node(nodename, texture)
1257 minetest.register_entity("falling_"..nodename, {
1258 -- Static definition
1260 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1262 textures = {texture,texture,texture,texture,texture,texture},
1265 on_step = function(self, dtime)
1267 self.object:setacceleration({x=0, y=-10, z=0})
1268 -- Turn to actual sand when collides to ground or just move
1269 local pos = self.object:getpos()
1270 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1271 local bcn = minetest.env:get_node(bcp)
1272 if bcn.name ~= "air" then
1273 -- Turn to a sand node
1274 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1275 minetest.env:add_node(np, {name=nodename})
1276 self.object:remove()
1284 register_falling_node("sand", "sand.png")
1285 register_falling_node("gravel", "gravel.png")
1291 -- Global environment step function
1292 function on_step(dtime)
1295 minetest.register_globalstep(on_step)
1297 function on_placenode(p, node)
1298 print("on_placenode")
1301 minetest.register_on_placenode(on_placenode)
1303 function on_dignode(p, node)
1307 minetest.register_on_dignode(on_dignode)
1309 function on_punchnode(p, node)
1310 print("on_punchnode")
1311 if node.name == "TNT" then
1312 minetest.env:remove_node(p)
1313 minetest.env:add_luaentity(p, "TNT")
1314 --minetest.env:add_luaentity(p, "testentity")
1315 --minetest.env:add_firefly(p)
1319 minetest.register_on_punchnode(on_punchnode)
1321 minetest.register_on_chat_message(function(name, message)
1322 print("default on_chat_message: name="..dump(name).." message="..dump(message))
1323 local cmd = "/giveme"
1324 if message:sub(0, #cmd) == cmd then
1325 if not minetest.get_player_privs(name)["give"] then
1326 minetest.chat_send_player(name, "you don't have permission to give")
1327 return true -- Handled chat message
1329 stackstring = string.match(message, cmd.." (.*)")
1330 if stackstring == nil then
1331 minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
1332 return true -- Handled chat message
1334 print(cmd..' invoked, stackstring="'..stackstring..'"')
1335 player = minetest.env:get_player_by_name(name)
1336 added, error_msg = player:add_to_inventory(stackstring)
1338 minetest.chat_send_player(name, '"'..stackstring
1339 ..'" added to inventory.');
1341 minetest.chat_send_player(name, 'Could not give "'..stackstring
1342 ..'": '..error_msg);
1344 return true -- Handled chat message
1347 if message:sub(0, #cmd) == cmd then
1348 print("minetest.get_player_privs(name)="
1349 ..dump(minetest.get_player_privs(name)))
1350 if not minetest.get_player_privs(name)["give"] then
1351 minetest.chat_send_player(name, "you don't have permission to give")
1352 return true -- Handled chat message
1354 name2, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
1355 if name == nil or stackstring == nil then
1356 minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
1357 return true -- Handled chat message
1359 print(cmd..' invoked, name2="'..name2
1360 ..'" stackstring="'..stackstring..'"')
1361 player = minetest.env:get_player_by_name(name2)
1362 if player == nil then
1363 minetest.chat_send_player(name, name2..' is not a known player')
1364 return true -- Handled chat message
1366 added, error_msg = player:add_to_inventory(stackstring)
1368 minetest.chat_send_player(name, '"'..stackstring
1369 ..'" added to '..name2..'\'s inventory.');
1370 minetest.chat_send_player(name2, '"'..stackstring
1371 ..'" added to inventory.');
1373 minetest.chat_send_player(name, 'Could not give "'..stackstring
1374 ..'": '..error_msg);
1376 return true -- Handled chat message
1381 -- Done, print some random stuff
1384 --print("minetest.registered_entities:")
1385 --dump2(minetest.registered_entities)