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"
10 -- minetest.register_entity(name, prototype_table)
11 -- minetest.register_tool(name, {lots of stuff})
12 -- minetest.register_node(name, {lots of stuff})
13 -- minetest.register_craft({output=item, recipe={...})
14 -- minetest.register_globalstep(func)
15 -- minetest.register_on_placenode(func(pos, newnode, placer))
16 -- minetest.register_on_dignode(func(pos, oldnode, digger))
17 -- minetest.register_on_punchnode(func(pos, node, puncher))
18 -- minetest.register_on_generated(func(minp, maxp))
19 -- minetest.register_on_newplayer(func(ObjectRef))
20 -- minetest.register_on_respawnplayer(func(ObjectRef))
21 -- ^ return true in func to disable regular player placement
22 -- minetest.register_on_chat_message(func(name, message))
23 -- minetest.setting_get(name)
24 -- minetest.setting_getbool(name)
25 -- minetest.chat_send_all(text)
26 -- minetest.chat_send_player(name, text)
29 -- minetest.env - environment reference
32 -- minetest.registered_nodes
33 -- ^ List of registed node definitions, indexed by name
34 -- minetest.registered_entities
35 -- ^ List of registered entity prototypes, indexed by name
36 -- minetest.object_refs
37 -- ^ List of object references, indexed by active object id
38 -- minetest.luaentities
39 -- ^ List of lua entities, indexed by active object id
41 -- EnvRef is basically ServerEnvironment and ServerMap combined.
43 -- - add_node(pos, node)
46 -- - add_luaentity(pos, name)
47 -- - get_meta(pos) -- Get a NodeMetaRef at that position
50 -- - settext(text) -- eg. set the text of a sign
52 -- ObjectRef is basically ServerActiveObject.
54 -- - remove(): remove object (after returning from Lua)
55 -- - getpos(): returns {x=num, y=num, z=num}
56 -- - setpos(pos); pos={x=num, y=num, z=num}
57 -- - moveto(pos, continuous=false): interpolated move
58 -- - add_to_inventory(itemstring): add an item to object inventory
59 -- - settexturemod(mod)
60 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
61 -- - select_horiz_by_yawpitch=false)
63 -- Registered entities:
64 -- - Functions receive a "luaentity" as self:
65 -- - It has the member .object, which is an ObjectRef pointing to the object
66 -- - The original prototype stuff is visible directly via a metatable
68 -- - on_activate(self, staticdata)
69 -- - on_step(self, dtime)
70 -- - on_punch(self, hitter)
71 -- - on_rightclick(self, clicker)
72 -- - get_staticdata(self): return string
74 -- MapNode representation:
75 -- {name="name", param1=num, param2=num}
77 -- Position representation:
78 -- {x=num, y=num, z=num}
81 -- print("minetest dump: "..dump(minetest))
92 minetest.register_tool("WPick", {
93 image = "tool_woodpick.png",
105 minetest.register_tool("STPick", {
106 image = "tool_stonepick.png",
109 dt_crackiness = -0.5,
112 basedurability = 100,
118 minetest.register_tool("SteelPick", {
119 image = "tool_steelpick.png",
122 dt_crackiness = -0.5,
125 basedurability = 333,
131 minetest.register_tool("MesePick", {
132 image = "tool_mesepick.png",
138 basedurability = 1337,
144 minetest.register_tool("WShovel", {
145 image = "tool_woodshovel.png",
149 dt_crumbliness = -1.5,
150 dt_cuttability = 0.3,
157 minetest.register_tool("STShovel", {
158 image = "tool_stoneshovel.png",
162 dt_crumbliness = -1.5,
163 dt_cuttability = 0.1,
164 basedurability = 100,
170 minetest.register_tool("SteelShovel", {
171 image = "tool_steelshovel.png",
175 dt_crumbliness = -1.5,
176 dt_cuttability = 0.0,
177 basedurability = 330,
183 minetest.register_tool("WAxe", {
184 image = "tool_woodaxe.png",
187 dt_crackiness = -0.2,
189 dt_cuttability = -0.5,
196 minetest.register_tool("STAxe", {
197 image = "tool_stoneaxe.png",
200 dt_crackiness = -0.2,
202 dt_cuttability = -0.5,
203 basedurability = 100,
209 minetest.register_tool("SteelAxe", {
210 image = "tool_steelaxe.png",
213 dt_crackiness = -0.2,
215 dt_cuttability = -0.5,
216 basedurability = 330,
222 minetest.register_tool("WSword", {
223 image = "tool_woodsword.png",
235 minetest.register_tool("STSword", {
236 image = "tool_stonesword.png",
242 basedurability = 100,
248 minetest.register_tool("SteelSword", {
249 image = "tool_steelsword.png",
255 basedurability = 330,
261 minetest.register_tool("", {
276 minetest.register_tool("horribletool", {
292 -- Crafting definition
295 minetest.register_craft({
296 output = 'NodeItem "wood" 4',
302 minetest.register_craft({
303 output = 'CraftItem "Stick" 4',
309 minetest.register_craft({
310 output = 'NodeItem "wooden_fence" 2',
312 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
313 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
317 minetest.register_craft({
318 output = 'NodeItem "sign_wall" 1',
320 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
321 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
322 {'', 'CraftItem "Stick"', ''},
326 minetest.register_craft({
327 output = 'NodeItem "torch" 4',
329 {'CraftItem "lump_of_coal"'},
330 {'CraftItem "Stick"'},
334 minetest.register_craft({
335 output = 'ToolItem "WPick"',
337 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
338 {'', 'CraftItem "Stick"', ''},
339 {'', 'CraftItem "Stick"', ''},
343 minetest.register_craft({
344 output = 'ToolItem "STPick"',
346 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
347 {'', 'CraftItem "Stick"', ''},
348 {'', 'CraftItem "Stick"', ''},
352 minetest.register_craft({
353 output = 'ToolItem "SteelPick"',
355 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
356 {'', 'CraftItem "Stick"', ''},
357 {'', 'CraftItem "Stick"', ''},
361 minetest.register_craft({
362 output = 'ToolItem "MesePick"',
364 {'NodeItem "mese"', 'NodeItem "mese"', 'NodeItem "mese"'},
365 {'', 'CraftItem "Stick"', ''},
366 {'', 'CraftItem "Stick"', ''},
370 minetest.register_craft({
371 output = 'ToolItem "WShovel"',
374 {'CraftItem "Stick"'},
375 {'CraftItem "Stick"'},
379 minetest.register_craft({
380 output = 'ToolItem "STShovel"',
382 {'NodeItem "cobble"'},
383 {'CraftItem "Stick"'},
384 {'CraftItem "Stick"'},
388 minetest.register_craft({
389 output = 'ToolItem "SteelShovel"',
391 {'CraftItem "steel_ingot"'},
392 {'CraftItem "Stick"'},
393 {'CraftItem "Stick"'},
397 minetest.register_craft({
398 output = 'ToolItem "WAxe"',
400 {'NodeItem "wood"', 'NodeItem "wood"'},
401 {'NodeItem "wood"', 'CraftItem "Stick"'},
402 {'', 'CraftItem "Stick"'},
406 minetest.register_craft({
407 output = 'ToolItem "STAxe"',
409 {'NodeItem "cobble"', 'NodeItem "cobble"'},
410 {'NodeItem "cobble"', 'CraftItem "Stick"'},
411 {'', 'CraftItem "Stick"'},
415 minetest.register_craft({
416 output = 'ToolItem "SteelAxe"',
418 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
419 {'CraftItem "steel_ingot"', 'CraftItem "Stick"'},
420 {'', 'CraftItem "Stick"'},
424 minetest.register_craft({
425 output = 'ToolItem "WSword"',
429 {'CraftItem "Stick"'},
433 minetest.register_craft({
434 output = 'ToolItem "STSword"',
436 {'NodeItem "cobble"'},
437 {'NodeItem "cobble"'},
438 {'CraftItem "Stick"'},
442 minetest.register_craft({
443 output = 'ToolItem "SteelSword"',
445 {'CraftItem "steel_ingot"'},
446 {'CraftItem "steel_ingot"'},
447 {'CraftItem "Stick"'},
451 minetest.register_craft({
452 output = 'NodeItem "rail" 15',
454 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
455 {'CraftItem "steel_ingot"', 'CraftItem "Stick"', 'CraftItem "steel_ingot"'},
456 {'CraftItem "steel_ingot"', '', 'CraftItem "steel_ingot"'},
460 minetest.register_craft({
461 output = 'NodeItem "chest" 1',
463 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
464 {'NodeItem "wood"', '', 'NodeItem "wood"'},
465 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
469 minetest.register_craft({
470 output = 'NodeItem "locked_chest" 1',
472 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
473 {'NodeItem "wood"', 'CraftItem "steel_ingot"', 'NodeItem "wood"'},
474 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
478 minetest.register_craft({
479 output = 'NodeItem "furnace" 1',
481 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
482 {'NodeItem "cobble"', '', 'NodeItem "cobble"'},
483 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
487 minetest.register_craft({
488 output = 'NodeItem "steelblock" 1',
490 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
491 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
492 {'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"', 'CraftItem "steel_ingot"'},
496 minetest.register_craft({
497 output = 'NodeItem "sandstone" 1',
499 {'NodeItem "sand"', 'NodeItem "sand"'},
500 {'NodeItem "sand"', 'NodeItem "sand"'},
504 minetest.register_craft({
505 output = 'NodeItem "clay" 1',
507 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
508 {'CraftItem "lump_of_clay"', 'CraftItem "lump_of_clay"'},
512 minetest.register_craft({
513 output = 'NodeItem "brick" 1',
515 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
516 {'CraftItem "clay_brick"', 'CraftItem "clay_brick"'},
520 minetest.register_craft({
521 output = 'CraftItem "paper" 1',
523 {'NodeItem "papyrus"', 'NodeItem "papyrus"', 'NodeItem "papyrus"'},
527 minetest.register_craft({
528 output = 'CraftItem "book" 1',
530 {'CraftItem "paper"'},
531 {'CraftItem "paper"'},
532 {'CraftItem "paper"'},
536 minetest.register_craft({
537 output = 'NodeItem "bookshelf" 1',
539 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
540 {'CraftItem "book"', 'CraftItem "book"', 'CraftItem "book"'},
541 {'NodeItem "wood"', 'NodeItem "wood"', 'NodeItem "wood"'},
545 minetest.register_craft({
546 output = 'NodeItem "ladder" 1',
548 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
549 {'CraftItem "Stick"', 'CraftItem "Stick"', 'CraftItem "Stick"'},
550 {'CraftItem "Stick"', '', 'CraftItem "Stick"'},
554 minetest.register_craft({
555 output = 'CraftItem "apple_iron" 1',
557 {'', 'CraftItem "steel_ingot"', ''},
558 {'CraftItem "steel_ingot"', 'CraftItem "apple"', 'CraftItem "steel_ingot"'},
559 {'', 'CraftItem "steel_ingot"', ''},
563 minetest.register_craft({
564 output = 'NodeItem "TNT" 4',
566 {'NodeItem "wood" 1'},
567 {'CraftItem "lump_of_coal" 1'},
568 {'NodeItem "wood" 1'}
572 minetest.register_craft({
573 output = 'NodeItem "somenode" 4',
575 {'CraftItem "Stick" 1'},
583 function digprop_constanttime(time)
585 diggability = "constant",
586 constant_time = time,
590 function digprop_stonelike(toughness)
592 diggablity = "normal",
593 weight = toughness * 5,
600 function digprop_dirtlike(toughness)
602 diggablity = "normal",
603 weight = toughness * 1.2,
610 function digprop_gravellike(toughness)
612 diggablity = "normal",
613 weight = toughness * 2,
620 function digprop_woodlike(toughness)
622 diggablity = "normal",
623 weight = toughness * 1.0,
630 function digprop_leaveslike(toughness)
632 diggablity = "normal",
633 weight = toughness * (-0.5),
640 function digprop_glasslike(toughness)
642 diggablity = "normal",
643 weight = toughness * 0.1,
650 function inventorycube(img1, img2, img3)
653 return "[inventorycube"
654 .. "{" .. img1:gsub("%^", "&")
655 .. "{" .. img2:gsub("%^", "&")
656 .. "{" .. img3:gsub("%^", "&")
661 minetest.register_node("stone", {
662 tile_images = {"stone.png"},
663 inventory_image = inventorycube("stone.png"),
664 paramtype = "mineral",
665 is_ground_content = true,
666 often_contains_mineral = true, -- Texture atlas hint
667 material = digprop_stonelike(1.0),
668 dug_item = 'NodeItem "cobble" 1',
671 minetest.register_node("dirt_with_grass", {
672 tile_images = {"grass.png", "mud.png", "mud.png^grass_side.png"},
673 inventory_image = inventorycube("mud.png^grass_side.png"),
674 is_ground_content = true,
675 material = digprop_dirtlike(1.0),
676 dug_item = 'NodeItem "dirt" 1',
679 minetest.register_node("dirt_with_grass_footsteps", {
680 tile_images = {"grass_footsteps.png", "mud.png", "mud.png^grass_side.png"},
681 inventory_image = "grass_footsteps.png",
682 is_ground_content = true,
683 material = digprop_dirtlike(1.0),
684 dug_item = 'NodeItem "dirt" 1',
687 minetest.register_node("dirt", {
688 tile_images = {"mud.png"},
689 inventory_image = inventorycube("mud.png"),
690 is_ground_content = true,
691 material = digprop_dirtlike(1.0),
694 minetest.register_node("sand", {
695 tile_images = {"sand.png"},
696 inventory_image = inventorycube("sand.png"),
697 is_ground_content = true,
698 material = digprop_dirtlike(1.0),
701 minetest.register_node("gravel", {
702 tile_images = {"gravel.png"},
703 inventory_image = inventorycube("gravel.png"),
704 is_ground_content = true,
705 material = digprop_gravellike(1.0),
708 minetest.register_node("sandstone", {
709 tile_images = {"sandstone.png"},
710 inventory_image = inventorycube("sandstone.png"),
711 is_ground_content = true,
712 material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
713 dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional?
716 minetest.register_node("clay", {
717 tile_images = {"clay.png"},
718 inventory_image = inventorycube("clay.png"),
719 is_ground_content = true,
720 material = digprop_dirtlike(1.0),
721 dug_item = 'CraftItem "lump_of_clay" 4',
724 minetest.register_node("brick", {
725 tile_images = {"brick.png"},
726 inventory_image = inventorycube("brick.png"),
727 is_ground_content = true,
728 material = digprop_stonelike(1.0),
729 dug_item = 'CraftItem "clay_brick" 4',
732 minetest.register_node("tree", {
733 tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
734 inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
735 is_ground_content = true,
736 material = digprop_woodlike(1.0),
737 cookresult_item = 'CraftItem "lump_of_coal" 1',
738 furnace_burntime = 30,
741 minetest.register_node("jungletree", {
742 tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
743 inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
744 is_ground_content = true,
745 material = digprop_woodlike(1.0),
746 cookresult_item = 'CraftItem "lump_of_coal" 1',
747 furnace_burntime = 30,
750 minetest.register_node("junglegrass", {
751 drawtype = "plantlike",
753 tile_images = {"junglegrass.png"},
754 inventory_image = "junglegrass.png",
755 light_propagates = true,
758 material = digprop_leaveslike(1.0),
759 furnace_burntime = 2,
762 minetest.register_node("leaves", {
763 drawtype = "allfaces_optional",
765 tile_images = {"leaves.png"},
766 inventory_image = "leaves.png",
767 light_propagates = true,
769 material = digprop_leaveslike(1.0),
770 extra_dug_item = 'NodeItem "sapling" 1',
771 extra_dug_item_rarity = 20,
772 furnace_burntime = 1,
775 minetest.register_node("cactus", {
776 tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
777 inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
778 is_ground_content = true,
779 material = digprop_woodlike(0.75),
780 furnace_burntime = 15,
783 minetest.register_node("papyrus", {
784 drawtype = "plantlike",
785 tile_images = {"papyrus.png"},
786 inventory_image = "papyrus.png",
787 light_propagates = true,
789 is_ground_content = true,
791 material = digprop_leaveslike(0.5),
792 furnace_burntime = 1,
795 minetest.register_node("bookshelf", {
796 tile_images = {"wood.png", "wood.png", "bookshelf.png"},
797 -- FIXME: inventorycube only cares for the first texture
798 --inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
799 inventory_image = inventorycube("bookshelf.png"),
800 is_ground_content = true,
801 material = digprop_woodlike(0.75),
802 furnace_burntime = 30,
805 minetest.register_node("glass", {
806 drawtype = "glasslike",
807 tile_images = {"glass.png"},
808 inventory_image = inventorycube("glass.png"),
809 light_propagates = true,
811 sunlight_propagates = true,
812 is_ground_content = true,
813 material = digprop_glasslike(1.0),
816 minetest.register_node("wooden_fence", {
817 drawtype = "fencelike",
818 tile_images = {"wood.png"},
819 inventory_image = "fence.png",
820 light_propagates = true,
822 is_ground_content = true,
825 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
827 furnace_burntime = 15,
828 material = digprop_woodlike(0.75),
831 minetest.register_node("rail", {
832 drawtype = "raillike",
833 tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
834 inventory_image = "rail.png",
835 light_propagates = true,
837 is_ground_content = true,
843 material = digprop_dirtlike(0.75),
846 minetest.register_node("ladder", {
847 drawtype = "signlike",
848 tile_images = {"ladder.png"},
849 inventory_image = "ladder.png",
850 light_propagates = true,
852 is_ground_content = true,
857 type = "wallmounted",
858 --wall_top = = <default>
859 --wall_bottom = = <default>
860 --wall_side = = <default>
862 furnace_burntime = 5,
863 material = digprop_woodlike(0.5),
866 minetest.register_node("coalstone", {
867 tile_images = {"stone.png^mineral_coal.png"},
868 inventory_image = "stone.png^mineral_coal.png",
869 is_ground_content = true,
870 material = digprop_stonelike(1.5),
873 minetest.register_node("wood", {
874 tile_images = {"wood.png"},
875 inventory_image = inventorycube("wood.png"),
876 is_ground_content = true,
877 furnace_burntime = 7,
878 material = digprop_woodlike(0.75),
881 minetest.register_node("mese", {
882 tile_images = {"mese.png"},
883 inventory_image = inventorycube("mese.png"),
884 is_ground_content = true,
885 furnace_burntime = 30,
886 material = digprop_stonelike(0.5),
889 minetest.register_node("cloud", {
890 tile_images = {"cloud.png"},
891 inventory_image = inventorycube("cloud.png"),
892 is_ground_content = true,
895 minetest.register_node("water_flowing", {
896 drawtype = "flowingliquid",
897 tile_images = {"water.png"},
899 inventory_image = inventorycube("water.png"),
901 light_propagates = true,
906 liquidtype = "flowing",
907 liquid_alternative_flowing = "water_flowing",
908 liquid_alternative_source = "water_source",
909 liquid_viscosity = WATER_VISC,
910 post_effect_color = {a=64, r=100, g=100, b=200},
911 special_materials = {
912 {image="water.png", backface_culling=false},
913 {image="water.png", backface_culling=true},
917 minetest.register_node("water_source", {
919 tile_images = {"water.png"},
921 inventory_image = inventorycube("water.png"),
923 light_propagates = true,
928 liquidtype = "source",
929 liquid_alternative_flowing = "water_flowing",
930 liquid_alternative_source = "water_source",
931 liquid_viscosity = WATER_VISC,
932 post_effect_color = {a=64, r=100, g=100, b=200},
933 special_materials = {
934 -- New-style water source material (mostly unused)
935 {image="water.png", backface_culling=false},
939 minetest.register_node("lava_flowing", {
940 drawtype = "flowingliquid",
941 tile_images = {"lava.png"},
942 inventory_image = inventorycube("lava.png"),
944 light_propagates = false,
945 light_source = LIGHT_MAX - 1,
950 liquidtype = "flowing",
951 liquid_alternative_flowing = "lava_flowing",
952 liquid_alternative_source = "lava_source",
953 liquid_viscosity = LAVA_VISC,
954 damage_per_second = 4*2,
955 post_effect_color = {a=192, r=255, g=64, b=0},
956 special_materials = {
957 {image="lava.png", backface_culling=false},
958 {image="lava.png", backface_culling=true},
962 minetest.register_node("lava_source", {
964 tile_images = {"lava.png"},
965 inventory_image = inventorycube("lava.png"),
967 light_propagates = false,
968 light_source = LIGHT_MAX - 1,
973 liquidtype = "source",
974 liquid_alternative_flowing = "lava_flowing",
975 liquid_alternative_source = "lava_source",
976 liquid_viscosity = LAVA_VISC,
977 damage_per_second = 4*2,
978 post_effect_color = {a=192, r=255, g=64, b=0},
979 special_materials = {
980 -- New-style lava source material (mostly unused)
981 {image="lava.png", backface_culling=false},
983 furnace_burntime = 60,
986 minetest.register_node("torch", {
987 drawtype = "torchlike",
988 tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
989 inventory_image = "torch_on_floor.png",
991 light_propagates = true,
992 sunlight_propagates = true,
995 light_source = LIGHT_MAX-1,
997 type = "wallmounted",
998 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
999 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1000 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1002 material = digprop_constanttime(0.0),
1003 furnace_burntime = 4,
1006 minetest.register_node("sign_wall", {
1007 drawtype = "signlike",
1008 tile_images = {"sign_wall.png"},
1009 inventory_image = "sign_wall.png",
1010 paramtype = "light",
1011 light_propagates = true,
1012 sunlight_propagates = true,
1014 wall_mounted = true,
1015 metadata_name = "sign",
1017 type = "wallmounted",
1018 --wall_top = <default>
1019 --wall_bottom = <default>
1020 --wall_side = <default>
1022 material = digprop_constanttime(0.5),
1023 furnace_burntime = 10,
1026 minetest.register_node("chest", {
1027 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1028 "chest_side.png", "chest_side.png", "chest_front.png"},
1029 inventory_image = "chest_top.png",
1030 --inventory_image = inventorycube("chest_top.png", "chest_side.png", "chest_front.png"),
1031 paramtype = "facedir_simple",
1032 metadata_name = "chest",
1033 material = digprop_woodlike(1.0),
1034 furnace_burntime = 30,
1037 minetest.register_node("locked_chest", {
1038 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1039 "chest_side.png", "chest_side.png", "chest_lock.png"},
1040 inventory_image = "chest_lock.png",
1041 paramtype = "facedir_simple",
1042 metadata_name = "locked_chest",
1043 material = digprop_woodlike(1.0),
1044 furnace_burntime = 30,
1047 minetest.register_node("furnace", {
1048 tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
1049 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1050 inventory_image = "furnace_front.png",
1051 paramtype = "facedir_simple",
1052 metadata_name = "furnace",
1053 material = digprop_stonelike(3.0),
1056 minetest.register_node("cobble", {
1057 tile_images = {"cobble.png"},
1058 inventory_image = inventorycube("cobble.png"),
1059 is_ground_content = true,
1060 cookresult_item = 'NodeItem "stone" 1',
1061 material = digprop_stonelike(0.9),
1064 minetest.register_node("mossycobble", {
1065 tile_images = {"mossycobble.png"},
1066 inventory_image = inventorycube("mossycobble.png"),
1067 is_ground_content = true,
1068 material = digprop_stonelike(0.8),
1071 minetest.register_node("steelblock", {
1072 tile_images = {"steel_block.png"},
1073 inventory_image = inventorycube("steel_block.png"),
1074 is_ground_content = true,
1075 material = digprop_stonelike(5.0),
1078 minetest.register_node("nyancat", {
1079 tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
1080 "nc_side.png", "nc_back.png", "nc_front.png"},
1081 inventory_image = "nc_front.png",
1082 paramtype = "facedir_simple",
1083 material = digprop_stonelike(3.0),
1084 furnace_burntime = 1,
1087 minetest.register_node("nyancat_rainbow", {
1088 tile_images = {"nc_rb.png"},
1089 inventory_image = "nc_rb.png",
1090 material = digprop_stonelike(3.0),
1091 furnace_burntime = 1,
1094 minetest.register_node("sapling", {
1095 drawtype = "plantlike",
1097 tile_images = {"sapling.png"},
1098 inventory_image = "sapling.png",
1099 paramtype = "light",
1100 light_propagates = true,
1102 material = digprop_constanttime(0.0),
1103 furnace_burntime = 10,
1106 minetest.register_node("apple", {
1107 drawtype = "plantlike",
1109 tile_images = {"apple.png"},
1110 inventory_image = "apple.png",
1111 paramtype = "light",
1112 light_propagates = true,
1113 sunlight_propagates = true,
1115 dug_item = 'CraftItem "apple" 1',
1116 material = digprop_constanttime(0.0),
1117 furnace_burntime = 3,
1122 minetest.register_node("somenode", {
1123 tile_images = {"lava.png", "mese.png", "stone.png", "grass.png", "cobble.png", "tree_top.png"},
1124 inventory_image = "treeprop.png",
1126 diggability = "normal",
1133 metadata_name = "chest",
1136 minetest.register_node("TNT", {
1137 tile_images = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png", "tnt_side.png", "tnt_side.png", "tnt_side.png"},
1138 inventory_image = "tnt_side.png",
1139 dug_item = '', -- Get nothing
1141 diggability = "not",
1146 -- Some common functions
1149 function nodeupdate_single(p)
1150 n = minetest.env:get_node(p)
1151 if n.name == "sand" or n.name == "gravel" then
1152 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1153 n_bottom = minetest.env:get_node(p_bottom)
1154 if n_bottom.name == "air" then
1155 minetest.env:remove_node(p)
1156 minetest.env:add_luaentity(p, "falling_"..n.name)
1162 function nodeupdate(p)
1166 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1167 nodeupdate_single(p2)
1174 -- TNT (not functional)
1178 -- Static definition
1179 physical = true, -- Collides with things
1181 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1183 textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"},
1184 -- Initial value for our timer
1186 -- Number of punches required to defuse
1192 -- Called when a TNT object is created
1193 function TNT:on_activate(staticdata)
1194 print("TNT:on_activate()")
1195 self.object:setvelocity({x=0, y=4, z=0})
1196 self.object:setacceleration({x=0, y=-10, z=0})
1197 self.object:settexturemod("^[brighten")
1200 -- Called periodically
1201 function TNT:on_step(dtime)
1202 --print("TNT:on_step()")
1203 self.timer = self.timer + dtime
1204 self.blinktimer = self.blinktimer + dtime
1205 if self.blinktimer > 0.5 then
1206 self.blinktimer = self.blinktimer - 0.5
1207 if self.blinkstatus then
1208 self.object:settexturemod("")
1210 self.object:settexturemod("^[brighten")
1212 self.blinkstatus = not self.blinkstatus
1216 -- Called when object is punched
1217 function TNT:on_punch(hitter)
1218 print("TNT:on_punch()")
1219 self.health = self.health - 1
1220 if self.health <= 0 then
1221 self.object:remove()
1222 hitter:add_to_inventory("NodeItem TNT 1")
1226 -- Called when object is right-clicked
1227 function TNT:on_rightclick(clicker)
1228 --pos = self.object:getpos()
1229 --pos = {x=pos.x, y=pos.y+0.1, z=pos.z}
1230 --self.object:moveto(pos, false)
1233 print("TNT dump: "..dump(TNT))
1235 print("Registering TNT");
1236 minetest.register_entity("TNT", TNT)
1239 minetest.register_entity("testentity", {
1240 -- Static definition
1241 physical = true, -- Collides with things
1243 collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7},
1244 --collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1246 visual_size = {x=2, y=3},
1247 textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
1248 spritediv = {x=6, y=5},
1249 initial_sprite_basepos = {x=0, y=0},
1251 on_activate = function(self, staticdata)
1252 print("testentity.on_activate")
1253 self.object:setsprite({x=0,y=0}, 1, 0, true)
1254 --self.object:setsprite({x=0,y=0}, 4, 0.3, true)
1257 self.object:setacceleration({x=0, y=-10, z=0})
1258 -- Jump a bit upwards
1259 self.object:setvelocity({x=0, y=10, z=0})
1262 on_punch = function(self, hitter)
1263 self.object:remove()
1264 hitter:add_to_inventory('CraftItem testobject1 1')
1272 function register_falling_node(nodename, texture)
1273 minetest.register_entity("falling_"..nodename, {
1274 -- Static definition
1276 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1278 textures = {texture,texture,texture,texture,texture,texture},
1281 on_step = function(self, dtime)
1283 self.object:setacceleration({x=0, y=-10, z=0})
1284 -- Turn to actual sand when collides to ground or just move
1285 local pos = self.object:getpos()
1286 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1287 local bcn = minetest.env:get_node(bcp)
1288 if bcn.name ~= "air" then
1289 -- Turn to a sand node
1290 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1291 minetest.env:add_node(np, {name=nodename})
1292 self.object:remove()
1300 register_falling_node("sand", "sand.png")
1301 register_falling_node("gravel", "gravel.png")
1307 -- Global environment step function
1308 function on_step(dtime)
1311 minetest.register_globalstep(on_step)
1313 function on_placenode(p, node)
1314 print("on_placenode")
1317 minetest.register_on_placenode(on_placenode)
1319 function on_dignode(p, node)
1323 minetest.register_on_dignode(on_dignode)
1325 function on_punchnode(p, node)
1326 print("on_punchnode")
1327 if node.name == "TNT" then
1328 minetest.env:remove_node(p)
1329 minetest.env:add_luaentity(p, "TNT")
1333 minetest.register_on_punchnode(on_punchnode)
1335 minetest.register_on_respawnplayer(function(player)
1336 print("on_respawnplayer")
1337 -- player:setpos({x=0, y=30, z=0})
1341 minetest.register_on_generated(function(minp, maxp)
1342 --print("on_generated: minp="..dump(minp).." maxp="..dump(maxp))
1343 --cp = {x=(minp.x+maxp.x)/2, y=(minp.y+maxp.y)/2, z=(minp.z+maxp.z)/2}
1344 --minetest.env:add_node(cp, {name="sand"})
1347 -- Example setting get
1348 print("setting max_users = " .. dump(minetest.setting_get("max_users")))
1349 print("setting asdf = " .. dump(minetest.setting_get("asdf")))
1351 minetest.register_on_chat_message(function(name, message)
1352 print("on_chat_message: name="..dump(name).." message="..dump(message))
1353 local cmd = "/testcommand"
1354 if message:sub(0, #cmd) == cmd then
1355 print(cmd.." invoked")
1359 if message:sub(0, #cmd) == cmd then
1360 print("script-overridden help command")
1361 minetest.chat_send_all("script-overridden help command")
1366 -- Grow papyrus on TNT every 10 seconds
1367 --[[minetest.register_abm({
1368 nodenames = {"TNT"},
1371 action = function(pos, node, active_object_count, active_object_count_wider)
1372 print("TNT ABM action")
1374 minetest.env:add_node(pos, {name="papyrus"})
1378 -- Replace texts of alls signs with "foo" every 10 seconds
1379 --[[minetest.register_abm({
1380 nodenames = {"sign_wall"},
1383 action = function(pos, node, active_object_count, active_object_count_wider)
1384 print("ABM: Sign text changed")
1385 local meta = minetest.env:get_meta(pos)
1390 -- LuaNodeMetadata should support something like this
1391 --meta.setvar("somevariable", {x=0, y=0, z=0})
1392 --meta.getvar("somevariable") -> {x=0, y=0, z=0}
1395 -- Done, print some random stuff
1398 print("minetest.registered_entities:")
1399 dump2(minetest.registered_entities)