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