1 -- default (Minetest 0.4 mod)
4 -- Quick documentation about the API
5 -- =================================
7 -- Helper functions defined by builtin.lua:
8 -- dump2(obj, name="_", dumped={})
9 -- dump(obj, dumped={})
15 -- $path_userdata/usermods/
18 -- On a run-in-place version (eg. the distributed windows version):
19 -- minetest-0.4.x/data/mods/
20 -- minetest-0.4.x/usermods/
21 -- minetest-0.4.x/world/worldmods/
23 -- On an installed version on linux:
24 -- /usr/share/minetest/mods/
25 -- ~/.minetest/usermods
26 -- ~/.minetest/world/worldmods
28 -- Naming convention for registered textual names
29 -- ----------------------------------------------
30 -- "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
32 -- This is to prevent conflicting names from corrupting maps and is
33 -- enforced by the mod loader.
35 -- Example: mod "experimental", ideal item/node/entity name "tnt":
36 -- -> the name should be "experimental:tnt".
38 -- Enforcement can be overridden by prefixing the name with ":". This can
39 -- be used for overriding the registrations of some other mod.
41 -- Example: Any mod can redefine experimental:tnt by using the name
42 -- ":experimental:tnt" when registering it.
43 -- (also that mods is required to have "experimental" as a dependency)
45 -- The legacy mod uses ":" for maintaining backwards compatibility.
49 -- Mods should generally prefix their textures with modname_, eg. given
50 -- the mod name "foomod", a texture could be called "default_foomod_superfurnace.png"
52 -- This is not crucial and a conflicting name will not corrupt maps.
54 -- Representations of simple things
55 -- --------------------------------
57 -- MapNode representation:
58 -- {name="name", param1=num, param2=num}
60 -- param1 and param2 are 8 bit and 4 bit integers, respectively. They
61 -- are reserved for certain automated functions. If you don't use these
62 -- functions, you can use them to store arbitrary values.
64 -- param1 is reserved for the engine when:
65 -- paramtype != "none"
66 -- param2 is reserved for the engine when any of these are used:
67 -- liquidtype == "flowing"
68 -- drawtype == "flowingliquid"
69 -- drawtype == "torchlike"
70 -- drawtype == "signlike"
72 -- Position representation:
73 -- {x=num, y=num, z=num}
75 -- stackstring/itemstring: A stack of items in serialized format.
76 -- eg. 'node "default:dirt" 5'
77 -- eg. 'tool "default:pick_wood" 21323'
78 -- eg. 'craft "default:apple" 2'
80 -- item: A stack of items in Lua table format.
81 -- eg. {name="default:dirt", count=1, wear=0, metadata=""}
82 -- ^ a single dirt node
83 -- eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
84 -- ^ a wooden pick about 1/3 weared out
85 -- eg. {name="default:apple", count=1, wear=0, metadata=""}
88 -- Any time an item must be passed to a function, it can be an
89 -- ItemStack (see below), an itemstring or a table in the above format.
92 -- minetest.register_entity(name, prototype table)
93 -- minetest.register_abm(abm definition)
94 -- minetest.register_node(name, node definition)
95 -- minetest.register_tool(name, item definition)
96 -- minetest.register_craftitem(name, item definition)
97 -- minetest.register_alias(name, convert_to)
98 -- minetest.register_craft(recipe)
99 -- minetest.register_globalstep(func(dtime))
100 -- minetest.register_on_placenode(func(pos, newnode, placer))
101 -- minetest.register_on_dignode(func(pos, oldnode, digger))
102 -- minetest.register_on_punchnode(func(pos, node, puncher))
103 -- minetest.register_on_generated(func(minp, maxp))
104 -- minetest.register_on_newplayer(func(ObjectRef))
105 -- minetest.register_on_dieplayer(func(ObjectRef))
106 -- minetest.register_on_respawnplayer(func(ObjectRef))
107 -- ^ return true in func to disable regular player placement
108 -- ^ currently called _before_ repositioning of player occurs
109 -- minetest.register_on_chat_message(func(name, message))
110 -- minetest.add_to_creative_inventory(itemstring)
111 -- minetest.setting_get(name) -> string or nil
112 -- minetest.setting_getbool(name) -> boolean value or nil
113 -- minetest.chat_send_all(text)
114 -- minetest.chat_send_player(name, text)
115 -- minetest.get_player_privs(name) -> set of privs
116 -- minetest.get_inventory(location) -> InvRef
117 -- ^ location = eg. {type="player", name="celeron55"}
118 -- {type="node", pos={x=, y=, z=}}
119 -- minetest.get_current_modname() -> string
120 -- minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
121 -- ^ Useful for loading additional .lua modules or static data from mod
122 -- minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
123 -- ^ Useful for storing custom data
125 -- minetest.debug(line)
127 -- minetest.log(line)
128 -- minetest.log(loglevel, line)
129 -- ^ loglevel one of "error", "action", "info", "verbose"
131 -- minetest.digprop_constanttime(time)
132 -- minetest.digprop_stonelike(toughness)
133 -- minetest.digprop_dirtlike(toughness)
134 -- minetest.digprop_gravellike(toughness)
135 -- minetest.digprop_woodlike(toughness)
136 -- minetest.digprop_leaveslike(toughness)
137 -- minetest.digprop_glasslike(toughness)
140 -- minetest.env - environment reference
143 -- minetest.registered_items
144 -- ^ List of registered items, indexed by name
145 -- minetest.registered_nodes
146 -- ^ List of registered node definitions, indexed by name
147 -- minetest.registered_craftitems
148 -- ^ List of registered craft item definitions, indexed by name
149 -- minetest.registered_tools
150 -- ^ List of registered tool definitions, indexed by name
151 -- minetest.registered_entities
152 -- ^ List of registered entity prototypes, indexed by name
153 -- minetest.object_refs
154 -- ^ List of object references, indexed by active object id
155 -- minetest.luaentities
156 -- ^ List of lua entities, indexed by active object id
158 -- EnvRef is basically ServerEnvironment and ServerMap combined.
160 -- - add_node(pos, node)
161 -- - remove_node(pos)
163 -- ^ Returns {name="ignore", ...} for unloaded area
164 -- - get_node_or_nil(pos)
165 -- ^ Returns nil for unloaded area
166 -- - get_node_light(pos, timeofday) -> 0...15 or nil
167 -- ^ timeofday: nil = current time, 0 = night, 0.5 = day
168 -- - add_entity(pos, name): Returns ObjectRef or nil if failed
169 -- - add_item(pos, itemstring)
171 -- - add_firefly(pos)
172 -- - get_meta(pos) -- Get a NodeMetaRef at that position
173 -- - get_player_by_name(name) -- Get an ObjectRef to a player
174 -- - get_objects_inside_radius(pos, radius)
175 -- - set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
178 -- NodeMetaRef (this stuff is subject to change in a future version)
180 -- - allows_text_input()
181 -- - set_text(text) -- eg. set the text of a sign
184 -- - set_owner(string)
185 -- Generic node metadata specific:
186 -- - set_infotext(infotext)
187 -- - get_inventory() -> InvRef
188 -- - set_inventory_draw_spec(string)
189 -- - set_allow_text_input(bool)
190 -- - set_allow_removal(bool)
191 -- - set_enforce_owner(bool)
192 -- - is_inventory_modified()
193 -- - reset_inventory_modified()
194 -- - is_text_modified()
195 -- - reset_text_modified()
196 -- - set_string(name, value)
197 -- - get_string(name)
199 -- ObjectRef is basically ServerActiveObject.
200 -- ObjectRef methods:
201 -- - remove(): remove object (after returning from Lua)
202 -- - getpos() -> {x=num, y=num, z=num}
203 -- - setpos(pos); pos={x=num, y=num, z=num}
204 -- - moveto(pos, continuous=false): interpolated move
205 -- - punch(puncher, time_from_last_punch, tool_capabilities, direction)
206 -- ^ puncher = an another ObjectRef,
207 -- ^ time_from_last_punch = time since last punch action of the puncher
208 -- - right_click(clicker); clicker = an another ObjectRef
209 -- - get_hp(): returns number of hitpoints (2 * number of hearts)
210 -- - set_hp(hp): set number of hitpoints (2 * number of hearts)
211 -- - get_inventory() -> InvRef
212 -- - get_wield_list(): returns the name of the inventory list the wielded item is in
213 -- - get_wield_index(): returns the index of the wielded item
214 -- - get_wielded_item() -> ItemStack
215 -- - set_wielded_item(item): replaces the wielded item, returns true if successful
216 -- LuaEntitySAO-only: (no-op for other objects)
217 -- - setvelocity({x=num, y=num, z=num})
218 -- - getvelocity() -> {x=num, y=num, z=num}
219 -- - setacceleration({x=num, y=num, z=num})
220 -- - getacceleration() -> {x=num, y=num, z=num}
222 -- - getyaw() -> radians
223 -- - settexturemod(mod)
224 -- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
225 -- - select_horiz_by_yawpitch=false)
226 -- - ^ Select sprite from spritesheet with optional animation and DM-style
227 -- - texture selection based on yaw relative to camera
228 -- - set_armor_groups({group1=rating, group2=rating, ...})
229 -- - get_entity_name() (DEPRECATED: Will be removed in a future version)
231 -- Player-only: (no-op for other objects)
232 -- - get_player_name(): will return nil if is not a player
233 -- - get_look_dir(): get camera direction as a unit vector
234 -- - get_look_pitch(): pitch in radians
235 -- - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
238 -- - get_size(listname): get size of a list
239 -- - set_size(listname, size): set size of a list
240 -- - get_stack(listname, i): get a copy of stack index i in list
241 -- - set_stack(listname, i, stack): copy stack to index i in list
242 -- - get_list(listname): return full list
243 -- - set_list(listname, list): set full list (size will not change)
244 -- - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
245 -- - room_for_item(listname, stack): returns true if the stack of items
246 -- can be fully added to the list
247 -- - contains_item(listname, stack): returns true if the stack of items
248 -- can be fully taken from the list
249 -- remove_item(listname, stack): take as many items as specified from the list,
250 -- returns the items that were actually removed (as an ItemStack)
252 -- ItemStack methods:
253 -- - is_empty(): return true if stack is empty
254 -- - get_name(): returns item name (e.g. "default:stone")
255 -- - get_count(): returns number of items on the stack
256 -- - get_wear(): returns tool wear (0-65535), 0 for non-tools
257 -- - get_metadata(): returns metadata (a string attached to an item stack)
258 -- - clear(): removes all items from the stack, making it empty
259 -- - replace(item): replace the contents of this stack (item can also
260 -- be an itemstring or table)
261 -- - to_string(): returns the stack in itemstring form
262 -- - to_table(): returns the stack in Lua table form
263 -- - get_stack_max(): returns the maximum size of the stack (depends on the item)
264 -- - get_free_space(): returns get_stack_max() - get_count()
265 -- - is_known(): returns true if the item name refers to a defined item type
266 -- - get_definition(): returns the item definition table
267 -- - get_tool_capabilities(): returns the digging properties of the item,
268 -- ^ or those of the hand if none are defined for this item type
269 -- - add_wear(amount): increases wear by amount if the item is a tool
270 -- - add_item(item): put some item or stack onto this stack,
271 -- ^ returns leftover ItemStack
272 -- - item_fits(item): returns true if item or stack can be fully added to this one
273 -- - take_item(n): take (and remove) up to n items from this stack
274 -- ^ returns taken ItemStack
275 -- ^ if n is omitted, n=1 is used
276 -- - peek_item(n): copy (don't remove) up to n items from this stack
277 -- ^ returns copied ItemStack
278 -- ^ if n is omitted, n=1 is used
280 -- Registered entities:
281 -- - Functions receive a "luaentity" as self:
282 -- - It has the member .name, which is the registered name ("mod:thing")
283 -- - It has the member .object, which is an ObjectRef pointing to the object
284 -- - The original prototype stuff is visible directly via a metatable
286 -- - on_activate(self, staticdata)
287 -- - on_step(self, dtime)
288 -- - on_punch(self, hitter)
289 -- - on_rightclick(self, clicker)
290 -- - get_staticdata(self)
291 -- ^ return string that will be passed to on_activate when the object
292 -- is created next time
294 -- Entity prototype table:
297 -- collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
298 -- visual = "cube"/"sprite",
299 -- visual_size = {x=1, y=1},
300 -- textures = {texture,texture,texture,texture,texture,texture},
301 -- spritediv = {x=1, y=1},
302 -- initial_sprite_basepos = {x=0, y=0},
303 -- on_activate = function(self, staticdata),
304 -- on_step = function(self, dtime),
305 -- on_punch = function(self, hitter),
306 -- on_rightclick = function(self, clicker),
307 -- get_staticdata = function(self),
308 -- # Also you can define arbitrary member variables here
309 -- myvariable = whatever,
312 -- Item definition options (register_node, register_craftitem, register_tool)
314 -- description = "Steel Axe",
315 -- groups = {}, -- key=name, value=rating; rating=1..3.
316 -- if rating not applicable, use 1.
317 -- eg. {wool=1, fluffy=3}
318 -- {soil=2, outerspace=1, crumbly=1}
319 -- {hard=3, brittle=3, spikes=2
320 -- {hard=1, metal=1, spikes=1}
321 -- inventory_image = "default_tool_steelaxe.png",
323 -- wield_scale = {x=1,y=1,z=1},
325 -- liquids_pointable = false,
326 -- tool_capabilities = {
327 -- full_punch_interval = 1.0,
330 -- dt_crackiness = -0.2,
331 -- dt_crumbliness = 1,
332 -- dt_cuttability = -0.5,
333 -- basedurability = 330,
335 -- dd_crackiness = 0,
336 -- dd_crumbliness = 0,
337 -- dd_cuttability = 0,
339 -- on_drop = func(item, dropper, pos),
340 -- on_place = func(item, placer, pointed_thing),
341 -- on_use = func(item, user, pointed_thing),
344 -- Node definition options (register_node):
346 -- <all fields allowed in item definitions>,
347 -- drawtype = "normal",
348 -- visual_scale = 1.0,
349 -- tile_images = {"default_unknown_block.png"},
350 -- special_materials = {
351 -- {image="", backface_culling=true},
352 -- {image="", backface_culling=true},
355 -- post_effect_color = {a=0, r=0, g=0, b=0},
356 -- paramtype = "none",
357 -- paramtype2 = "none",
358 -- is_ground_content = false,
359 -- sunlight_propagates = false,
363 -- climbable = false,
364 -- buildable_to = false,
366 -- -- alternatively drop = { max_items = ..., items = { ... } }
367 -- metadata_name = "",
368 -- liquidtype = "none",
369 -- liquid_alternative_flowing = "",
370 -- liquid_alternative_source = "",
371 -- liquid_viscosity = 0,
373 -- damage_per_second = 0,
374 -- selection_box = {type="regular"},
375 -- legacy_facedir_simple = false, -- Support maps made in and before January 2012
376 -- legacy_wallmounted = false, -- Support maps made in and before January 2012
381 -- output = 'default:pick_stone',
383 -- {'default:cobble', 'default:cobble', 'default:cobble'},
384 -- {'', 'default:stick', ''},
385 -- {'', 'default:stick', ''},
387 -- replacements = <optional list of item pairs,
388 -- replace one input item with another item on crafting>
391 -- Recipe (shapeless):
393 -- type = "shapeless",
394 -- output = 'mushrooms:mushroom_stew',
397 -- "mushrooms:mushroom_brown",
398 -- "mushrooms:mushroom_red",
400 -- replacements = <optional list of item pairs,
401 -- replace one input item with another item on crafting>
404 -- Recipe (tool repair):
406 -- type = "toolrepair",
407 -- additional_wear = -0.02,
413 -- output = "default:glass",
414 -- recipe = "default:sand",
418 -- Recipe (furnace fuel):
421 -- recipe = "default:leaves",
425 -- ABM (ActiveBlockModifier) definition:
427 -- nodenames = {"default:lava_source"},
428 -- neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
429 -- ^ If left out or empty, any neighbor will do
430 -- ^ This might get removed in the future
431 -- interval = 1.0, -- (operation interval)
432 -- chance = 1, -- (chance of trigger is 1.0/this)
433 -- action = func(pos, node, active_object_count, active_object_count_wider),
441 -- Definitions made by this mod that other mods can use too
449 minetest.register_item(":", {
451 wield_image = "wieldhand.png",
452 wield_scale = {x=1,y=1,z=2.5},
453 tool_capabilities = {
454 full_punch_interval = 1.0,
457 fleshy = {times={[2]=2.00, [3]=1.00}, maxwear=0, maxlevel=1},
458 crumbly = {times={[3]=0.70}, maxwear=0, maxlevel=1},
459 snappy = {times={[3]=0.70}, maxwear=0, maxlevel=1},
464 minetest.register_tool("default:pick_wood", {
465 description = "Wooden Pickaxe",
466 inventory_image = "default_tool_woodpick.png",
467 tool_capabilities = {
470 cracky={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
474 minetest.register_tool("default:pick_stone", {
475 description = "Stone Pickaxe",
476 inventory_image = "default_tool_stonepick.png",
477 tool_capabilities = {
480 cracky={times={[1]=1.50, [2]=0.80, [3]=0.60}, maxwear=0.05, maxlevel=1}
484 minetest.register_tool("default:pick_steel", {
485 description = "Steel Pickaxe",
486 inventory_image = "default_tool_steelpick.png",
487 tool_capabilities = {
490 cracky={times={[1]=1.00, [2]=0.60, [3]=0.40}, maxwear=0.1, maxlevel=2}
494 minetest.register_tool("default:pick_mese", {
495 description = "Mese Pickaxe",
496 inventory_image = "default_tool_mesepick.png",
497 tool_capabilities = {
500 cracky={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
501 crumbly={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3},
502 snappy={times={[1]=0.2, [2]=0.2, [3]=0.2}, maxwear=0.05, maxlevel=3}
506 minetest.register_tool("default:shovel_wood", {
507 description = "Wooden Shovel",
508 inventory_image = "default_tool_woodshovel.png",
509 tool_capabilities = {
512 crumbly={times={[1]=1.50, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=1}
516 minetest.register_tool("default:shovel_stone", {
517 description = "Stone Shovel",
518 inventory_image = "default_tool_stoneshovel.png",
519 tool_capabilities = {
522 crumbly={times={[1]=0.80, [2]=0.50, [3]=0.30}, maxwear=0.05, maxlevel=1}
526 minetest.register_tool("default:shovel_steel", {
527 description = "Steel Shovel",
528 inventory_image = "default_tool_steelshovel.png",
529 tool_capabilities = {
532 crumbly={times={[1]=0.50, [2]=0.35, [3]=0.30}, maxwear=0.1, maxlevel=2}
536 minetest.register_tool("default:axe_wood", {
537 description = "Wooden Axe",
538 inventory_image = "default_tool_woodaxe.png",
539 tool_capabilities = {
542 choppy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1},
543 fleshy={times={[2]=1.50, [3]=0.80}, maxwear=0.1, maxlevel=1}
547 minetest.register_tool("default:axe_stone", {
548 description = "Stone Axe",
549 inventory_image = "default_tool_stoneaxe.png",
550 tool_capabilities = {
553 choppy={times={[1]=1.50, [2]=1.00, [3]=0.60}, maxwear=0.05, maxlevel=1},
554 fleshy={times={[2]=1.30, [3]=0.70}, maxwear=0.05, maxlevel=1}
558 minetest.register_tool("default:axe_steel", {
559 description = "Steel Axe",
560 inventory_image = "default_tool_steelaxe.png",
561 tool_capabilities = {
564 choppy={times={[1]=1.00, [2]=0.80, [3]=0.50}, maxwear=0.1, maxlevel=2},
565 fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.03, maxlevel=1}
569 minetest.register_tool("default:sword_wood", {
570 description = "Wooden Sword",
571 inventory_image = "default_tool_woodsword.png",
572 tool_capabilities = {
573 full_punch_interval = 1.0,
576 fleshy={times={[2]=1.10, [3]=0.60}, maxwear=0.1, maxlevel=1},
577 snappy={times={[2]=1.00, [3]=0.50}, maxwear=0.1, maxlevel=1},
578 choppy={times={[3]=1.00}, maxwear=0.05, maxlevel=0}
582 minetest.register_tool("default:sword_stone", {
583 description = "Stone Sword",
584 inventory_image = "default_tool_stonesword.png",
585 tool_capabilities = {
586 full_punch_interval = 1.0,
589 fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
590 snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
591 choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
595 minetest.register_tool("default:sword_steel", {
596 description = "Steel Sword",
597 inventory_image = "default_tool_steelsword.png",
598 tool_capabilities = {
599 full_punch_interval = 1.0,
602 fleshy={times={[1]=1.00, [2]=0.40, [3]=0.20}, maxwear=0.1, maxlevel=2},
603 snappy={times={[2]=0.70, [3]=0.30}, maxwear=0.03, maxlevel=1},
604 choppy={times={[3]=0.70}, maxwear=0.03, maxlevel=0}
610 -- Crafting definition
613 minetest.register_craft({
614 output = 'default:wood 4',
620 minetest.register_craft({
621 output = 'default:stick 4',
627 minetest.register_craft({
628 output = 'default:fence_wood 2',
630 {'default:stick', 'default:stick', 'default:stick'},
631 {'default:stick', 'default:stick', 'default:stick'},
635 minetest.register_craft({
636 output = 'default:sign_wall',
638 {'default:wood', 'default:wood', 'default:wood'},
639 {'default:wood', 'default:wood', 'default:wood'},
640 {'', 'default:stick', ''},
644 minetest.register_craft({
645 output = 'default:torch 4',
647 {'default:coal_lump'},
652 minetest.register_craft({
653 output = 'default:pick_wood',
655 {'default:wood', 'default:wood', 'default:wood'},
656 {'', 'default:stick', ''},
657 {'', 'default:stick', ''},
661 minetest.register_craft({
662 output = 'default:pick_stone',
664 {'default:cobble', 'default:cobble', 'default:cobble'},
665 {'', 'default:stick', ''},
666 {'', 'default:stick', ''},
670 minetest.register_craft({
671 output = 'default:pick_steel',
673 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
674 {'', 'default:stick', ''},
675 {'', 'default:stick', ''},
679 minetest.register_craft({
680 output = 'default:pick_mese',
682 {'default:mese', 'default:mese', 'default:mese'},
683 {'', 'default:stick', ''},
684 {'', 'default:stick', ''},
688 minetest.register_craft({
689 output = 'default:shovel_wood',
697 minetest.register_craft({
698 output = 'default:shovel_stone',
706 minetest.register_craft({
707 output = 'default:shovel_steel',
709 {'default:steel_ingot'},
715 minetest.register_craft({
716 output = 'default:axe_wood',
718 {'default:wood', 'default:wood'},
719 {'default:wood', 'default:stick'},
720 {'', 'default:stick'},
724 minetest.register_craft({
725 output = 'default:axe_stone',
727 {'default:cobble', 'default:cobble'},
728 {'default:cobble', 'default:stick'},
729 {'', 'default:stick'},
733 minetest.register_craft({
734 output = 'default:axe_steel',
736 {'default:steel_ingot', 'default:steel_ingot'},
737 {'default:steel_ingot', 'default:stick'},
738 {'', 'default:stick'},
742 minetest.register_craft({
743 output = 'default:sword_wood',
751 minetest.register_craft({
752 output = 'default:sword_stone',
760 minetest.register_craft({
761 output = 'default:sword_steel',
763 {'default:steel_ingot'},
764 {'default:steel_ingot'},
769 minetest.register_craft({
770 output = 'default:rail 15',
772 {'default:steel_ingot', '', 'default:steel_ingot'},
773 {'default:steel_ingot', 'default:stick', 'default:steel_ingot'},
774 {'default:steel_ingot', '', 'default:steel_ingot'},
778 minetest.register_craft({
779 output = 'default:chest',
781 {'default:wood', 'default:wood', 'default:wood'},
782 {'default:wood', '', 'default:wood'},
783 {'default:wood', 'default:wood', 'default:wood'},
787 minetest.register_craft({
788 output = 'default:chest_locked',
790 {'default:wood', 'default:wood', 'default:wood'},
791 {'default:wood', 'default:steel_ingot', 'default:wood'},
792 {'default:wood', 'default:wood', 'default:wood'},
796 minetest.register_craft({
797 output = 'default:furnace',
799 {'default:cobble', 'default:cobble', 'default:cobble'},
800 {'default:cobble', '', 'default:cobble'},
801 {'default:cobble', 'default:cobble', 'default:cobble'},
805 minetest.register_craft({
806 output = 'default:steelblock',
808 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
809 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
810 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
814 minetest.register_craft({
815 output = 'default:sandstone',
817 {'default:sand', 'default:sand'},
818 {'default:sand', 'default:sand'},
822 minetest.register_craft({
823 output = 'default:clay',
825 {'default:clay_lump', 'default:clay_lump'},
826 {'default:clay_lump', 'default:clay_lump'},
830 minetest.register_craft({
831 output = 'default:brick',
833 {'default:clay_brick', 'default:clay_brick'},
834 {'default:clay_brick', 'default:clay_brick'},
838 minetest.register_craft({
839 output = 'default:paper',
841 {'default:papyrus', 'default:papyrus', 'default:papyrus'},
845 minetest.register_craft({
846 output = 'default:book',
854 minetest.register_craft({
855 output = 'default:bookshelf',
857 {'default:wood', 'default:wood', 'default:wood'},
858 {'default:book', 'default:book', 'default:book'},
859 {'default:wood', 'default:wood', 'default:wood'},
863 minetest.register_craft({
864 output = 'default:ladder',
866 {'default:stick', '', 'default:stick'},
867 {'default:stick', 'default:stick', 'default:stick'},
868 {'default:stick', '', 'default:stick'},
873 -- Crafting (tool repair)
875 minetest.register_craft({
877 additional_wear = -0.02,
884 minetest.register_craft({
886 output = "default:glass",
887 recipe = "default:sand",
890 minetest.register_craft({
892 output = "default:coal_lump",
893 recipe = "default:tree",
896 minetest.register_craft({
898 output = "default:coal_lump",
899 recipe = "default:jungletree",
902 minetest.register_craft({
904 output = "default:stone",
905 recipe = "default:cobble",
908 minetest.register_craft({
910 output = "default:steel_ingot",
911 recipe = "default:iron_lump",
914 minetest.register_craft({
916 output = "default:clay_brick",
917 recipe = "default:clay_lump",
924 minetest.register_craft({
926 recipe = "default:tree",
930 minetest.register_craft({
932 recipe = "default:jungletree",
936 minetest.register_craft({
938 recipe = "default:junglegrass",
942 minetest.register_craft({
944 recipe = "default:leaves",
948 minetest.register_craft({
950 recipe = "default:cactus",
954 minetest.register_craft({
956 recipe = "default:papyrus",
960 minetest.register_craft({
962 recipe = "default:bookshelf",
966 minetest.register_craft({
968 recipe = "default:fence_wood",
972 minetest.register_craft({
974 recipe = "default:ladder",
978 minetest.register_craft({
980 recipe = "default:wood",
984 minetest.register_craft({
986 recipe = "default:mese",
990 minetest.register_craft({
992 recipe = "default:lava_source",
996 minetest.register_craft({
998 recipe = "default:torch",
1002 minetest.register_craft({
1004 recipe = "default:sign_wall",
1008 minetest.register_craft({
1010 recipe = "default:chest",
1014 minetest.register_craft({
1016 recipe = "default:chest_locked",
1020 minetest.register_craft({
1022 recipe = "default:nyancat",
1026 minetest.register_craft({
1028 recipe = "default:nyancat_rainbow",
1032 minetest.register_craft({
1034 recipe = "default:sapling",
1038 minetest.register_craft({
1040 recipe = "default:apple",
1044 minetest.register_craft({
1046 recipe = "default:coal_lump",
1054 minetest.register_node("default:stone", {
1055 description = "Stone",
1056 tile_images = {"default_stone.png"},
1057 is_ground_content = true,
1058 groups = {cracky=3},
1059 drop = 'default:cobble',
1060 legacy_mineral = true,
1063 minetest.register_node("default:stone_with_coal", {
1064 description = "Stone with coal",
1065 tile_images = {"default_stone.png^default_mineral_coal.png"},
1066 is_ground_content = true,
1067 groups = {cracky=3},
1068 drop = 'default:coal_lump',
1071 minetest.register_node("default:stone_with_iron", {
1072 description = "Stone with iron",
1073 tile_images = {"default_stone.png^default_mineral_iron.png"},
1074 is_ground_content = true,
1075 groups = {cracky=3},
1076 drop = 'default:iron_lump',
1079 minetest.register_node("default:dirt_with_grass", {
1080 description = "Dirt with grass",
1081 tile_images = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1082 is_ground_content = true,
1083 groups = {crumbly=3},
1084 drop = 'default:dirt',
1087 minetest.register_node("default:dirt_with_grass_footsteps", {
1088 description = "Dirt with grass and footsteps",
1089 tile_images = {"default_grass_footsteps.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"},
1090 is_ground_content = true,
1091 groups = {crumbly=3},
1092 drop = 'default:dirt',
1095 minetest.register_node("default:dirt", {
1096 description = "Dirt",
1097 tile_images = {"default_dirt.png"},
1098 is_ground_content = true,
1099 groups = {crumbly=3},
1102 minetest.register_node("default:sand", {
1103 description = "Sand",
1104 tile_images = {"default_sand.png"},
1105 is_ground_content = true,
1106 groups = {crumbly=3},
1109 minetest.register_node("default:gravel", {
1110 description = "Gravel",
1111 tile_images = {"default_gravel.png"},
1112 is_ground_content = true,
1113 groups = {crumbly=2},
1116 minetest.register_node("default:sandstone", {
1117 description = "Sandstone",
1118 tile_images = {"default_sandstone.png"},
1119 is_ground_content = true,
1120 groups = {crumbly=2,cracky=2},
1121 drop = 'default:sand',
1124 minetest.register_node("default:clay", {
1125 description = "Clay",
1126 tile_images = {"default_clay.png"},
1127 is_ground_content = true,
1128 groups = {crumbly=3},
1129 drop = 'default:clay_lump 4',
1132 minetest.register_node("default:brick", {
1133 description = "Brick",
1134 tile_images = {"default_brick.png"},
1135 is_ground_content = true,
1136 groups = {cracky=3},
1137 drop = 'default:clay_brick 4',
1140 minetest.register_node("default:tree", {
1141 description = "Tree",
1142 tile_images = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"},
1143 is_ground_content = true,
1144 groups = {snappy=2,choppy=2},
1147 minetest.register_node("default:jungletree", {
1148 description = "Jungle Tree",
1149 tile_images = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
1150 is_ground_content = true,
1151 groups = {snappy=2,choppy=2},
1154 minetest.register_node("default:junglegrass", {
1155 description = "Jungle Grass",
1156 drawtype = "plantlike",
1158 tile_images = {"default_junglegrass.png"},
1159 inventory_image = "default_junglegrass.png",
1160 wield_image = "default_junglegrass.png",
1161 paramtype = "light",
1163 groups = {snappy=3},
1166 minetest.register_node("default:leaves", {
1167 description = "Leaves",
1168 drawtype = "allfaces_optional",
1170 tile_images = {"default_leaves.png"},
1171 paramtype = "light",
1172 groups = {snappy=3},
1177 -- player will get sapling with 1/20 chance
1178 items = {'default:sapling'},
1182 -- player will get leaves only if he get no saplings,
1183 -- this is because max_items is 1
1184 items = {'default:leaves'},
1190 minetest.register_node("default:cactus", {
1191 description = "Cactus",
1192 tile_images = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_side.png"},
1193 is_ground_content = true,
1194 groups = {snappy=2,choppy=3},
1197 minetest.register_node("default:papyrus", {
1198 description = "Papyrus",
1199 drawtype = "plantlike",
1200 tile_images = {"default_papyrus.png"},
1201 inventory_image = "default_papyrus.png",
1202 wield_image = "default_papyrus.png",
1203 paramtype = "light",
1204 is_ground_content = true,
1206 groups = {snappy=3},
1209 minetest.register_node("default:bookshelf", {
1210 description = "Bookshelf",
1211 tile_images = {"default_wood.png", "default_wood.png", "default_bookshelf.png"},
1212 is_ground_content = true,
1213 groups = {snappy=2,choppy=3},
1216 minetest.register_node("default:glass", {
1217 description = "Glass",
1218 drawtype = "glasslike",
1219 tile_images = {"default_glass.png"},
1220 inventory_image = minetest.inventorycube("default_glass.png"),
1221 paramtype = "light",
1222 sunlight_propagates = true,
1223 is_ground_content = true,
1224 groups = {snappy=2,cracky=3},
1227 minetest.register_node("default:fence_wood", {
1228 description = "Wooden Fence",
1229 drawtype = "fencelike",
1230 tile_images = {"default_wood.png"},
1231 inventory_image = "default_fence.png",
1232 wield_image = "default_fence.png",
1233 paramtype = "light",
1234 is_ground_content = true,
1237 fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
1239 groups = {snappy=2,choppy=2},
1242 minetest.register_node("default:rail", {
1243 description = "Rail",
1244 drawtype = "raillike",
1245 tile_images = {"default_rail.png", "default_rail_curved.png", "default_rail_t_junction.png", "default_rail_crossing.png"},
1246 inventory_image = "default_rail.png",
1247 wield_image = "default_rail.png",
1248 paramtype = "light",
1249 is_ground_content = true,
1255 groups = {bendy=2,snappy=1},
1258 minetest.register_node("default:ladder", {
1259 description = "Ladder",
1260 drawtype = "signlike",
1261 tile_images = {"default_ladder.png"},
1262 inventory_image = "default_ladder.png",
1263 wield_image = "default_ladder.png",
1264 paramtype = "light",
1265 paramtype2 = "wallmounted",
1266 is_ground_content = true,
1270 type = "wallmounted",
1271 --wall_top = = <default>
1272 --wall_bottom = = <default>
1273 --wall_side = = <default>
1275 groups = {snappy=2,choppy=2},
1276 legacy_wallmounted = true,
1279 minetest.register_node("default:wood", {
1280 description = "Wood",
1281 tile_images = {"default_wood.png"},
1282 is_ground_content = true,
1283 groups = {snappy=2,choppy=2},
1286 minetest.register_node("default:mese", {
1287 description = "Mese",
1288 tile_images = {"default_mese.png"},
1289 is_ground_content = true,
1290 groups = {cracky=1},
1293 minetest.register_node("default:cloud", {
1294 description = "Cloud",
1295 tile_images = {"default_cloud.png"},
1296 is_ground_content = true,
1299 minetest.register_node("default:water_flowing", {
1300 description = "Water (flowing)",
1301 inventory_image = minetest.inventorycube("default_water.png"),
1302 drawtype = "flowingliquid",
1303 tile_images = {"default_water.png"},
1304 alpha = WATER_ALPHA,
1305 paramtype = "light",
1309 buildable_to = true,
1310 liquidtype = "flowing",
1311 liquid_alternative_flowing = "default:water_flowing",
1312 liquid_alternative_source = "default:water_source",
1313 liquid_viscosity = WATER_VISC,
1314 post_effect_color = {a=64, r=100, g=100, b=200},
1315 special_materials = {
1316 {image="default_water.png", backface_culling=false},
1317 {image="default_water.png", backface_culling=true},
1319 groups = {water=3, liquid=3},
1322 minetest.register_node("default:water_source", {
1323 description = "Water",
1324 inventory_image = minetest.inventorycube("default_water.png"),
1325 drawtype = "liquid",
1326 tile_images = {"default_water.png"},
1327 alpha = WATER_ALPHA,
1328 paramtype = "light",
1332 buildable_to = true,
1333 liquidtype = "source",
1334 liquid_alternative_flowing = "default:water_flowing",
1335 liquid_alternative_source = "default:water_source",
1336 liquid_viscosity = WATER_VISC,
1337 post_effect_color = {a=64, r=100, g=100, b=200},
1338 special_materials = {
1339 -- New-style water source material (mostly unused)
1340 {image="default_water.png", backface_culling=false},
1342 groups = {water=3, liquid=3},
1345 minetest.register_node("default:lava_flowing", {
1346 description = "Lava (flowing)",
1347 inventory_image = minetest.inventorycube("default_lava.png"),
1348 drawtype = "flowingliquid",
1349 tile_images = {"default_lava.png"},
1350 paramtype = "light",
1351 light_source = LIGHT_MAX - 1,
1355 buildable_to = true,
1356 liquidtype = "flowing",
1357 liquid_alternative_flowing = "default:lava_flowing",
1358 liquid_alternative_source = "default:lava_source",
1359 liquid_viscosity = LAVA_VISC,
1360 damage_per_second = 4*2,
1361 post_effect_color = {a=192, r=255, g=64, b=0},
1362 special_materials = {
1363 {image="default_lava.png", backface_culling=false},
1364 {image="default_lava.png", backface_culling=true},
1366 groups = {lava=3, liquid=2, hot=3},
1369 minetest.register_node("default:lava_source", {
1370 description = "Lava",
1371 inventory_image = minetest.inventorycube("default_lava.png"),
1372 drawtype = "liquid",
1373 tile_images = {"default_lava.png"},
1374 paramtype = "light",
1375 light_source = LIGHT_MAX - 1,
1379 buildable_to = true,
1380 liquidtype = "source",
1381 liquid_alternative_flowing = "default:lava_flowing",
1382 liquid_alternative_source = "default:lava_source",
1383 liquid_viscosity = LAVA_VISC,
1384 damage_per_second = 4*2,
1385 post_effect_color = {a=192, r=255, g=64, b=0},
1386 special_materials = {
1387 -- New-style lava source material (mostly unused)
1388 {image="default_lava.png", backface_culling=false},
1390 groups = {lava=3, liquid=2, hot=3},
1393 minetest.register_node("default:torch", {
1394 description = "Torch",
1395 drawtype = "torchlike",
1396 tile_images = {"default_torch_on_floor.png", "default_torch_on_ceiling.png", "default_torch.png"},
1397 inventory_image = "default_torch_on_floor.png",
1398 wield_image = "default_torch_on_floor.png",
1399 paramtype = "light",
1400 paramtype2 = "wallmounted",
1401 sunlight_propagates = true,
1403 light_source = LIGHT_MAX-1,
1405 type = "wallmounted",
1406 wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
1407 wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
1408 wall_side = {-0.5, -0.3, -0.1, -0.5+0.3, 0.3, 0.1},
1410 groups = {dig_immediate=1},
1411 legacy_wallmounted = true,
1414 minetest.register_node("default:sign_wall", {
1415 description = "Sign",
1416 drawtype = "signlike",
1417 tile_images = {"default_sign_wall.png"},
1418 inventory_image = "default_sign_wall.png",
1419 wield_image = "default_sign_wall.png",
1420 paramtype = "light",
1421 paramtype2 = "wallmounted",
1422 sunlight_propagates = true,
1424 metadata_name = "sign",
1426 type = "wallmounted",
1427 --wall_top = <default>
1428 --wall_bottom = <default>
1429 --wall_side = <default>
1431 groups = {dig_immediate=2},
1432 legacy_wallmounted = true,
1435 minetest.register_node("default:chest", {
1436 description = "Chest",
1437 tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1438 "default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
1439 paramtype2 = "facedir",
1440 metadata_name = "chest",
1441 groups = {snappy=2,choppy=2},
1442 legacy_facedir_simple = true,
1445 minetest.register_node("default:chest_locked", {
1446 description = "Locked Chest",
1447 tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
1448 "default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
1449 paramtype2 = "facedir",
1450 metadata_name = "locked_chest",
1451 groups = {snappy=2,choppy=2},
1452 legacy_facedir_simple = true,
1455 minetest.register_node("default:furnace", {
1456 description = "Furnace",
1457 tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
1458 "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
1459 paramtype2 = "facedir",
1460 metadata_name = "furnace",
1461 groups = {cracky=2},
1462 legacy_facedir_simple = true,
1465 minetest.register_node("default:cobble", {
1466 description = "Cobble",
1467 tile_images = {"default_cobble.png"},
1468 is_ground_content = true,
1469 groups = {cracky=3},
1472 minetest.register_node("default:mossycobble", {
1473 description = "Mossy Cobble",
1474 tile_images = {"default_mossycobble.png"},
1475 is_ground_content = true,
1476 groups = {cracky=3},
1479 minetest.register_node("default:steelblock", {
1480 description = "Steel Block",
1481 tile_images = {"default_steel_block.png"},
1482 is_ground_content = true,
1483 groups = {snappy=1,bendy=2},
1486 minetest.register_node("default:nyancat", {
1487 description = "Nyancat",
1488 tile_images = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
1489 "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
1490 inventory_image = "default_nc_front.png",
1491 paramtype2 = "facedir",
1492 groups = {cracky=2},
1493 legacy_facedir_simple = true,
1496 minetest.register_node("default:nyancat_rainbow", {
1497 description = "Nyancat Rainbow",
1498 tile_images = {"default_nc_rb.png"},
1499 inventory_image = "default_nc_rb.png",
1500 groups = {cracky=2},
1503 minetest.register_node("default:sapling", {
1504 description = "Sapling",
1505 drawtype = "plantlike",
1507 tile_images = {"default_sapling.png"},
1508 inventory_image = "default_sapling.png",
1509 wield_image = "default_sapling.png",
1510 paramtype = "light",
1512 groups = {dig_immediate=1},
1515 minetest.register_node("default:apple", {
1516 description = "Apple",
1517 drawtype = "plantlike",
1519 tile_images = {"default_apple.png"},
1520 inventory_image = "default_apple.png",
1521 paramtype = "light",
1522 sunlight_propagates = true,
1524 groups = {dig_immediate=1},
1525 on_use = minetest.item_eat(4),
1532 minetest.register_craftitem("default:stick", {
1533 description = "Stick",
1534 inventory_image = "default_stick.png",
1537 minetest.register_craftitem("default:paper", {
1538 description = "Paper",
1539 inventory_image = "default_paper.png",
1542 minetest.register_craftitem("default:book", {
1543 description = "Book",
1544 inventory_image = "default_book.png",
1547 minetest.register_craftitem("default:coal_lump", {
1548 description = "Lump of coal",
1549 inventory_image = "default_coal_lump.png",
1552 minetest.register_craftitem("default:iron_lump", {
1553 description = "Lump of iron",
1554 inventory_image = "default_iron_lump.png",
1557 minetest.register_craftitem("default:clay_lump", {
1558 description = "Lump of clay",
1559 inventory_image = "default_clay_lump.png",
1562 minetest.register_craftitem("default:steel_ingot", {
1563 description = "Steel ingot",
1564 inventory_image = "default_steel_ingot.png",
1567 minetest.register_craftitem("default:clay_brick", {
1568 description = "Clay brick",
1569 inventory_image = "default_steel_ingot.png",
1570 inventory_image = "default_clay_brick.png",
1573 minetest.register_craftitem("default:scorched_stuff", {
1574 description = "Scorched stuff",
1575 inventory_image = "default_scorched_stuff.png",
1579 -- Creative inventory
1582 minetest.add_to_creative_inventory('default:pick_mese')
1583 minetest.add_to_creative_inventory('default:pick_steel')
1584 minetest.add_to_creative_inventory('default:axe_steel')
1585 minetest.add_to_creative_inventory('default:shovel_steel')
1587 minetest.add_to_creative_inventory('default:torch')
1588 minetest.add_to_creative_inventory('default:cobble')
1589 minetest.add_to_creative_inventory('default:dirt')
1590 minetest.add_to_creative_inventory('default:stone')
1591 minetest.add_to_creative_inventory('default:sand')
1592 minetest.add_to_creative_inventory('default:sandstone')
1593 minetest.add_to_creative_inventory('default:clay')
1594 minetest.add_to_creative_inventory('default:brick')
1595 minetest.add_to_creative_inventory('default:tree')
1596 minetest.add_to_creative_inventory('default:wood')
1597 minetest.add_to_creative_inventory('default:leaves')
1598 minetest.add_to_creative_inventory('default:cactus')
1599 minetest.add_to_creative_inventory('default:papyrus')
1600 minetest.add_to_creative_inventory('default:bookshelf')
1601 minetest.add_to_creative_inventory('default:glass')
1602 minetest.add_to_creative_inventory('default:fence_wood')
1603 minetest.add_to_creative_inventory('default:rail')
1604 minetest.add_to_creative_inventory('default:mese')
1605 minetest.add_to_creative_inventory('default:chest')
1606 minetest.add_to_creative_inventory('default:furnace')
1607 minetest.add_to_creative_inventory('default:sign_wall')
1608 minetest.add_to_creative_inventory('default:water_source')
1609 minetest.add_to_creative_inventory('default:lava_source')
1610 minetest.add_to_creative_inventory('default:ladder')
1613 -- Some common functions
1616 default.falling_node_names = {}
1618 function nodeupdate_single(p)
1619 n = minetest.env:get_node(p)
1620 if default.falling_node_names[n.name] ~= nil then
1621 p_bottom = {x=p.x, y=p.y-1, z=p.z}
1622 n_bottom = minetest.env:get_node(p_bottom)
1623 if n_bottom.name == "air" then
1624 minetest.env:remove_node(p)
1625 minetest.env:add_entity(p, "default:falling_"..n.name)
1631 function nodeupdate(p)
1635 p2 = {x=p.x+x, y=p.y+y, z=p.z+z}
1636 nodeupdate_single(p2)
1646 function default.register_falling_node(nodename, texture)
1647 default.falling_node_names[nodename] = true
1648 -- Override naming conventions for stuff like :default:falling_default:sand
1649 minetest.register_entity(":default:falling_"..nodename, {
1650 -- Static definition
1652 collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
1654 textures = {texture,texture,texture,texture,texture,texture},
1657 on_step = function(self, dtime)
1659 self.object:setacceleration({x=0, y=-10, z=0})
1660 -- Turn to actual sand when collides to ground or just move
1661 local pos = self.object:getpos()
1662 local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
1663 local bcn = minetest.env:get_node(bcp)
1664 if bcn.name ~= "air" then
1665 -- Turn to a sand node
1666 local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
1667 minetest.env:add_node(np, {name=nodename})
1668 self.object:remove()
1676 default.register_falling_node("default:sand", "default_sand.png")
1677 default.register_falling_node("default:gravel", "default_gravel.png")
1683 -- Global environment step function
1684 function on_step(dtime)
1687 minetest.register_globalstep(on_step)
1689 function on_placenode(p, node)
1690 --print("on_placenode")
1693 minetest.register_on_placenode(on_placenode)
1695 function on_dignode(p, node)
1696 --print("on_dignode")
1699 minetest.register_on_dignode(on_dignode)
1701 function on_punchnode(p, node)
1703 minetest.register_on_punchnode(on_punchnode)
1705 local function handle_give_command(cmd, giver, receiver, stackstring)
1706 if not minetest.get_player_privs(giver)["give"] then
1707 minetest.chat_send_player(giver, "error: you don't have permission to give")
1710 minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"')
1711 minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
1712 local itemstack = ItemStack(stackstring)
1713 if itemstack:is_empty() then
1714 minetest.chat_send_player(giver, 'error: cannot give an empty item')
1716 elseif not itemstack:is_known() then
1717 minetest.chat_send_player(giver, 'error: cannot give an unknown item')
1720 local receiverref = minetest.env:get_player_by_name(receiver)
1721 if receiverref == nil then
1722 minetest.chat_send_player(giver, receiver..' is not a known player')
1725 local leftover = receiverref:get_inventory():add_item("main", itemstack)
1726 if leftover:is_empty() then
1728 elseif leftover:get_count() == itemstack:get_count() then
1729 partiality = "could not be "
1731 partiality = "partially "
1733 -- The actual item stack string may be different from what the "giver"
1734 -- entered (e.g. big numbers are always interpreted as 2^16-1).
1735 stackstring = itemstack:to_string()
1736 if giver == receiver then
1737 minetest.chat_send_player(giver, '"'..stackstring
1738 ..'" '..partiality..'added to inventory.');
1740 minetest.chat_send_player(giver, '"'..stackstring
1741 ..'" '..partiality..'added to '..receiver..'\'s inventory.');
1742 minetest.chat_send_player(receiver, '"'..stackstring
1743 ..'" '..partiality..'added to inventory.');
1747 minetest.register_on_chat_message(function(name, message)
1748 --print("default on_chat_message: name="..dump(name).." message="..dump(message))
1749 local cmd = "/giveme"
1750 if message:sub(0, #cmd) == cmd then
1751 local stackstring = string.match(message, cmd.." (.*)")
1752 if stackstring == nil then
1753 minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
1754 return true -- Handled chat message
1756 handle_give_command(cmd, name, name, stackstring)
1760 if message:sub(0, #cmd) == cmd then
1761 local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
1762 if receiver == nil or stackstring == nil then
1763 minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
1764 return true -- Handled chat message
1766 handle_give_command(cmd, name, receiver, stackstring)
1769 local cmd = "/spawnentity"
1770 if message:sub(0, #cmd) == cmd then
1771 if not minetest.get_player_privs(name)["give"] then
1772 minetest.chat_send_player(name, "you don't have permission to spawn (give)")
1773 return true -- Handled chat message
1775 if not minetest.get_player_privs(name)["interact"] then
1776 minetest.chat_send_player(name, "you don't have permission to interact")
1777 return true -- Handled chat message
1779 local entityname = string.match(message, cmd.." (.*)")
1780 if entityname == nil then
1781 minetest.chat_send_player(name, 'usage: '..cmd..' entityname')
1782 return true -- Handled chat message
1784 print(cmd..' invoked, entityname="'..entityname..'"')
1785 local player = minetest.env:get_player_by_name(name)
1786 if player == nil then
1787 print("Unable to spawn entity, player is nil")
1788 return true -- Handled chat message
1790 local p = player:getpos()
1792 minetest.env:add_entity(p, entityname)
1793 minetest.chat_send_player(name, '"'..entityname
1795 return true -- Handled chat message
1797 local cmd = "/pulverize"
1798 if message:sub(0, #cmd) == cmd then
1799 local player = minetest.env:get_player_by_name(name)
1800 if player == nil then
1801 print("Unable to pulverize, player is nil")
1802 return true -- Handled chat message
1804 if player:get_wielded_item():is_empty() then
1805 minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
1807 player:set_wielded_item(nil)
1808 minetest.chat_send_player(name, 'An item was pulverized.')
1815 -- Done, print some random stuff
1818 --print("minetest.registered_entities:")
1819 --dump2(minetest.registered_entities)