]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
Add more information to lua_api.txt
[minetest.git] / doc / lua_api.txt
1 Minetest Lua Modding API Reference 0.4.dev
2 ==========================================
3 More information at http://c55.me/minetest/
4
5 Introduction
6 -------------
7 Content and functionality can be added to Minetest 0.4 by using Lua
8 scripting in run-time loaded mods.
9
10 A mod is a self-contained bunch of scripts, textures and other related
11 things that is loaded by and interfaces with Minetest.
12
13 Mods are contained and ran solely on the server side. Definitions and media
14 files are automatically transferred to the client.
15
16 If you see a deficiency in the API, feel free to attempt to add the
17 functionality in the engine and API. You can send such improvements as
18 source code patches to <celeron55@gmail.com>.
19
20 Programming in Lua
21 -------------------
22 If you have any difficulty in understanding this, please read:
23   http://www.lua.org/pil/
24
25 Startup
26 --------
27 Mods are loaded during server startup from the mod load paths by running
28 the init.lua scripts.
29
30 Mod load path
31 -------------
32 Generic:
33   $path_share/games/gameid/mods/
34   $path_share/mods/gameid/
35   $path_user/games/gameid/mods/
36   $path_user/mods/gameid/ <-- User-installed mods
37   $worldpath/worldmods/
38
39 In a run-in-place version (eg. the distributed windows version):
40   minetest-0.4.x/games/gameid/mods/
41   minetest-0.4.x/mods/gameid/ <-- User-installed mods
42   minetest-0.4.x/worlds/worldname/worldmods/
43
44 On an installed version on linux:
45   /usr/share/minetest/games/gameid/mods/
46   ~/.minetest/mods/gameid/ <-- User-installed mods
47   ~/.minetest/worlds/worldname/worldmods
48
49 Mod directory structure
50 ------------------------
51 mods
52 |-- modname
53 |   |-- depends.txt
54 |   |-- init.lua
55 |   |-- textures
56 |   |   |-- modname_stuff.png
57 |   |   `-- modname_something_else.png
58 |   `-- <custom data>
59 `-- another
60
61 modname:
62   The location of this directory can be fetched by using
63   minetest.get_modpath(modname)
64
65 depends.txt:
66   List of mods that have to be loaded before loading this mod.
67   A single line contains a single modname.
68
69 init.lua:
70   The main Lua script. Running this script should register everything it
71   wants to register. Subsequent execution depends on minetest calling the
72   registered callbacks.
73
74   minetest.setting_get(name) and minetest.setting_getbool(name) can be used
75   to read custom or existing settings at load time, if necessary.
76
77 textures:
78   These textures will be transferred to the client and can be referred to
79   by the mod.
80
81 Naming convention for registered textual names
82 ----------------------------------------------
83 Registered names should generally be in this format:
84   "modname:<whatever>" (<whatever> can have characters a-zA-Z0-9_)
85
86 This is to prevent conflicting names from corrupting maps and is
87 enforced by the mod loader.
88
89 Example: mod "experimental", ideal item/node/entity name "tnt":
90          -> the name should be "experimental:tnt".
91
92 Enforcement can be overridden by prefixing the name with ":". This can
93 be used for overriding the registrations of some other mod.
94
95 Example: Any mod can redefine experimental:tnt by using the name
96          ":experimental:tnt" when registering it.
97 (also that mod is required to have "experimental" as a dependency)
98
99 The ":" prefix can also be used for maintaining backwards compatibility.
100
101 Aliases
102 -------
103 Aliases can be added by using minetest.register_alias(name, convert_to)
104
105 This will make Minetest to convert things called name to things called
106 convert_to.
107
108 This can be used for maintaining backwards compatibility.
109
110 This can be also used for setting quick access names for things, eg. if
111 you have an item called epiclylongmodname:stuff, you could do
112   minetest.register_alias("stuff", "epiclylongmodname:stuff")
113 and be able to use "/giveme stuff".
114
115 Textures
116 --------
117 Mods should generally prefix their textures with modname_, eg. given
118 the mod name "foomod", a texture could be called
119   "foomod_foothing.png"
120
121 Representations of simple things
122 --------------------------------
123 MapNode representation:
124   {name="name", param1=num, param2=num}
125
126 MapNodes do not directly have any other data associated with them.
127 If you want to access the definition of the node, you access
128   minetest.registered_nodes[node.name]
129
130 param1 and param2 are 8 bit and 4 bit integers, respectively. They
131 are reserved for certain automated functions. If you don't use these
132 functions, you can use them to store arbitrary values.
133
134 param1 is reserved for the engine when:
135   paramtype != "none"
136 param2 is reserved for the engine when any of these are used:
137   liquidtype == "flowing"
138   drawtype == "flowingliquid"
139   drawtype == "torchlike"
140   drawtype == "signlike"
141
142 Position/vector:
143   {x=num, y=num, z=num}
144 Currently the API does not provide any helper functions for addition,
145 subtraction and whatever; you can define those that you need yourself.
146
147 stackstring/itemstring: A stack of items in serialized format.
148 eg. 'node "default:dirt" 5'
149 eg. 'tool "default:pick_wood" 21323'
150 eg. 'craft "default:apple" 2'
151
152 item: A stack of items in Lua table format.
153 eg. {name="default:dirt", count=1, wear=0, metadata=""} 
154     ^ a single dirt node
155 eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
156     ^ a wooden pick about 1/3 weared out
157 eg. {name="default:apple", count=1, wear=0, metadata=""}
158     ^ an apple.
159
160 Any time an item must be passed to a function, it can be an
161 ItemStack (see below), an itemstring or a table in the above format.
162
163 Items
164 ------
165 Node (register_node):
166   A node from the world
167 Tool (register_tool):
168   A tool/weapon that can dig and damage things according to tool_capabilities
169 Craftitem (register_craftitem):
170   A miscellaneous item
171
172 Groups
173 -------
174 In a number of places, there is a group table. Groups define the
175 properties of a thing (item, node, armor of entity, capabilities of
176 tool) in such a way that the engine and other mods can can interact with
177 the thing without actually knowing what the thing is.
178
179 Usage:
180 - Groups are stored in a table, having the group names with keys and the
181   group ratings as values. For example:
182     groups = {crumbly=3, soil=1}
183     ^ Default dirt (soil group actually currently not defined; TODO)
184     groups = {crumbly=2, soil=1, level=2, outerspace=1}
185     ^ A more special dirt-kind of thing
186 - Groups always have a rating associated with them. If there is no
187   useful meaning for a rating for an enabled group, it shall be 1.
188 - When not defined, the rating of a group defaults to 0. Thus when you
189   read groups, you must interpret nil and 0 as the same value, 0.
190
191 Groups of items
192 ----------------
193 Groups of items can define what kind of an item it is (eg. wool).
194
195 Groups of nodes
196 ----------------
197 In addition to the general item things, whether a node is diggable and how
198 long it takes is defined by using groups.
199
200 Groups of entities
201 -------------------
202 For entities, groups are, as of now, used only for calculating damage.
203
204 object.get_armor_groups() -> a group-rating table (eg. {fleshy=3})
205 object.set_armor_groups({level=2, fleshy=2, cracky=2})
206
207 Groups of tools
208 ----------------
209 Groups in tools define which groups of nodes and entities they are
210 effective towards.
211
212 Groups in crafting recipes
213 ---------------------------
214 - Not implemented yet. (TODO)
215 - Will probably look like this:
216 {
217     output = 'food:meat_soup_raw',
218     recipe = {
219         {'group:meat'},
220         {'group:water'},
221         {'group:bowl'},
222     },
223         preserve = {'group:bowl'},
224 }
225
226 Special groups
227 ---------------
228 - immortal: Disables the group damage system for an entity
229 - level: Can be used to give an additional sense of progression in the game.
230   - A larger level will cause eg. a weapon of a lower level make much less
231     damage, and get weared out much faster, or not be able to get drops
232         from destroyed nodes.
233   - 0 is something that is directly accessible at the start of gameplay
234 - dig_immediate: (player can always pick up node without tool wear)
235   - 2: node is removed without tool wear after 0.5 seconds or so
236        (rail, sign)
237   - 3: node is removed without tool wear immediately (torch)
238
239 Known damage and digging time defining groups
240 ----------------------------------------------
241 - crumbly: dirt, sand
242 - cracky: tough but crackable stuff like stone.
243 - snappy: something that can be cut using fine tools; eg. leaves, small
244           plants, wire, sheets of metal
245 - choppy: something that can be cut using force; eg. trees, wooden planks
246 - fleshy: Living things like animals and the player. This could imply
247           some blood effects when hitting.
248 - explody: Especially prone to explosions
249 - oddly_breakable_by_hand:
250    Can be added to nodes that shouldn't logically be breakable by the
251    hand but are. Somewhat similar to dig_immediate, but times are more
252    like {[1]=3.50,[2]=2.00,[3]=0.70} and this does not override the
253    speed of a tool if the tool can dig at a larger speed than this
254    suggests for the hand.
255
256 Examples of custom groups
257 --------------------------
258 Item groups are often used for defining, well, //groups of items//.
259 - meat: any meat-kind of a thing (rating might define the size or healing
260   ability or be irrelevant - it is not defined as of yet)
261 - eatable: anything that can be eaten. Rating might define HP gain in half
262   hearts.
263 - flammable: can be set on fire. Rating might define the intensity of the
264   fire, affecting eg. the speed of the spreading of an open fire.
265 - wool: any wool (any origin, any color)
266 - metal: any metal
267 - weapon: any weapon
268 - heavy: anything considerably heavy
269
270 Digging time calculation specifics
271 -----------------------------------
272 Groups such as **crumbly**, **cracky** and **snappy** are used for this
273 purpose. Rating is 1, 2 or 3. A higher rating for such a group implies
274 faster digging time.
275
276 Also, the **level** group is used.
277
278 Tools define their properties by a list of parameters for groups. They
279 cannot dig other groups; thus it is important to use a standard bunch of
280 groups to enable interaction with tools.
281
282 **Example definition of the digging capabilities of a tool:**
283 tool_capabilities = {
284         full_punch_interval=1.5,
285         max_drop_level=1,
286         groupcaps={
287                 crumbly={maxwear=0.01, maxlevel=2, times={[1]=0.80, [2]=0.60, [3]=0.40}}
288         }
289 }
290
291 **Tools define:**
292   * Full punch interval Maximum drop level For an arbitrary list of groups:
293   * Maximum level (usually 0, 1, 2 or 3) Maximum wear (0...1) Digging times
294
295 **Full punch interval**: When used as a weapon, the tool will do full
296 damage if this time is spent between punches. If eg. half the time is
297 spent, the tool will do half damage.
298
299 **Maximum drop level** suggests the maximum level of node, when dug with
300 the tool, that will drop it's useful item. (eg. iron ore to drop a lump of
301 iron).
302
303 **Maximum level** tells what is the maximum level of a node of this group
304 that the tool will be able to dig.
305
306 **Maximum wear** determines how much the tool wears out when it is used for
307 digging a node, of this group, of the maximum level. For lower leveled
308 tools, the wear is divided by //4// to the exponent //level difference//.
309 This means for a maximum wear of 0.1, a level difference 1 will result in
310 wear=0.1/4=0.025, and a level difference of 2 will result in
311 wear=0.1/(4*4)=0.00625.
312
313 **Digging times** is basically a list of digging times for different
314 ratings of the group. It also determines the damage done to entities, based
315 on their "armor groups".
316   * For example, as a lua table, ''times={2=2.00, 3=0.70}''. This would
317   * result the tool to be able to dig nodes that have a rating of 2 or 3
318   * for this group, and unable to dig the rating 1, which is the toughest.
319   * Unless there is a matching group that enables digging otherwise.  For
320   * entities, damage equals the amount of nodes dug in the time spent
321   * between hits, with a maximum of ''full_punch_interval''.
322
323 Entity damage mechanism
324 ------------------------
325 Client predicts damage based on damage groups. Because of this, it is able to
326 give an immediate response when an entity is damaged or dies; the response is
327 pre-defined somehow (eg. by defining a sprite animation) (not implemented;
328 TODO).
329
330 The group **immortal** will completely disable normal damage.
331
332 Entities can define a special armor group, which is **punch_operable**. This
333 group will disable the regular damage mechanism for players punching it by hand
334 or a non-tool item.
335
336 On the Lua side, every punch calls ''entity:on_punch(puncher,
337 time_from_last_punch, tool_capabilities, direction)''. This should never be
338 called directly, because damage is usually not handled by the entity itself.
339   * ''puncher'' is the object performing the punch. Can be nil. Should never be
340     accessed unless absolutely required.
341   * ''time_from_last_punch'' is time from last punch (by puncher) or nil.
342   * ''tool_capabilities'' can be nil.
343   * ''direction'' is a unit vector, pointing from the source of the punch to
344     the punched object.
345
346 To punch an entity/object in Lua, call ''object:punch(puncher, time_from_last_punch, tool_capabilities, direction)''.
347   * Return value is tool wear.
348   * Parameters are equal to the above callback.
349   * If ''direction'' is nil and ''puncher'' is not nil, ''direction'' will be
350     automatically filled in based on the location of ''puncher''.
351
352 Helper functions
353 -----------------
354 dump2(obj, name="_", dumped={})
355 ^ Return object serialized as a string, handles reference loops
356 dump(obj, dumped={})
357 ^ Return object serialized as a string
358
359 minetest namespace reference
360 -----------------------------
361 minetest.register_entity(name, prototype table)
362 minetest.register_abm(abm definition)
363 minetest.register_node(name, node definition)
364 minetest.register_tool(name, item definition)
365 minetest.register_craftitem(name, item definition)
366 minetest.register_alias(name, convert_to)
367 minetest.register_craft(recipe)
368 minetest.register_globalstep(func(dtime))
369 minetest.register_on_placenode(func(pos, newnode, placer))
370 minetest.register_on_dignode(func(pos, oldnode, digger))
371 minetest.register_on_punchnode(func(pos, node, puncher))
372 minetest.register_on_generated(func(minp, maxp))
373 minetest.register_on_newplayer(func(ObjectRef))
374 minetest.register_on_dieplayer(func(ObjectRef))
375 minetest.register_on_respawnplayer(func(ObjectRef))
376 ^ return true in func to disable regular player placement
377 ^ currently called _before_ repositioning of player occurs
378 minetest.register_on_chat_message(func(name, message))
379 minetest.add_to_creative_inventory(itemstring)
380 minetest.setting_get(name) -> string or nil
381 minetest.setting_getbool(name) -> boolean value or nil
382 minetest.chat_send_all(text)
383 minetest.chat_send_player(name, text)
384 minetest.get_player_privs(name) -> set of privs
385 minetest.get_inventory(location) -> InvRef
386 ^ location = eg. {type="player", name="celeron55"}
387                  {type="node", pos={x=, y=, z=}}
388 minetest.get_current_modname() -> string
389 minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
390 ^ Useful for loading additional .lua modules or static data from mod
391 minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
392 ^ Useful for storing custom data
393
394 minetest.debug(line)
395 ^ Goes to dstream
396 minetest.log(line)
397 minetest.log(loglevel, line)
398 ^ loglevel one of "error", "action", "info", "verbose"
399
400 Global objects:
401 minetest.env - environment reference
402
403 Global tables:
404 minetest.registered_items
405 ^ List of registered items, indexed by name
406 minetest.registered_nodes
407 ^ List of registered node definitions, indexed by name
408 minetest.registered_craftitems
409 ^ List of registered craft item definitions, indexed by name
410 minetest.registered_tools
411 ^ List of registered tool definitions, indexed by name
412 minetest.registered_entities
413 ^ List of registered entity prototypes, indexed by name
414 minetest.object_refs
415 ^ List of object references, indexed by active object id
416 minetest.luaentities
417 ^ List of lua entities, indexed by active object id
418
419 Deprecated but defined for backwards compatibility:
420 minetest.digprop_constanttime(time)
421 minetest.digprop_stonelike(toughness)
422 minetest.digprop_dirtlike(toughness)
423 minetest.digprop_gravellike(toughness)
424 minetest.digprop_woodlike(toughness)
425 minetest.digprop_leaveslike(toughness)
426 minetest.digprop_glasslike(toughness)
427
428 Class reference
429 ----------------
430 EnvRef: basically ServerEnvironment and ServerMap combined.
431 methods:
432 - add_node(pos, node)
433 - remove_node(pos)
434 - get_node(pos)
435   ^ Returns {name="ignore", ...} for unloaded area
436 - get_node_or_nil(pos)
437   ^ Returns nil for unloaded area
438 - get_node_light(pos, timeofday) -> 0...15 or nil
439   ^ timeofday: nil = current time, 0 = night, 0.5 = day
440 - add_entity(pos, name): Returns ObjectRef or nil if failed
441 - add_item(pos, itemstring)
442 - add_rat(pos)
443 - add_firefly(pos)
444 - get_meta(pos) -- Get a NodeMetaRef at that position
445 - get_player_by_name(name) -- Get an ObjectRef to a player
446 - get_objects_inside_radius(pos, radius)
447 - set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
448 - get_timeofday()
449
450 NodeMetaRef (this stuff is subject to change in a future version)
451 methods:
452 - get_type()
453 - allows_text_input()
454 - set_text(text) -- eg. set the text of a sign
455 - get_text()
456 - get_owner()
457 - set_owner(string)
458 Generic node metadata specific:
459 - set_infotext(infotext)
460 - get_inventory() -> InvRef
461 - set_inventory_draw_spec(string)
462 - set_allow_text_input(bool)
463 - set_allow_removal(bool)
464 - set_enforce_owner(bool)
465 - is_inventory_modified()
466 - reset_inventory_modified()
467 - is_text_modified()
468 - reset_text_modified()
469 - set_string(name, value)
470 - get_string(name)
471
472 ObjectRef: Moving things in the game are generally these
473 (basically reference to a C++ ServerActiveObject)
474 methods:
475 - remove(): remove object (after returning from Lua)
476 - getpos() -> {x=num, y=num, z=num}
477 - setpos(pos); pos={x=num, y=num, z=num}
478 - moveto(pos, continuous=false): interpolated move
479 - punch(puncher, time_from_last_punch, tool_capabilities, direction)
480   ^ puncher = an another ObjectRef,
481   ^ time_from_last_punch = time since last punch action of the puncher
482 - right_click(clicker); clicker = an another ObjectRef
483 - get_hp(): returns number of hitpoints (2 * number of hearts)
484 - set_hp(hp): set number of hitpoints (2 * number of hearts)
485 - get_inventory() -> InvRef
486 - get_wield_list(): returns the name of the inventory list the wielded item is in
487 - get_wield_index(): returns the index of the wielded item
488 - get_wielded_item() -> ItemStack
489 - set_wielded_item(item): replaces the wielded item, returns true if successful
490 LuaEntitySAO-only: (no-op for other objects)
491 - setvelocity({x=num, y=num, z=num})
492 - getvelocity() -> {x=num, y=num, z=num}
493 - setacceleration({x=num, y=num, z=num})
494 - getacceleration() -> {x=num, y=num, z=num}
495 - setyaw(radians)
496 - getyaw() -> radians
497 - settexturemod(mod)
498 - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
499 -           select_horiz_by_yawpitch=false)
500 - ^ Select sprite from spritesheet with optional animation and DM-style
501 -   texture selection based on yaw relative to camera
502 - set_armor_groups({group1=rating, group2=rating, ...})
503 - get_entity_name() (DEPRECATED: Will be removed in a future version)
504 - get_luaentity()
505 Player-only: (no-op for other objects)
506 - get_player_name(): will return nil if is not a player
507 - get_look_dir(): get camera direction as a unit vector
508 - get_look_pitch(): pitch in radians
509 - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
510
511 InvRef: Reference to an inventory
512 methods:
513 - get_size(listname): get size of a list
514 - set_size(listname, size): set size of a list
515 - get_stack(listname, i): get a copy of stack index i in list
516 - set_stack(listname, i, stack): copy stack to index i in list
517 - get_list(listname): return full list
518 - set_list(listname, list): set full list (size will not change)
519 - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
520 - room_for_item(listname, stack): returns true if the stack of items
521     can be fully added to the list
522 - contains_item(listname, stack): returns true if the stack of items
523     can be fully taken from the list
524   remove_item(listname, stack): take as many items as specified from the list,
525     returns the items that were actually removed (as an ItemStack)
526
527 ItemStack: A stack of items.
528 methods:
529 - is_empty(): return true if stack is empty
530 - get_name(): returns item name (e.g. "default:stone")
531 - get_count(): returns number of items on the stack
532 - get_wear(): returns tool wear (0-65535), 0 for non-tools
533 - get_metadata(): returns metadata (a string attached to an item stack)
534 - clear(): removes all items from the stack, making it empty
535 - replace(item): replace the contents of this stack (item can also
536     be an itemstring or table)
537 - to_string(): returns the stack in itemstring form
538 - to_table(): returns the stack in Lua table form
539 - get_stack_max(): returns the maximum size of the stack (depends on the item)
540 - get_free_space(): returns get_stack_max() - get_count()
541 - is_known(): returns true if the item name refers to a defined item type
542 - get_definition(): returns the item definition table
543 - get_tool_capabilities(): returns the digging properties of the item,
544   ^ or those of the hand if none are defined for this item type
545 - add_wear(amount): increases wear by amount if the item is a tool
546 - add_item(item): put some item or stack onto this stack,
547   ^ returns leftover ItemStack
548 - item_fits(item): returns true if item or stack can be fully added to this one
549 - take_item(n): take (and remove) up to n items from this stack
550   ^ returns taken ItemStack
551   ^ if n is omitted, n=1 is used
552 - peek_item(n): copy (don't remove) up to n items from this stack
553   ^ returns copied ItemStack
554   ^ if n is omitted, n=1 is used
555
556 Registered entities
557 --------------------
558 - Functions receive a "luaentity" as self:
559   - It has the member .name, which is the registered name ("mod:thing")
560   - It has the member .object, which is an ObjectRef pointing to the object
561   - The original prototype stuff is visible directly via a metatable
562 - Callbacks:
563   - on_activate(self, staticdata)
564     ^ Called when the object is instantiated.
565   - on_step(self, dtime)
566     ^ Called on every server tick (dtime is usually 0.05 seconds)
567   - on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
568     ^ Called when somebody punches the object.
569     ^ Note that you probably want to handle most punches using the
570       automatic armor group system.
571     ^ puncher: ObjectRef (can be nil)
572     ^ time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
573     ^ tool_capabilities: capability table of used tool (can be nil)
574         ^ dir: unit vector of direction of punch. Always defined. Points from
575                the puncher to the punched.
576   - on_rightclick(self, clicker)
577   - get_staticdata(self)
578     ^ Should return a string that will be passed to on_activate when
579       the object is instantiated the next time.
580
581 Definition tables
582 ------------------
583
584 Entity definition (register_entity)
585 {
586     physical = true,
587     collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
588     visual = "cube"/"sprite",
589     visual_size = {x=1, y=1},
590     textures = {texture,texture,texture,texture,texture,texture},
591     spritediv = {x=1, y=1},
592     initial_sprite_basepos = {x=0, y=0},
593     on_activate = function(self, staticdata),
594     on_step = function(self, dtime),
595     on_punch = function(self, hitter),
596     on_rightclick = function(self, clicker),
597     get_staticdata = function(self),
598     # Also you can define arbitrary member variables here
599     myvariable = whatever,
600 }
601
602 ABM (ActiveBlockModifier) definition (register_abm)
603 {
604     nodenames = {"default:lava_source"},
605     neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
606      ^ If left out or empty, any neighbor will do
607     interval = 1.0, -- (operation interval)
608     chance = 1, -- (chance of trigger is 1.0/this)
609     action = func(pos, node, active_object_count, active_object_count_wider),
610 }
611
612 Item definition (register_node, register_craftitem, register_tool)
613 {
614     description = "Steel Axe",
615     groups = {}, -- key=name, value=rating; rating=1..3.
616                     if rating not applicable, use 1.
617                     eg. {wool=1, fluffy=3}
618                         {soil=2, outerspace=1, crumbly=1}
619                         {bendy=2, snappy=1},
620                         {hard=1, metal=1, spikes=1}
621     inventory_image = "default_tool_steelaxe.png",
622     wield_image = "",
623     wield_scale = {x=1,y=1,z=1},
624     stack_max = 99,
625     liquids_pointable = false,
626     tool_capabilities = {
627         full_punch_interval = 1.0,
628         max_drop_level=0,
629         groupcaps={
630             -- For example:
631             fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
632             snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
633             choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
634         }
635     }
636     on_drop = func(item, dropper, pos),
637     on_place = func(item, placer, pointed_thing),
638     on_use = func(item, user, pointed_thing),
639 }
640
641 Node definition (register_node)
642 {
643     <all fields allowed in item definitions>,
644
645     drawtype = "normal",
646     visual_scale = 1.0,
647     tile_images = {"default_unknown_block.png"},
648     special_materials = {
649         {image="", backface_culling=true},
650         {image="", backface_culling=true},
651     },
652     alpha = 255,
653     post_effect_color = {a=0, r=0, g=0, b=0},
654     paramtype = "none",
655     paramtype2 = "none",
656     is_ground_content = false,
657     sunlight_propagates = false,
658     walkable = true,
659     pointable = true,
660     diggable = true,
661     climbable = false,
662     buildable_to = false,
663     drop = "",
664     -- alternatively drop = { max_items = ..., items = { ... } }
665     metadata_name = "",
666     liquidtype = "none",
667     liquid_alternative_flowing = "",
668     liquid_alternative_source = "",
669     liquid_viscosity = 0,
670     light_source = 0,
671     damage_per_second = 0,
672     selection_box = {type="regular"},
673     legacy_facedir_simple = false, -- Support maps made in and before January 2012
674     legacy_wallmounted = false, -- Support maps made in and before January 2012
675 }
676
677 Recipe: (register_craft)
678 {
679     output = 'default:pick_stone',
680     recipe = {
681         {'default:cobble', 'default:cobble', 'default:cobble'},
682         {'', 'default:stick', ''},
683         {'', 'default:stick', ''},
684     },
685     replacements = <optional list of item pairs,
686                     replace one input item with another item on crafting>
687 }
688
689 Recipe (shapeless):
690 {
691     type = "shapeless",
692     output = 'mushrooms:mushroom_stew',
693     recipe = {
694         "mushrooms:bowl",
695         "mushrooms:mushroom_brown",
696         "mushrooms:mushroom_red",
697     },
698     replacements = <optional list of item pairs,
699                     replace one input item with another item on crafting>
700 }
701
702 Recipe (tool repair):
703 {
704     type = "toolrepair",
705     additional_wear = -0.02,
706 }
707
708 Recipe (cooking):
709 {
710     type = "cooking",
711     output = "default:glass",
712     recipe = "default:sand",
713     cooktime = 3,
714 }
715
716 Recipe (furnace fuel):
717 {
718     type = "fuel",
719     recipe = "default:leaves",
720     burntime = 1,
721 }
722
723