1 -- Helper functions defined by builtin.lua:
2 -- dump2(obj, name="_", dumped={})
3 -- dump(obj, dumped={})
6 -- Mods should prefix their textures with modname_, eg. given the mod
7 -- name "foomod", a texture could be called "foomod_superfurnace.png"
8 -- Due to historical reasons, the default mod does not follow this rule.
11 -- minetest.register_entity(name, prototype_table)
12 -- minetest.register_tool(name, {lots of stuff})
13 -- minetest.register_node(name, {lots of stuff})
14 -- minetest.register_craftitem(name, {lots of stuff})
15 -- minetest.register_craft({output=item, recipe={...})
16 -- minetest.register_globalstep(func)
17 -- minetest.register_on_placenode(func(pos, newnode, placer))
18 -- minetest.register_on_dignode(func(pos, oldnode, digger))
19 -- minetest.register_on_punchnode(func(pos, node, puncher))
20 -- minetest.register_on_generated(func(minp, maxp))
21 -- minetest.register_on_newplayer(func(ObjectRef))
22 -- minetest.register_on_respawnplayer(func(ObjectRef))
23 -- ^ return true in func to disable regular player placement
24 -- minetest.register_on_chat_message(func(name, message))
25 -- minetest.setting_get(name)
26 -- minetest.setting_getbool(name)
27 -- minetest.chat_send_all(text)
28 -- minetest.chat_send_player(name, text)
31 -- minetest.env - environment reference
34 -- minetest.registered_nodes
35 -- ^ List of registered node definitions, indexed by name
36 -- minetest.registered_craftitems
37 -- ^ List of registered craft item definitions, indexed by name
38 -- minetest.registered_entities
39 -- ^ List of registered entity prototypes, indexed by name
40 -- minetest.object_refs
41 -- ^ List of object references, indexed by active object id
42 -- minetest.luaentities
43 -- ^ List of lua entities, indexed by active object id
45 -- EnvRef is basically ServerEnvironment and ServerMap combined.
47 -- - add_node(pos, node)
50 -- - add_luaentity(pos, name)
51 -- - add_item(pos, itemstring)
54 -- - get_meta(pos) -- Get a NodeMetaRef at that position
58 -- - allows_text_input()
59 -- - set_text(text) -- eg. set the text of a sign
62 -- - set_infotext(infotext)
63 -- - inventory_set_list(name, {item1, item2, ...})
64 -- - inventory_get_list(name)
65 -- - set_inventory_draw_spec(string)
66 -- - set_allow_text_input(bool)
67 -- - set_allow_removal(bool)
68 -- - set_enforce_owner(bool)
69 -- - is_inventory_modified()
70 -- - reset_inventory_modified()
71 -- - is_text_modified()
72 -- - reset_text_modified()
73 -- - set_string(name, value)
76 -- ObjectRef is basically ServerActiveObject.
78 -- - remove(): remove object (after returning from Lua)
79 -- - getpos(): returns {x=num, y=num, z=num}
80 -- - setpos(pos); pos={x=num, y=num, z=num}
81 -- - moveto(pos, continuous=false): interpolated move
82 -- - add_to_inventory(itemstring): add an item to object inventory
83 -- - add_to_inventory_later(itemstring): like above, but after callback returns (only allowed for craftitem callbacks)
84 -- - get_hp(): returns number of hitpoints (2 * number of hearts)
85 -- - set_hp(hp): set number of hitpoints (2 * number of hearts)
86 -- - settexturemod(mod)
87 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
88 -- - select_horiz_by_yawpitch=false)
90 -- Registered entities:
91 -- - Functions receive a "luaentity" as self:
92 -- - It has the member .object, which is an ObjectRef pointing to the object
93 -- - The original prototype stuff is visible directly via a metatable
95 -- - on_activate(self, staticdata)
96 -- - on_step(self, dtime)
97 -- - on_punch(self, hitter)
98 -- - on_rightclick(self, clicker)
99 -- - get_staticdata(self): return string
101 -- MapNode representation:
102 -- {name="name", param1=num, param2=num}
104 -- Position representation:
105 -- {x=num, y=num, z=num}
108 -- print("minetest dump: "..dump(minetest))
119 minetest.register_tool("WPick", {
120 image = "tool_woodpick.png",
123 dt_crackiness = -0.5,
132 minetest.register_tool("STPick", {
133 image = "tool_stonepick.png",
136 dt_crackiness = -0.5,
139 basedurability = 100,
145 minetest.register_tool("SteelPick", {
146 image = "tool_steelpick.png",
149 dt_crackiness = -0.5,
152 basedurability = 333,
158 minetest.register_tool("MesePick", {
159 image = "tool_mesepick.png",
165 basedurability = 1337,
171 minetest.register_tool("WShovel", {
172 image = "tool_woodshovel.png",
176 dt_crumbliness = -1.5,
177 dt_cuttability = 0.3,
184 minetest.register_tool("STShovel", {
185 image = "tool_stoneshovel.png",
189 dt_crumbliness = -1.5,
190 dt_cuttability = 0.1,
191 basedurability = 100,
197 minetest.register_tool("SteelShovel", {
198 image = "tool_steelshovel.png",
202 dt_crumbliness = -1.5,
203 dt_cuttability = 0.0,
204 basedurability = 330,
210 minetest.register_tool("WAxe", {
211 image = "tool_woodaxe.png",
214 dt_crackiness = -0.2,
216 dt_cuttability = -0.5,
223 minetest.register_tool("STAxe", {
224 image = "tool_stoneaxe.png",
227 dt_crackiness = -0.2,
229 dt_cuttability = -0.5,
230 basedurability = 100,
236 minetest.register_tool("SteelAxe", {
237 image = "tool_steelaxe.png",
240 dt_crackiness = -0.2,
242 dt_cuttability = -0.5,
243 basedurability = 330,
249 minetest.register_tool("WSword", {
250 image = "tool_woodsword.png",
262 minetest.register_tool("STSword", {
263 image = "tool_stonesword.png",
269 basedurability = 100,
275 minetest.register_tool("SteelSword", {
276 image = "tool_steelsword.png",
282 basedurability = 330,
288 minetest.register_tool("", {
303 minetest.register_tool("horribletool", {
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"', ''},
590 minetest.register_craft({
591 output = 'NodeItem "TNT" 4',
593 {'NodeItem "wood" 1'},
594 {'CraftItem "lump_of_coal" 1'},
595 {'NodeItem "wood" 1'}
599 minetest.register_craft({
600 output = 'NodeItem "somenode" 4',
602 {'CraftItem "Stick" 1'},
610 function digprop_constanttime(time)
612 diggability = "constant",
613 constant_time = time,
617 function digprop_stonelike(toughness)
619 diggablity = "normal",
620 weight = toughness * 5,
627 function digprop_dirtlike(toughness)
629 diggablity = "normal",
630 weight = toughness * 1.2,
637 function digprop_gravellike(toughness)
639 diggablity = "normal",
640 weight = toughness * 2,
647 function digprop_woodlike(toughness)
649 diggablity = "normal",
650 weight = toughness * 1.0,
657 function digprop_leaveslike(toughness)
659 diggablity = "normal",
660 weight = toughness * (-0.5),
667 function digprop_glasslike(toughness)
669 diggablity = "normal",
670 weight = toughness * 0.1,
677 function inventorycube(img1, img2, img3)
680 return "[inventorycube"
681 .. "{" .. img1:gsub("%^", "&")
682 .. "{" .. img2:gsub("%^", "&")
683 .. "{" .. img3:gsub("%^", "&")
688 minetest.register_node("stone", {
689 tile_images = {"stone.png"},
690 inventory_image = inventorycube("stone.png"),
691 paramtype = "mineral",
692 is_ground_content = true,
693 often_contains_mineral = true, -- Texture atlas hint
694 material = digprop_stonelike(1.0),
695 dug_item = 'NodeItem "cobble" 1',
698 minetest.register_node("dirt_with_grass", {
699 tile_images = {"grass.png", "mud.png", "mud.png^grass_side.png"},
700 inventory_image = inventorycube("mud.png^grass_side.png"),
701 is_ground_content = true,
702 material = digprop_dirtlike(1.0),
703 dug_item = 'NodeItem "dirt" 1',
706 minetest.register_node("dirt_with_grass_footsteps", {
707 tile_images = {"grass_footsteps.png", "mud.png", "mud.png^grass_side.png"},
708 inventory_image = "grass_footsteps.png",
709 is_ground_content = true,
710 material = digprop_dirtlike(1.0),
711 dug_item = 'NodeItem "dirt" 1',
714 minetest.register_node("dirt", {
715 tile_images = {"mud.png"},
716 inventory_image = inventorycube("mud.png"),
717 is_ground_content = true,
718 material = digprop_dirtlike(1.0),
721 minetest.register_node("sand", {
722 tile_images = {"sand.png"},
723 inventory_image = inventorycube("sand.png"),
724 is_ground_content = true,
725 material = digprop_dirtlike(1.0),
728 minetest.register_node("gravel", {
729 tile_images = {"gravel.png"},
730 inventory_image = inventorycube("gravel.png"),
731 is_ground_content = true,
732 material = digprop_gravellike(1.0),
735 minetest.register_node("sandstone", {
736 tile_images = {"sandstone.png"},
737 inventory_image = inventorycube("sandstone.png"),
738 is_ground_content = true,
739 material = digprop_dirtlike(1.0), -- FIXME should this be stonelike?
740 dug_item = 'NodeItem "sand" 1', -- FIXME is this intentional?
743 minetest.register_node("clay", {
744 tile_images = {"clay.png"},
745 inventory_image = inventorycube("clay.png"),
746 is_ground_content = true,
747 material = digprop_dirtlike(1.0),
748 dug_item = 'CraftItem "lump_of_clay" 4',
751 minetest.register_node("brick", {
752 tile_images = {"brick.png"},
753 inventory_image = inventorycube("brick.png"),
754 is_ground_content = true,
755 material = digprop_stonelike(1.0),
756 dug_item = 'CraftItem "clay_brick" 4',
759 minetest.register_node("tree", {
760 tile_images = {"tree_top.png", "tree_top.png", "tree.png"},
761 inventory_image = inventorycube("tree_top.png", "tree.png", "tree.png"),
762 is_ground_content = true,
763 material = digprop_woodlike(1.0),
764 cookresult_item = 'CraftItem "lump_of_coal" 1',
765 furnace_burntime = 30,
768 minetest.register_node("jungletree", {
769 tile_images = {"jungletree_top.png", "jungletree_top.png", "jungletree.png"},
770 inventory_image = inventorycube("jungletree_top.png", "jungletree.png", "jungletree.png"),
771 is_ground_content = true,
772 material = digprop_woodlike(1.0),
773 cookresult_item = 'CraftItem "lump_of_coal" 1',
774 furnace_burntime = 30,
777 minetest.register_node("junglegrass", {
778 drawtype = "plantlike",
780 tile_images = {"junglegrass.png"},
781 inventory_image = "junglegrass.png",
782 light_propagates = true,
785 material = digprop_leaveslike(1.0),
786 furnace_burntime = 2,
789 minetest.register_node("leaves", {
790 drawtype = "allfaces_optional",
792 tile_images = {"leaves.png"},
793 inventory_image = "leaves.png",
794 light_propagates = true,
796 material = digprop_leaveslike(1.0),
797 extra_dug_item = 'NodeItem "sapling" 1',
798 extra_dug_item_rarity = 20,
799 furnace_burntime = 1,
802 minetest.register_node("cactus", {
803 tile_images = {"cactus_top.png", "cactus_top.png", "cactus_side.png"},
804 inventory_image = inventorycube("cactus_top.png", "cactus_side.png", "cactus_side.png"),
805 is_ground_content = true,
806 material = digprop_woodlike(0.75),
807 furnace_burntime = 15,
810 minetest.register_node("papyrus", {
811 drawtype = "plantlike",
812 tile_images = {"papyrus.png"},
813 inventory_image = "papyrus.png",
814 light_propagates = true,
816 is_ground_content = true,
818 material = digprop_leaveslike(0.5),
819 furnace_burntime = 1,
822 minetest.register_node("bookshelf", {
823 tile_images = {"wood.png", "wood.png", "bookshelf.png"},
824 -- FIXME: inventorycube only cares for the first texture
825 --inventory_image = inventorycube("wood.png", "bookshelf.png", "bookshelf.png")
826 inventory_image = inventorycube("bookshelf.png"),
827 is_ground_content = true,
828 material = digprop_woodlike(0.75),
829 furnace_burntime = 30,
832 minetest.register_node("glass", {
833 drawtype = "glasslike",
834 tile_images = {"glass.png"},
835 inventory_image = inventorycube("glass.png"),
836 light_propagates = true,
838 sunlight_propagates = true,
839 is_ground_content = true,
840 material = digprop_glasslike(1.0),
843 minetest.register_node("wooden_fence", {
844 drawtype = "fencelike",
845 tile_images = {"wood.png"},
846 inventory_image = "fence.png",
847 light_propagates = true,
849 is_ground_content = true,
852 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
854 furnace_burntime = 15,
855 material = digprop_woodlike(0.75),
858 minetest.register_node("rail", {
859 drawtype = "raillike",
860 tile_images = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
861 inventory_image = "rail.png",
862 light_propagates = true,
864 is_ground_content = true,
870 material = digprop_dirtlike(0.75),
873 minetest.register_node("ladder", {
874 drawtype = "signlike",
875 tile_images = {"ladder.png"},
876 inventory_image = "ladder.png",
877 light_propagates = true,
879 is_ground_content = true,
884 type = "wallmounted",
885 --wall_top = = <default>
886 --wall_bottom = = <default>
887 --wall_side = = <default>
889 furnace_burntime = 5,
890 material = digprop_woodlike(0.5),
893 minetest.register_node("coalstone", {
894 tile_images = {"stone.png^mineral_coal.png"},
895 inventory_image = "stone.png^mineral_coal.png",
896 is_ground_content = true,
897 material = digprop_stonelike(1.5),
900 minetest.register_node("wood", {
901 tile_images = {"wood.png"},
902 inventory_image = inventorycube("wood.png"),
903 is_ground_content = true,
904 furnace_burntime = 7,
905 material = digprop_woodlike(0.75),
908 minetest.register_node("mese", {
909 tile_images = {"mese.png"},
910 inventory_image = inventorycube("mese.png"),
911 is_ground_content = true,
912 furnace_burntime = 30,
913 material = digprop_stonelike(0.5),
916 minetest.register_node("cloud", {
917 tile_images = {"cloud.png"},
918 inventory_image = inventorycube("cloud.png"),
919 is_ground_content = true,
922 minetest.register_node("water_flowing", {
923 drawtype = "flowingliquid",
924 tile_images = {"water.png"},
926 inventory_image = inventorycube("water.png"),
928 light_propagates = true,
933 liquidtype = "flowing",
934 liquid_alternative_flowing = "water_flowing",
935 liquid_alternative_source = "water_source",
936 liquid_viscosity = WATER_VISC,
937 post_effect_color = {a=64, r=100, g=100, b=200},
938 special_materials = {
939 {image="water.png", backface_culling=false},
940 {image="water.png", backface_culling=true},
944 minetest.register_node("water_source", {
946 tile_images = {"water.png"},
948 inventory_image = inventorycube("water.png"),
950 light_propagates = true,
955 liquidtype = "source",
956 liquid_alternative_flowing = "water_flowing",
957 liquid_alternative_source = "water_source",
958 liquid_viscosity = WATER_VISC,
959 post_effect_color = {a=64, r=100, g=100, b=200},
960 special_materials = {
961 -- New-style water source material (mostly unused)
962 {image="water.png", backface_culling=false},
966 minetest.register_node("lava_flowing", {
967 drawtype = "flowingliquid",
968 tile_images = {"lava.png"},
969 inventory_image = inventorycube("lava.png"),
971 light_propagates = false,
972 light_source = LIGHT_MAX - 1,
977 liquidtype = "flowing",
978 liquid_alternative_flowing = "lava_flowing",
979 liquid_alternative_source = "lava_source",
980 liquid_viscosity = LAVA_VISC,
981 damage_per_second = 4*2,
982 post_effect_color = {a=192, r=255, g=64, b=0},
983 special_materials = {
984 {image="lava.png", backface_culling=false},
985 {image="lava.png", backface_culling=true},
989 minetest.register_node("lava_source", {
991 tile_images = {"lava.png"},
992 inventory_image = inventorycube("lava.png"),
994 light_propagates = false,
995 light_source = LIGHT_MAX - 1,
1000 liquidtype = "source",
1001 liquid_alternative_flowing = "lava_flowing",
1002 liquid_alternative_source = "lava_source",
1003 liquid_viscosity = LAVA_VISC,
1004 damage_per_second = 4*2,
1005 post_effect_color = {a=192, r=255, g=64, b=0},
1006 special_materials = {
1007 -- New-style lava source material (mostly unused)
1008 {image="lava.png", backface_culling=false},
1010 furnace_burntime = 60,
1013 minetest.register_node("torch", {
1014 drawtype = "torchlike",
1015 tile_images = {"torch_on_floor.png", "torch_on_ceiling.png", "torch.png"},
1016 inventory_image = "torch_on_floor.png",
1017 paramtype = "light",
1018 light_propagates = true,
1019 sunlight_propagates = true,
1021 wall_mounted = true,
1022 light_source = LIGHT_MAX-1,
1024 type = "wallmounted",
1025 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1026 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1027 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1029 material = digprop_constanttime(0.0),
1030 furnace_burntime = 4,
1033 minetest.register_node("sign_wall", {
1034 drawtype = "signlike",
1035 tile_images = {"sign_wall.png"},
1036 inventory_image = "sign_wall.png",
1037 paramtype = "light",
1038 light_propagates = true,
1039 sunlight_propagates = true,
1041 wall_mounted = true,
1042 metadata_name = "sign",
1044 type = "wallmounted",
1045 --wall_top = <default>
1046 --wall_bottom = <default>
1047 --wall_side = <default>
1049 material = digprop_constanttime(0.5),
1050 furnace_burntime = 10,
1053 minetest.register_node("chest", {
1054 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1055 "chest_side.png", "chest_side.png", "chest_front.png"},
1056 inventory_image = "chest_top.png",
1057 --inventory_image = inventorycube("chest_top.png", "chest_side.png", "chest_front.png"),
1058 paramtype = "facedir_simple",
1059 metadata_name = "chest",
1060 material = digprop_woodlike(1.0),
1061 furnace_burntime = 30,
1064 minetest.register_node("locked_chest", {
1065 tile_images = {"chest_top.png", "chest_top.png", "chest_side.png",
1066 "chest_side.png", "chest_side.png", "chest_lock.png"},
1067 inventory_image = "chest_lock.png",
1068 paramtype = "facedir_simple",
1069 metadata_name = "locked_chest",
1070 material = digprop_woodlike(1.0),
1071 furnace_burntime = 30,
1074 minetest.register_node("furnace", {
1075 tile_images = {"furnace_side.png", "furnace_side.png", "furnace_side.png",
1076 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1077 inventory_image = "furnace_front.png",
1078 paramtype = "facedir_simple",
1079 metadata_name = "furnace",
1080 material = digprop_stonelike(3.0),
1083 minetest.register_node("cobble", {
1084 tile_images = {"cobble.png"},
1085 inventory_image = inventorycube("cobble.png"),
1086 is_ground_content = true,
1087 cookresult_item = 'NodeItem "stone" 1',
1088 material = digprop_stonelike(0.9),
1091 minetest.register_node("mossycobble", {
1092 tile_images = {"mossycobble.png"},
1093 inventory_image = inventorycube("mossycobble.png"),
1094 is_ground_content = true,
1095 material = digprop_stonelike(0.8),
1098 minetest.register_node("steelblock", {
1099 tile_images = {"steel_block.png"},
1100 inventory_image = inventorycube("steel_block.png"),
1101 is_ground_content = true,
1102 material = digprop_stonelike(5.0),
1105 minetest.register_node("nyancat", {
1106 tile_images = {"nc_side.png", "nc_side.png", "nc_side.png",
1107 "nc_side.png", "nc_back.png", "nc_front.png"},
1108 inventory_image = "nc_front.png",
1109 paramtype = "facedir_simple",
1110 material = digprop_stonelike(3.0),
1111 furnace_burntime = 1,
1114 minetest.register_node("nyancat_rainbow", {
1115 tile_images = {"nc_rb.png"},
1116 inventory_image = "nc_rb.png",
1117 material = digprop_stonelike(3.0),
1118 furnace_burntime = 1,
1121 minetest.register_node("sapling", {
1122 drawtype = "plantlike",
1124 tile_images = {"sapling.png"},
1125 inventory_image = "sapling.png",
1126 paramtype = "light",
1127 light_propagates = true,
1129 material = digprop_constanttime(0.0),
1130 furnace_burntime = 10,
1133 minetest.register_node("apple", {
1134 drawtype = "plantlike",
1136 tile_images = {"apple.png"},
1137 inventory_image = "apple.png",
1138 paramtype = "light",
1139 light_propagates = true,
1140 sunlight_propagates = true,
1142 dug_item = 'CraftItem "apple" 1',
1143 material = digprop_constanttime(0.0),
1144 furnace_burntime = 3,
1149 minetest.register_node("somenode", {
1150 tile_images = {"lava.png", "mese.png", "stone.png", "grass.png", "cobble.png", "tree_top.png"},
1151 inventory_image = "treeprop.png",
1153 diggability = "normal",
1160 metadata_name = "chest",
1163 minetest.register_node("TNT", {
1164 tile_images = {"tnt_top.png", "tnt_bottom.png", "tnt_side.png", "tnt_side.png", "tnt_side.png", "tnt_side.png"},
1165 inventory_image = "tnt_side.png",
1166 dug_item = '', -- Get nothing
1168 diggability = "not",
1176 local craftitem_place_item = function(item, placer, pos)
1177 --print("craftitem_place_item")
1178 print("item: " .. dump(item))
1179 print("placer: " .. dump(placer))
1180 print("pos: " .. dump(pos))
1181 minetest.env:add_item(pos, 'CraftItem "' .. item .. '" 1')
1185 local craftitem_eat = function(hp_change)
1186 return function(item, user, pointed_thing) -- closure
1187 --print("craftitem_eat(" .. hp_change .. ")")
1188 --print("item: " .. dump(item))
1189 --print("user: " .. dump(user))
1190 --print("pointed_thing: " .. dump(pointed_thing))
1191 user:set_hp(user:get_hp() + hp_change)
1196 minetest.register_craftitem("Stick", {
1197 image = "stick.png",
1198 --furnace_burntime = ...,
1199 on_place_on_ground = craftitem_place_item,
1202 minetest.register_craftitem("paper", {
1203 image = "paper.png",
1204 on_place_on_ground = craftitem_place_item,
1207 minetest.register_craftitem("book", {
1209 on_place_on_ground = craftitem_place_item,
1212 minetest.register_craftitem("lump_of_coal", {
1213 image = "lump_of_coal.png",
1214 furnace_burntime = 40;
1215 on_place_on_ground = craftitem_place_item,
1218 minetest.register_craftitem("lump_of_iron", {
1219 image = "lump_of_iron.png",
1220 cookresult_item = 'CraftItem "steel_ingot" 1',
1221 on_place_on_ground = craftitem_place_item,
1224 minetest.register_craftitem("lump_of_clay", {
1225 image = "lump_of_clay.png",
1226 cookresult_item = 'CraftItem "clay_brick" 1',
1227 on_place_on_ground = craftitem_place_item,
1230 minetest.register_craftitem("steel_ingot", {
1231 image = "steel_ingot.png",
1232 on_place_on_ground = craftitem_place_item,
1235 minetest.register_craftitem("clay_brick", {
1236 image = "clay_brick.png",
1237 on_place_on_ground = craftitem_place_item,
1240 minetest.register_craftitem("rat", {
1242 cookresult_item = 'CraftItem "cooked_rat" 1',
1243 on_drop = function(item, dropper, pos)
1244 minetest.env:add_rat(pos)
1249 minetest.register_craftitem("cooked_rat", {
1250 image = "cooked_rat.png",
1251 cookresult_item = 'CraftItem "scorched_stuff" 1',
1252 on_place_on_ground = craftitem_place_item,
1253 on_use = craftitem_eat(6),
1256 minetest.register_craftitem("scorched_stuff", {
1257 image = "scorched_stuff.png",
1258 on_place_on_ground = craftitem_place_item,
1261 minetest.register_craftitem("firefly", {
1262 image = "firefly.png",
1263 on_drop = function(item, dropper, pos)
1264 minetest.env:add_firefly(pos)
1269 minetest.register_craftitem("apple", {
1270 image = "apple.png",
1271 on_place_on_ground = craftitem_place_item,
1272 on_use = craftitem_eat(4),
1275 minetest.register_craftitem("apple_iron", {
1276 image = "apple_iron.png",
1277 on_place_on_ground = craftitem_place_item,
1278 on_use = craftitem_eat(8),
1281 print(dump(minetest.registered_craftitems))
1285 -- Some common functions
1288 function nodeupdate_single(p)
1289 n = minetest.env:get_node(p)
1290 if n.name == "sand" or n.name == "gravel" then
1291 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1292 n_bottom = minetest.env:get_node(p_bottom)
1293 if n_bottom.name == "air" then
1294 minetest.env:remove_node(p)
1295 minetest.env:add_luaentity(p, "falling_"..n.name)
1301 function nodeupdate(p)
1305 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1306 nodeupdate_single(p2)
1313 -- TNT (not functional)
1317 -- Static definition
1318 physical = true, -- Collides with things
1320 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1322 textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"},
1323 -- Initial value for our timer
1325 -- Number of punches required to defuse
1331 -- Called when a TNT object is created
1332 function TNT:on_activate(staticdata)
1333 print("TNT:on_activate()")
1334 self.object:setvelocity({x=0, y=4, z=0})
1335 self.object:setacceleration({x=0, y=-10, z=0})
1336 self.object:settexturemod("^[brighten")
1339 -- Called periodically
1340 function TNT:on_step(dtime)
1341 --print("TNT:on_step()")
1342 self.timer = self.timer + dtime
1343 self.blinktimer = self.blinktimer + dtime
1344 if self.blinktimer > 0.5 then
1345 self.blinktimer = self.blinktimer - 0.5
1346 if self.blinkstatus then
1347 self.object:settexturemod("")
1349 self.object:settexturemod("^[brighten")
1351 self.blinkstatus = not self.blinkstatus
1355 -- Called when object is punched
1356 function TNT:on_punch(hitter)
1357 print("TNT:on_punch()")
1358 self.health = self.health - 1
1359 if self.health <= 0 then
1360 self.object:remove()
1361 hitter:add_to_inventory("NodeItem TNT 1")
1362 hitter:set_hp(hitter:get_hp() - 1)
1366 -- Called when object is right-clicked
1367 function TNT:on_rightclick(clicker)
1368 --pos = self.object:getpos()
1369 --pos = {x=pos.x, y=pos.y+0.1, z=pos.z}
1370 --self.object:moveto(pos, false)
1373 print("TNT dump: "..dump(TNT))
1375 print("Registering TNT");
1376 minetest.register_entity("TNT", TNT)
1379 minetest.register_entity("testentity", {
1380 -- Static definition
1381 physical = true, -- Collides with things
1383 collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7},
1384 --collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1386 visual_size = {x=2, y=3},
1387 textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"},
1388 spritediv = {x=6, y=5},
1389 initial_sprite_basepos = {x=0, y=0},
1391 on_activate = function(self, staticdata)
1392 print("testentity.on_activate")
1393 self.object:setsprite({x=0,y=0}, 1, 0, true)
1394 --self.object:setsprite({x=0,y=0}, 4, 0.3, true)
1397 self.object:setacceleration({x=0, y=-10, z=0})
1398 -- Jump a bit upwards
1399 self.object:setvelocity({x=0, y=10, z=0})
1402 on_punch = function(self, hitter)
1403 self.object:remove()
1404 hitter:add_to_inventory('CraftItem testobject1 1')
1412 function register_falling_node(nodename, texture)
1413 minetest.register_entity("falling_"..nodename, {
1414 -- Static definition
1416 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1418 textures = {texture,texture,texture,texture,texture,texture},
1421 on_step = function(self, dtime)
1423 self.object:setacceleration({x=0, y=-10, z=0})
1424 -- Turn to actual sand when collides to ground or just move
1425 local pos = self.object:getpos()
1426 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1427 local bcn = minetest.env:get_node(bcp)
1428 if bcn.name ~= "air" then
1429 -- Turn to a sand node
1430 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1431 minetest.env:add_node(np, {name=nodename})
1432 self.object:remove()
1440 register_falling_node("sand", "sand.png")
1441 register_falling_node("gravel", "gravel.png")
1447 -- Global environment step function
1448 function on_step(dtime)
1451 minetest.register_globalstep(on_step)
1453 function on_placenode(p, node)
1454 print("on_placenode")
1457 minetest.register_on_placenode(on_placenode)
1459 function on_dignode(p, node)
1463 minetest.register_on_dignode(on_dignode)
1465 function on_punchnode(p, node)
1466 print("on_punchnode")
1467 if node.name == "TNT" then
1468 minetest.env:remove_node(p)
1469 minetest.env:add_luaentity(p, "TNT")
1470 --minetest.env:add_luaentity(p, "testentity")
1471 --minetest.env:add_firefly(p)
1475 minetest.register_on_punchnode(on_punchnode)
1477 minetest.register_on_respawnplayer(function(player)
1478 print("on_respawnplayer")
1479 -- player:setpos({x=0, y=30, z=0})
1483 minetest.register_on_generated(function(minp, maxp)
1484 --print("on_generated: minp="..dump(minp).." maxp="..dump(maxp))
1485 --cp = {x=(minp.x+maxp.x)/2, y=(minp.y+maxp.y)/2, z=(minp.z+maxp.z)/2}
1486 --minetest.env:add_node(cp, {name="sand"})
1489 -- Example setting get
1490 print("setting max_users = " .. dump(minetest.setting_get("max_users")))
1491 print("setting asdf = " .. dump(minetest.setting_get("asdf")))
1493 minetest.register_on_chat_message(function(name, message)
1494 print("on_chat_message: name="..dump(name).." message="..dump(message))
1495 local cmd = "/testcommand"
1496 if message:sub(0, #cmd) == cmd then
1497 print(cmd.." invoked")
1501 if message:sub(0, #cmd) == cmd then
1502 print("script-overridden help command")
1503 minetest.chat_send_all("script-overridden help command")
1508 -- Grow papyrus on TNT every 10 seconds
1509 minetest.register_abm({
1510 nodenames = {"TNT"},
1513 action = function(pos, node, active_object_count, active_object_count_wider)
1514 print("TNT ABM action")
1516 minetest.env:add_node(pos, {name="papyrus"})
1520 -- Replace texts of alls signs with "foo" every 10 seconds
1521 --[[minetest.register_abm({
1522 nodenames = {"sign_wall"},
1525 action = function(pos, node, active_object_count, active_object_count_wider)
1526 print("ABM: Sign text changed")
1527 local meta = minetest.env:get_meta(pos)
1528 meta:set_text("foo")
1532 --[[local ncpos = nil
1535 {2, 1, 0, 3}, {3, 0, 1, 2}, {4, -1, 0, 1}, {5, -1, 0, 1}, {6, 0, -1, 0},
1536 {7, 0, -1, 0}, {8, 1, 0, 3}, {9, 1, 0, 3}, {10, 1, 0, 3}, {11, 0, 1, 2},
1537 {12, 0, 1, 2}, {13, 0, 1, 2}, {14, -1, 0, 1}, {15, -1, 0, 1}, {16, -1, 0, 1},
1538 {17, -1, 0, 1}, {18, 0, -1, 0}, {19, 0, -1, 0}, {20, 0, -1, 0}, {21, 0, -1, 0},
1539 {22, 1, 0, 3}, {23, 1, 0, 3}, {24, 1, 0, 3}, {25, 1, 0, 3}, {10, 0, 1, 2}
1544 minetest.register_abm({
1545 nodenames = {"dirt_with_grass"},
1546 interval = 100000.0,
1548 action = function(pos, node, active_object_count, active_object_count_wider)
1549 if ncpos ~= nil then
1553 if pos.x % 16 ~= 8 or pos.z % 16 ~= 8 then
1558 n = minetest.env:get_node(pos)
1560 if n.name ~= "air" then
1567 minetest.env:add_node(ncpos, {name="nyancat"})
1571 minetest.register_abm({
1572 nodenames = {"nyancat"},
1575 action = function(pos, node, active_object_count, active_object_count_wider)
1576 if ncpos == nil then
1579 if pos.x == ncpos.x and pos.y == ncpos.y and pos.z == ncpos.z then
1581 if clock - nctime < 0.1 then
1590 p1 = {x = p0.x + s0[2], y = p0.y, z = p0.z + s0[3]}
1591 p2 = {x = p1.x + s1[2], y = p1.y, z = p1.z + s1[3]}
1592 table.insert(ncold, 1, p0)
1593 while #ncold >= 10 do
1594 minetest.env:add_node(ncold[#ncold], {name="air"})
1595 table.remove(ncold, #ncold)
1597 minetest.env:add_node(p0, {name="nyancat_rainbow"})
1598 minetest.env:add_node(p1, {name="nyancat", param1=s0[4]})
1599 minetest.env:add_node(p2, {name="air"})
1605 -- LuaNodeMetadata should support something like this
1606 --meta.setvar("somevariable", {x=0, y=0, z=0})
1607 --meta.getvar("somevariable") -> {x=0, y=0, z=0}
1613 minetest.register_node("luafurnace", {
1614 tile_images = {"lava.png", "furnace_side.png", "furnace_side.png",
1615 "furnace_side.png", "furnace_side.png", "furnace_front.png"},
1616 --inventory_image = "furnace_front.png",
1617 inventory_image = inventorycube("furnace_front.png"),
1618 paramtype = "facedir_simple",
1619 metadata_name = "generic",
1620 material = digprop_stonelike(3.0),
1623 minetest.register_on_placenode(function(pos, newnode, placer)
1624 if newnode.name == "luafurnace" then
1626 local meta = minetest.env:get_meta(pos)
1627 print("inventory_set_list");
1628 meta:inventory_set_list("fuel", {""})
1629 print("inventory_set_list");
1630 meta:inventory_set_list("src", {""})
1631 print("inventory_set_list");
1632 meta:inventory_set_list("dst", {"","","",""})
1633 print("set_inventory_draw_spec");
1634 meta:set_inventory_draw_spec(
1636 .."list[current_name;fuel;2,3;1,1;]"
1637 .."list[current_name;src;2,1;1,1;]"
1638 .."list[current_name;dst;5,1;2,2;]"
1639 .."list[current_player;main;0,5;8,4;]"
1642 local total_cooked = 0;
1644 meta:set_string("total_cooked", total_cooked)
1645 print("set_infotext");
1646 meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
1650 function stackstring_take_item(stackstring)
1651 if stackstring == nil then
1654 local stacktype = nil
1655 stacktype = string.match(stackstring,
1656 '([%a%d]+Item[%a%d]*)')
1657 if stacktype == "NodeItem" or stacktype == "CraftItem" then
1658 local itemtype = nil
1659 local itemname = nil
1660 local itemcount = nil
1661 itemtype, itemname, itemcount = string.match(stackstring,
1662 '([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
1663 itemcount = tonumber(itemcount)
1664 if itemcount == 0 then
1666 elseif itemcount == 1 then
1667 return '', {type=itemtype, name=itemname}
1669 return itemtype.." \""..itemname.."\" "..(itemcount-1),
1670 {type=itemtype, name=itemname}
1672 elseif stacktype == "ToolItem" then
1673 local itemtype = nil
1674 local itemname = nil
1675 local itemwear = nil
1676 itemtype, itemname, itemwear = string.match(stackstring,
1677 '([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
1678 itemwear = tonumber(itemwear)
1679 return '', {type=itemtype, name=itemname, wear=itemwear}
1683 function stackstring_put_item(stackstring, item)
1685 return stackstring, false
1687 stackstring = stackstring or ''
1688 local stacktype = nil
1689 stacktype = string.match(stackstring,
1690 '([%a%d]+Item[%a%d]*)')
1691 stacktype = stacktype or ''
1692 if stacktype ~= '' and stacktype ~= item.type then
1693 return stackstring, false
1695 if item.type == "NodeItem" or item.type == "CraftItem" then
1696 local itemtype = nil
1697 local itemname = nil
1698 local itemcount = nil
1699 itemtype, itemname, itemcount = string.match(stackstring,
1700 '([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
1701 itemtype = itemtype or item.type
1702 itemname = itemname or item.name
1703 if itemcount == nil then
1706 itemcount = itemcount + 1
1707 return itemtype.." \""..itemname.."\" "..itemcount, true
1708 elseif item.type == "ToolItem" then
1709 if stacktype ~= nil then
1710 return stackstring, false
1712 local itemtype = nil
1713 local itemname = nil
1714 local itemwear = nil
1715 itemtype, itemname, itemwear = string.match(stackstring,
1716 '([%a%d]+Item[%a%d]*) "([^"]*)" (%d+)')
1717 itemwear = tonumber(itemwear)
1718 return itemtype.." \""..itemname.."\" "..itemwear, true
1720 return stackstring, false
1723 function stackstring_put_stackstring(stackstring, src)
1725 --print("src="..dump(src))
1726 src, item = stackstring_take_item(src)
1727 --print("src="..dump(src).." item="..dump(item))
1729 stackstring, success = stackstring_put_item(stackstring, item)
1731 return stackstring, false
1734 return stackstring, true
1737 function test_stack()
1742 stack, item = stackstring_take_item('NodeItem "TNT" 3')
1743 assert(stack == 'NodeItem "TNT" 2')
1744 assert(item.type == 'NodeItem')
1745 assert(item.name == 'TNT')
1747 stack, item = stackstring_take_item('CraftItem "with spaces" 2')
1748 assert(stack == 'CraftItem "with spaces" 1')
1749 assert(item.type == 'CraftItem')
1750 assert(item.name == 'with spaces')
1752 stack, item = stackstring_take_item('CraftItem "with spaces" 1')
1754 assert(item.type == 'CraftItem')
1755 assert(item.name == 'with spaces')
1757 stack, item = stackstring_take_item('CraftItem "s8df2kj3" 0')
1761 stack, item = stackstring_take_item('ToolItem "With Spaces" 32487')
1763 assert(item.type == 'ToolItem')
1764 assert(item.name == 'With Spaces')
1765 assert(item.wear == 32487)
1767 stack, success = stackstring_put_item('NodeItem "With Spaces" 40',
1768 {type='NodeItem', name='With Spaces'})
1769 assert(stack == 'NodeItem "With Spaces" 41')
1770 assert(success == true)
1772 stack, success = stackstring_put_item('CraftItem "With Spaces" 40',
1773 {type='CraftItem', name='With Spaces'})
1774 assert(stack == 'CraftItem "With Spaces" 41')
1775 assert(success == true)
1777 stack, success = stackstring_put_item('ToolItem "With Spaces" 32487',
1778 {type='ToolItem', name='With Spaces'})
1779 assert(stack == 'ToolItem "With Spaces" 32487')
1780 assert(success == false)
1782 stack, success = stackstring_put_item('NodeItem "With Spaces" 40',
1783 {type='ToolItem', name='With Spaces'})
1784 assert(stack == 'NodeItem "With Spaces" 40')
1785 assert(success == false)
1787 assert(stackstring_put_stackstring('NodeItem "With Spaces" 2',
1788 'NodeItem "With Spaces" 1') == 'NodeItem "With Spaces" 3')
1792 minetest.register_abm({
1793 nodenames = {"luafurnace"},
1796 action = function(pos, node, active_object_count, active_object_count_wider)
1797 local meta = minetest.env:get_meta(pos)
1798 local fuellist = meta:inventory_get_list("fuel")
1799 local srclist = meta:inventory_get_list("src")
1800 local dstlist = meta:inventory_get_list("dst")
1801 if fuellist == nil or srclist == nil or dstlist == nil then
1804 _, srcitem = stackstring_take_item(srclist[1])
1805 _, fuelitem = stackstring_take_item(fuellist[1])
1806 if not srcitem or not fuelitem then return end
1807 if fuelitem.type == "NodeItem" then
1808 local prop = minetest.registered_nodes[fuelitem.name]
1809 if prop == nil then return end
1810 if prop.furnace_burntime < 0 then return end
1814 local resultstack = nil
1815 if srcitem.type == "NodeItem" then
1816 local prop = minetest.registered_nodes[srcitem.name]
1817 if prop == nil then return end
1818 if prop.cookresult_item == "" then return end
1819 resultstack = prop.cookresult_item
1824 if resultstack == nil then
1828 dstlist[1], success = stackstring_put_stackstring(dstlist[1], resultstack)
1833 fuellist[1], _ = stackstring_take_item(fuellist[1])
1834 srclist[1], _ = stackstring_take_item(srclist[1])
1836 meta:inventory_set_list("fuel", fuellist)
1837 meta:inventory_set_list("src", srclist)
1838 meta:inventory_set_list("dst", dstlist)
1840 local total_cooked = meta:get_string("total_cooked")
1841 total_cooked = tonumber(total_cooked) + 1
1842 meta:set_string("total_cooked", total_cooked)
1843 meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
1847 minetest.register_craft({
1848 output = 'NodeItem "luafurnace" 1',
1850 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
1851 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
1852 {'NodeItem "cobble"', 'NodeItem "cobble"', 'NodeItem "cobble"'},
1857 -- Done, print some random stuff
1860 print("minetest.registered_entities:")
1861 dump2(minetest.registered_entities)