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),
712 minetest.register_node("gravel", {
713 tile_images = {"gravel.png"},
714 inventory_image = inventorycube("gravel.png"),
715 is_ground_content = true,
716 material = digprop_gravellike(1.0),
719 minetest.register_node("sandstone", {
720 tile_images = {"sandstone.png"},
721 inventory_image = inventorycube("sandstone.png"),
722 is_ground_content = true,
723 material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
724 dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional?
727 minetest.register_node("clay", {
728 tile_images = {"clay.png"},
729 inventory_image = inventorycube("clay.png"),
730 is_ground_content = true,
731 material = digprop_dirtlike(1.0),
732 dug_item = 'CraftItem "lump_of_clay" 4',
735 minetest.register_node("brick", {
736 tile_images = {"brick.png"},
737 inventory_image = inventorycube("brick.png"),
738 is_ground_content = true,
739 material = digprop_stonelike(1.0),
740 dug_item = 'CraftItem "clay_brick" 4',
743 minetest.register_node("tree", {
744 tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
745 inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
746 is_ground_content = true,
747 material = digprop_woodlike(1.0),
748 cookresult_item = 'CraftItem "lump_of_coal" 1',
749 furnace_burntime = 30,
752 minetest.register_node("jungletree", {
753 tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
754 inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
755 is_ground_content = true,
756 material = digprop_woodlike(1.0),
757 cookresult_item = 'CraftItem "lump_of_coal" 1',
758 furnace_burntime = 30,
761 minetest.register_node("junglegrass", {
762 drawtype = "plantlike",
764 tile_images = {"junglegrass.png"},
765 inventory_image = "junglegrass.png",
766 light_propagates = true,
769 material = digprop_leaveslike(1.0),
770 furnace_burntime = 2,
773 minetest.register_node("leaves", {
774 drawtype = "allfaces_optional",
776 tile_images = {"leaves.png"},
777 inventory_image = "leaves.png",
778 light_propagates = true,
780 material = digprop_leaveslike(1.0),
781 extra_dug_item = 'NodeItem "sapling" 1',
782 extra_dug_item_rarity = 20,
783 furnace_burntime = 1,
786 minetest.register_node("cactus", {
787 tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
788 inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
789 is_ground_content = true,
790 material = digprop_woodlike(0.75),
791 furnace_burntime = 15,
794 minetest.register_node("papyrus", {
795 drawtype = "plantlike",
796 tile_images = {"papyrus.png"},
797 inventory_image = "papyrus.png",
798 light_propagates = true,
800 is_ground_content = true,
802 material = digprop_leaveslike(0.5),
803 furnace_burntime = 1,
806 minetest.register_node("bookshelf", {
807 tile_images = {"wood.png", "wood.png", "bookshelf.png"},
808 -- FIXME: inventorycube only cares for the first texture
809 --inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
810 inventory_image = inventorycube("bookshelf.png"),
811 is_ground_content = true,
812 material = digprop_woodlike(0.75),
813 furnace_burntime = 30,
816 minetest.register_node("glass", {
817 drawtype = "glasslike",
818 tile_images = {"glass.png"},
819 inventory_image = inventorycube("glass.png"),
820 light_propagates = true,
822 sunlight_propagates = true,
823 is_ground_content = true,
824 material = digprop_glasslike(1.0),
827 minetest.register_node("wooden_fence", {
828 drawtype = "fencelike",
829 tile_images = {"wood.png"},
830 inventory_image = "fence.png",
831 light_propagates = true,
833 is_ground_content = true,
836 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
838 furnace_burntime = 15,
839 material = digprop_woodlike(0.75),
842 minetest.register_node("rail", {
843 drawtype = "raillike",
844 tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
845 inventory_image = "rail.png",
846 light_propagates = true,
848 is_ground_content = true,
854 material = digprop_dirtlike(0.75),
857 minetest.register_node("ladder", {
858 drawtype = "signlike",
859 tile_images = {"ladder.png"},
860 inventory_image = "ladder.png",
861 light_propagates = true,
863 is_ground_content = true,
868 type = "wallmounted",
869 --wall_top = = <default>
870 --wall_bottom = = <default>
871 --wall_side = = <default>
873 furnace_burntime = 5,
874 material = digprop_woodlike(0.5),
877 minetest.register_node("coalstone", {
878 tile_images = {"stone.png^mineral_coal.png"},
879 inventory_image = "stone.png^mineral_coal.png",
880 is_ground_content = true,
881 material = digprop_stonelike(1.5),
884 minetest.register_node("wood", {
885 tile_images = {"wood.png"},
886 inventory_image = inventorycube("wood.png"),
887 is_ground_content = true,
888 furnace_burntime = 7,
889 material = digprop_woodlike(0.75),
892 minetest.register_node("mese", {
893 tile_images = {"mese.png"},
894 inventory_image = inventorycube("mese.png"),
895 is_ground_content = true,
896 furnace_burntime = 30,
897 material = digprop_stonelike(0.5),
900 minetest.register_node("cloud", {
901 tile_images = {"cloud.png"},
902 inventory_image = inventorycube("cloud.png"),
903 is_ground_content = true,
906 minetest.register_node("water_flowing", {
907 drawtype = "flowingliquid",
908 tile_images = {"water.png"},
910 inventory_image = inventorycube("water.png"),
912 light_propagates = true,
917 liquidtype = "flowing",
918 liquid_alternative_flowing = "water_flowing",
919 liquid_alternative_source = "water_source",
920 liquid_viscosity = WATER_VISC,
921 post_effect_color = {a=64, r=100, g=100, b=200},
922 special_materials = {
923 {image="water.png", backface_culling=false},
924 {image="water.png", backface_culling=true},
928 minetest.register_node("water_source", {
930 tile_images = {"water.png"},
932 inventory_image = inventorycube("water.png"),
934 light_propagates = true,
939 liquidtype = "source",
940 liquid_alternative_flowing = "water_flowing",
941 liquid_alternative_source = "water_source",
942 liquid_viscosity = WATER_VISC,
943 post_effect_color = {a=64, r=100, g=100, b=200},
944 special_materials = {
945 -- New-style water source material (mostly unused)
946 {image="water.png", backface_culling=false},
950 minetest.register_node("lava_flowing", {
951 drawtype = "flowingliquid",
952 tile_images = {"lava.png"},
953 inventory_image = inventorycube("lava.png"),
955 light_propagates = false,
956 light_source = LIGHT_MAX - 1,
961 liquidtype = "flowing",
962 liquid_alternative_flowing = "lava_flowing",
963 liquid_alternative_source = "lava_source",
964 liquid_viscosity = LAVA_VISC,
965 damage_per_second = 4*2,
966 post_effect_color = {a=192, r=255, g=64, b=0},
967 special_materials = {
968 {image="lava.png", backface_culling=false},
969 {image="lava.png", backface_culling=true},
973 minetest.register_node("lava_source", {
975 tile_images = {"lava.png"},
976 inventory_image = inventorycube("lava.png"),
978 light_propagates = false,
979 light_source = LIGHT_MAX - 1,
984 liquidtype = "source",
985 liquid_alternative_flowing = "lava_flowing",
986 liquid_alternative_source = "lava_source",
987 liquid_viscosity = LAVA_VISC,
988 damage_per_second = 4*2,
989 post_effect_color = {a=192, r=255, g=64, b=0},
990 special_materials = {
991 -- New-style lava source material (mostly unused)
992 {image="lava.png", backface_culling=false},
994 furnace_burntime = 60,
997 minetest.register_node("torch", {
998 drawtype = "torchlike",
999 tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
1000 inventory_image = "torch_on_floor.png",
1001 paramtype = "light",
1002 light_propagates = true,
1003 sunlight_propagates = true,
1005 wall_mounted = true,
1006 light_source = LIGHT_MAX-1,
1008 type = "wallmounted",
1009 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1010 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1011 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1013 material = digprop_constanttime(0.0),
1014 furnace_burntime = 4,
1017 minetest.register_node("sign_wall", {
1018 drawtype = "signlike",
1019 tile_images = {"sign_wall.png"},
1020 inventory_image = "sign_wall.png",
1021 paramtype = "light",
1022 light_propagates = true,
1023 sunlight_propagates = true,
1025 wall_mounted = true,
1026 metadata_name = "sign",
1028 type = "wallmounted",
1029 --wall_top = <default>
1030 --wall_bottom = <default>
1031 --wall_side = <default>
1033 material = digprop_constanttime(0.5),
1034 furnace_burntime = 10,
1037 minetest.register_node("chest", {
1038 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1039 "chest_side.png", "chest_side.png", "chest_front.png"},
1040 inventory_image = "chest_top.png",
1041 --inventory_image = inventorycube("chest_top.png", "chest_side.png", "chest_front.png"),
1042 paramtype = "facedir_simple",
1043 metadata_name = "chest",
1044 material = digprop_woodlike(1.0),
1045 furnace_burntime = 30,
1048 minetest.register_node("locked_chest", {
1049 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1050 "chest_side.png", "chest_side.png", "chest_lock.png"},
1051 inventory_image = "chest_lock.png",
1052 paramtype = "facedir_simple",
1053 metadata_name = "locked_chest",
1054 material = digprop_woodlike(1.0),
1055 furnace_burntime = 30,
1058 minetest.register_node("furnace", {
1059 tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
1060 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1061 inventory_image = "furnace_front.png",
1062 paramtype = "facedir_simple",
1063 metadata_name = "furnace",
1064 material = digprop_stonelike(3.0),
1067 minetest.register_node("cobble", {
1068 tile_images = {"cobble.png"},
1069 inventory_image = inventorycube("cobble.png"),
1070 is_ground_content = true,
1071 cookresult_item = 'NodeItem "stone" 1',
1072 material = digprop_stonelike(0.9),
1075 minetest.register_node("mossycobble", {
1076 tile_images = {"mossycobble.png"},
1077 inventory_image = inventorycube("mossycobble.png"),
1078 is_ground_content = true,
1079 material = digprop_stonelike(0.8),
1082 minetest.register_node("steelblock", {
1083 tile_images = {"steel_block.png"},
1084 inventory_image = inventorycube("steel_block.png"),
1085 is_ground_content = true,
1086 material = digprop_stonelike(5.0),
1089 minetest.register_node("nyancat", {
1090 tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
1091 "nc_side.png", "nc_back.png", "nc_front.png"},
1092 inventory_image = "nc_front.png",
1093 paramtype = "facedir_simple",
1094 material = digprop_stonelike(3.0),
1095 furnace_burntime = 1,
1098 minetest.register_node("nyancat_rainbow", {
1099 tile_images = {"nc_rb.png"},
1100 inventory_image = "nc_rb.png",
1101 material = digprop_stonelike(3.0),
1102 furnace_burntime = 1,
1105 minetest.register_node("sapling", {
1106 drawtype = "plantlike",
1108 tile_images = {"sapling.png"},
1109 inventory_image = "sapling.png",
1110 paramtype = "light",
1111 light_propagates = true,
1113 material = digprop_constanttime(0.0),
1114 furnace_burntime = 10,
1117 minetest.register_node("apple", {
1118 drawtype = "plantlike",
1120 tile_images = {"apple.png"},
1121 inventory_image = "apple.png",
1122 paramtype = "light",
1123 light_propagates = true,
1124 sunlight_propagates = true,
1126 dug_item = 'CraftItem "apple" 1',
1127 material = digprop_constanttime(0.0),
1128 furnace_burntime = 3,
1135 minetest.register_craftitem("Stick", {
1136 image = "stick.png",
1137 --furnace_burntime = ...,
1138 on_place_on_ground = minetest.craftitem_place_item,
1141 minetest.register_craftitem("paper", {
1142 image = "paper.png",
1143 on_place_on_ground = minetest.craftitem_place_item,
1146 minetest.register_craftitem("book", {
1148 on_place_on_ground = minetest.craftitem_place_item,
1151 minetest.register_craftitem("lump_of_coal", {
1152 image = "lump_of_coal.png",
1153 furnace_burntime = 40;
1154 on_place_on_ground = minetest.craftitem_place_item,
1157 minetest.register_craftitem("lump_of_iron", {
1158 image = "lump_of_iron.png",
1159 cookresult_item = 'CraftItem "steel_ingot" 1',
1160 on_place_on_ground = minetest.craftitem_place_item,
1163 minetest.register_craftitem("lump_of_clay", {
1164 image = "lump_of_clay.png",
1165 cookresult_item = 'CraftItem "clay_brick" 1',
1166 on_place_on_ground = minetest.craftitem_place_item,
1169 minetest.register_craftitem("steel_ingot", {
1170 image = "steel_ingot.png",
1171 on_place_on_ground = minetest.craftitem_place_item,
1174 minetest.register_craftitem("clay_brick", {
1175 image = "clay_brick.png",
1176 on_place_on_ground = minetest.craftitem_place_item,
1179 minetest.register_craftitem("rat", {
1181 cookresult_item = 'CraftItem "cooked_rat" 1',
1182 on_drop = function(item, dropper, pos)
1183 minetest.env:add_rat(pos)
1188 minetest.register_craftitem("cooked_rat", {
1189 image = "cooked_rat.png",
1190 cookresult_item = 'CraftItem "scorched_stuff" 1',
1191 on_place_on_ground = minetest.craftitem_place_item,
1192 on_use = minetest.craftitem_eat(6),
1195 minetest.register_craftitem("scorched_stuff", {
1196 image = "scorched_stuff.png",
1197 on_place_on_ground = minetest.craftitem_place_item,
1200 minetest.register_craftitem("firefly", {
1201 image = "firefly.png",
1202 on_drop = function(item, dropper, pos)
1203 minetest.env:add_firefly(pos)
1208 minetest.register_craftitem("apple", {
1209 image = "apple.png",
1210 on_place_on_ground = minetest.craftitem_place_item,
1211 on_use = minetest.craftitem_eat(4),
1214 minetest.register_craftitem("apple_iron", {
1215 image = "apple_iron.png",
1216 on_place_on_ground = minetest.craftitem_place_item,
1217 on_use = minetest.craftitem_eat(8),
1220 print(dump(minetest.registered_craftitems))
1224 -- Some common functions
1227 function nodeupdate_single(p)
1228 n = minetest.env:get_node(p)
1229 if n.name == "sand" or n.name == "gravel" then
1230 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1231 n_bottom = minetest.env:get_node(p_bottom)
1232 if n_bottom.name == "air" then
1233 minetest.env:remove_node(p)
1234 minetest.env:add_luaentity(p, "falling_"..n.name)
1240 function nodeupdate(p)
1244 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1245 nodeupdate_single(p2)
1255 function register_falling_node(nodename, texture)
1256 minetest.register_entity("falling_"..nodename, {
1257 -- Static definition
1259 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1261 textures = {texture,texture,texture,texture,texture,texture},
1264 on_step = function(self, dtime)
1266 self.object:setacceleration({x=0, y=-10, z=0})
1267 -- Turn to actual sand when collides to ground or just move
1268 local pos = self.object:getpos()
1269 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1270 local bcn = minetest.env:get_node(bcp)
1271 if bcn.name ~= "air" then
1272 -- Turn to a sand node
1273 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1274 minetest.env:add_node(np, {name=nodename})
1275 self.object:remove()
1283 register_falling_node("sand", "sand.png")
1284 register_falling_node("gravel", "gravel.png")
1290 -- Global environment step function
1291 function on_step(dtime)
1294 minetest.register_globalstep(on_step)
1296 function on_placenode(p, node)
1297 print("on_placenode")
1300 minetest.register_on_placenode(on_placenode)
1302 function on_dignode(p, node)
1306 minetest.register_on_dignode(on_dignode)
1308 function on_punchnode(p, node)
1309 print("on_punchnode")
1310 if node.name == "TNT" then
1311 minetest.env:remove_node(p)
1312 minetest.env:add_luaentity(p, "TNT")
1313 --minetest.env:add_luaentity(p, "testentity")
1314 --minetest.env:add_firefly(p)
1318 minetest.register_on_punchnode(on_punchnode)
1320 minetest.register_on_chat_message(function(name, message)
1321 print("default on_chat_message: name="..dump(name).." message="..dump(message))
1322 local cmd = "/giveme"
1323 if message:sub(0, #cmd) == cmd then
1324 if not minetest.get_player_privs(name)["give"] then
1325 minetest.chat_send_player(name, "you don't have permission to give")
1326 return true -- Handled chat message
1328 stackstring = string.match(message, cmd.." (.*)")
1329 if stackstring == nil then
1330 minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
1331 return true -- Handled chat message
1333 print(cmd..' invoked, stackstring="'..stackstring..'"')
1334 player = minetest.env:get_player_by_name(name)
1335 added, error_msg = player:add_to_inventory(stackstring)
1337 minetest.chat_send_player(name, '"'..stackstring
1338 ..'" added to inventory.');
1340 minetest.chat_send_player(name, 'Could not give "'..stackstring
1341 ..'": '..error_msg);
1343 return true -- Handled chat message
1346 if message:sub(0, #cmd) == cmd then
1347 print("minetest.get_player_privs(name)="
1348 ..dump(minetest.get_player_privs(name)))
1349 if not minetest.get_player_privs(name)["give"] then
1350 minetest.chat_send_player(name, "you don't have permission to give")
1351 return true -- Handled chat message
1353 name2, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
1354 if name == nil or stackstring == nil then
1355 minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
1356 return true -- Handled chat message
1358 print(cmd..' invoked, name2="'..name2
1359 ..'" stackstring="'..stackstring..'"')
1360 player = minetest.env:get_player_by_name(name2)
1361 if player == nil then
1362 minetest.chat_send_player(name, name2..' is not a known player')
1363 return true -- Handled chat message
1365 added, error_msg = player:add_to_inventory(stackstring)
1367 minetest.chat_send_player(name, '"'..stackstring
1368 ..'" added to '..name2..'\'s inventory.');
1369 minetest.chat_send_player(name2, '"'..stackstring
1370 ..'" added to inventory.');
1372 minetest.chat_send_player(name, 'Could not give "'..stackstring
1373 ..'": '..error_msg);
1375 return true -- Handled chat message
1380 -- Done, print some random stuff
1383 --print("minetest.registered_entities:")
1384 --dump2(minetest.registered_entities)