]> git.lizzy.rs Git - minetest.git/blob - doc/lua_api.txt
Lua API for playing sounds
[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 Sounds
367 -------
368 Examples of sound parameter tables:
369 -- Play locationless on all clients
370 {
371         gain = 1.0, -- default
372 }
373 -- Play locationless to a player
374 {
375         to_player = name,
376         gain = 1.0, -- default
377 }
378 -- Play in a location
379 {
380         pos = {x=1,y=2,z=3},
381         gain = 1.0, -- default
382         max_hear_distance = 32, -- default
383 }
384 -- Play connected to an object, looped
385 {
386     object = <an ObjectRef>,
387         gain = 1.0, -- default
388         max_hear_distance = 32, -- default
389     loop = true, -- only sounds connected to objects can be looped
390 }
391
392 minetest namespace reference
393 -----------------------------
394 minetest.get_current_modname() -> string
395 minetest.get_modpath(modname) -> eg. "/home/user/.minetest/usermods/modname"
396 ^ Useful for loading additional .lua modules or static data from mod
397 minetest.get_worldpath(modname) -> eg. "/home/user/.minetest/world"
398 ^ Useful for storing custom data
399
400 minetest.register_entity(name, prototype table)
401 minetest.register_abm(abm definition)
402 minetest.register_node(name, node definition)
403 minetest.register_tool(name, item definition)
404 minetest.register_craftitem(name, item definition)
405 minetest.register_alias(name, convert_to)
406 minetest.register_craft(recipe)
407
408 minetest.register_globalstep(func(dtime))
409 minetest.register_on_placenode(func(pos, newnode, placer))
410 minetest.register_on_dignode(func(pos, oldnode, digger))
411 minetest.register_on_punchnode(func(pos, node, puncher))
412 minetest.register_on_generated(func(minp, maxp))
413 minetest.register_on_newplayer(func(ObjectRef))
414 minetest.register_on_dieplayer(func(ObjectRef))
415 minetest.register_on_respawnplayer(func(ObjectRef))
416 ^ return true in func to disable regular player placement
417 ^ currently called _before_ repositioning of player occurs
418 minetest.register_on_chat_message(func(name, message))
419
420 minetest.add_to_creative_inventory(itemstring)
421 minetest.setting_get(name) -> string or nil
422 minetest.setting_getbool(name) -> boolean value or nil
423
424 minetest.chat_send_all(text)
425 minetest.chat_send_player(name, text)
426 minetest.get_player_privs(name) -> set of privs
427 minetest.get_inventory(location) -> InvRef
428 ^ location = eg. {type="player", name="celeron55"}
429                  {type="node", pos={x=, y=, z=}}
430
431 minetest.sound_play(spec, parameters) -> handle
432 ^ spec = SimpleSoundSpec
433 ^ parameters = sound parameter table
434 minetest.sound_stop(handle)
435
436 minetest.debug(line)
437 ^ Goes to dstream
438 minetest.log(line)
439 minetest.log(loglevel, line)
440 ^ loglevel one of "error", "action", "info", "verbose"
441
442 Global objects:
443 minetest.env - environment reference
444
445 Global tables:
446 minetest.registered_items
447 ^ List of registered items, indexed by name
448 minetest.registered_nodes
449 ^ List of registered node definitions, indexed by name
450 minetest.registered_craftitems
451 ^ List of registered craft item definitions, indexed by name
452 minetest.registered_tools
453 ^ List of registered tool definitions, indexed by name
454 minetest.registered_entities
455 ^ List of registered entity prototypes, indexed by name
456 minetest.object_refs
457 ^ List of object references, indexed by active object id
458 minetest.luaentities
459 ^ List of lua entities, indexed by active object id
460
461 Deprecated but defined for backwards compatibility:
462 minetest.digprop_constanttime(time)
463 minetest.digprop_stonelike(toughness)
464 minetest.digprop_dirtlike(toughness)
465 minetest.digprop_gravellike(toughness)
466 minetest.digprop_woodlike(toughness)
467 minetest.digprop_leaveslike(toughness)
468 minetest.digprop_glasslike(toughness)
469
470 Class reference
471 ----------------
472 EnvRef: basically ServerEnvironment and ServerMap combined.
473 methods:
474 - add_node(pos, node)
475 - remove_node(pos)
476 - get_node(pos)
477   ^ Returns {name="ignore", ...} for unloaded area
478 - get_node_or_nil(pos)
479   ^ Returns nil for unloaded area
480 - get_node_light(pos, timeofday) -> 0...15 or nil
481   ^ timeofday: nil = current time, 0 = night, 0.5 = day
482 - add_entity(pos, name): Returns ObjectRef or nil if failed
483 - add_item(pos, itemstring)
484 - add_rat(pos)
485 - add_firefly(pos)
486 - get_meta(pos) -- Get a NodeMetaRef at that position
487 - get_player_by_name(name) -- Get an ObjectRef to a player
488 - get_objects_inside_radius(pos, radius)
489 - set_timeofday(val): val: 0...1; 0 = midnight, 0.5 = midday
490 - get_timeofday()
491
492 NodeMetaRef (this stuff is subject to change in a future version)
493 methods:
494 - get_type()
495 - allows_text_input()
496 - set_text(text) -- eg. set the text of a sign
497 - get_text()
498 - get_owner()
499 - set_owner(string)
500 Generic node metadata specific:
501 - set_infotext(infotext)
502 - get_inventory() -> InvRef
503 - set_inventory_draw_spec(string)
504 - set_allow_text_input(bool)
505 - set_allow_removal(bool)
506 - set_enforce_owner(bool)
507 - is_inventory_modified()
508 - reset_inventory_modified()
509 - is_text_modified()
510 - reset_text_modified()
511 - set_string(name, value)
512 - get_string(name)
513
514 ObjectRef: Moving things in the game are generally these
515 (basically reference to a C++ ServerActiveObject)
516 methods:
517 - remove(): remove object (after returning from Lua)
518 - getpos() -> {x=num, y=num, z=num}
519 - setpos(pos); pos={x=num, y=num, z=num}
520 - moveto(pos, continuous=false): interpolated move
521 - punch(puncher, time_from_last_punch, tool_capabilities, direction)
522   ^ puncher = an another ObjectRef,
523   ^ time_from_last_punch = time since last punch action of the puncher
524 - right_click(clicker); clicker = an another ObjectRef
525 - get_hp(): returns number of hitpoints (2 * number of hearts)
526 - set_hp(hp): set number of hitpoints (2 * number of hearts)
527 - get_inventory() -> InvRef
528 - get_wield_list(): returns the name of the inventory list the wielded item is in
529 - get_wield_index(): returns the index of the wielded item
530 - get_wielded_item() -> ItemStack
531 - set_wielded_item(item): replaces the wielded item, returns true if successful
532 LuaEntitySAO-only: (no-op for other objects)
533 - setvelocity({x=num, y=num, z=num})
534 - getvelocity() -> {x=num, y=num, z=num}
535 - setacceleration({x=num, y=num, z=num})
536 - getacceleration() -> {x=num, y=num, z=num}
537 - setyaw(radians)
538 - getyaw() -> radians
539 - settexturemod(mod)
540 - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2,
541 -           select_horiz_by_yawpitch=false)
542 - ^ Select sprite from spritesheet with optional animation and DM-style
543 -   texture selection based on yaw relative to camera
544 - set_armor_groups({group1=rating, group2=rating, ...})
545 - get_entity_name() (DEPRECATED: Will be removed in a future version)
546 - get_luaentity()
547 Player-only: (no-op for other objects)
548 - get_player_name(): will return nil if is not a player
549 - get_look_dir(): get camera direction as a unit vector
550 - get_look_pitch(): pitch in radians
551 - get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
552
553 InvRef: Reference to an inventory
554 methods:
555 - get_size(listname): get size of a list
556 - set_size(listname, size): set size of a list
557 - get_stack(listname, i): get a copy of stack index i in list
558 - set_stack(listname, i, stack): copy stack to index i in list
559 - get_list(listname): return full list
560 - set_list(listname, list): set full list (size will not change)
561 - add_item(listname, stack): add item somewhere in list, returns leftover ItemStack
562 - room_for_item(listname, stack): returns true if the stack of items
563     can be fully added to the list
564 - contains_item(listname, stack): returns true if the stack of items
565     can be fully taken from the list
566   remove_item(listname, stack): take as many items as specified from the list,
567     returns the items that were actually removed (as an ItemStack)
568
569 ItemStack: A stack of items.
570 methods:
571 - is_empty(): return true if stack is empty
572 - get_name(): returns item name (e.g. "default:stone")
573 - get_count(): returns number of items on the stack
574 - get_wear(): returns tool wear (0-65535), 0 for non-tools
575 - get_metadata(): returns metadata (a string attached to an item stack)
576 - clear(): removes all items from the stack, making it empty
577 - replace(item): replace the contents of this stack (item can also
578     be an itemstring or table)
579 - to_string(): returns the stack in itemstring form
580 - to_table(): returns the stack in Lua table form
581 - get_stack_max(): returns the maximum size of the stack (depends on the item)
582 - get_free_space(): returns get_stack_max() - get_count()
583 - is_known(): returns true if the item name refers to a defined item type
584 - get_definition(): returns the item definition table
585 - get_tool_capabilities(): returns the digging properties of the item,
586   ^ or those of the hand if none are defined for this item type
587 - add_wear(amount): increases wear by amount if the item is a tool
588 - add_item(item): put some item or stack onto this stack,
589   ^ returns leftover ItemStack
590 - item_fits(item): returns true if item or stack can be fully added to this one
591 - take_item(n): take (and remove) up to n items from this stack
592   ^ returns taken ItemStack
593   ^ if n is omitted, n=1 is used
594 - peek_item(n): copy (don't remove) up to n items from this stack
595   ^ returns copied ItemStack
596   ^ if n is omitted, n=1 is used
597
598 Registered entities
599 --------------------
600 - Functions receive a "luaentity" as self:
601   - It has the member .name, which is the registered name ("mod:thing")
602   - It has the member .object, which is an ObjectRef pointing to the object
603   - The original prototype stuff is visible directly via a metatable
604 - Callbacks:
605   - on_activate(self, staticdata)
606     ^ Called when the object is instantiated.
607   - on_step(self, dtime)
608     ^ Called on every server tick (dtime is usually 0.05 seconds)
609   - on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
610     ^ Called when somebody punches the object.
611     ^ Note that you probably want to handle most punches using the
612       automatic armor group system.
613     ^ puncher: ObjectRef (can be nil)
614     ^ time_from_last_punch: Meant for disallowing spamming of clicks (can be nil)
615     ^ tool_capabilities: capability table of used tool (can be nil)
616         ^ dir: unit vector of direction of punch. Always defined. Points from
617                the puncher to the punched.
618   - on_rightclick(self, clicker)
619   - get_staticdata(self)
620     ^ Should return a string that will be passed to on_activate when
621       the object is instantiated the next time.
622
623 Definition tables
624 ------------------
625
626 Entity definition (register_entity)
627 {
628     physical = true,
629     collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
630     visual = "cube"/"sprite",
631     visual_size = {x=1, y=1},
632     textures = {texture,texture,texture,texture,texture,texture},
633     spritediv = {x=1, y=1},
634     initial_sprite_basepos = {x=0, y=0},
635     on_activate = function(self, staticdata),
636     on_step = function(self, dtime),
637     on_punch = function(self, hitter),
638     on_rightclick = function(self, clicker),
639     get_staticdata = function(self),
640     # Also you can define arbitrary member variables here
641     myvariable = whatever,
642 }
643
644 ABM (ActiveBlockModifier) definition (register_abm)
645 {
646     nodenames = {"default:lava_source"},
647     neighbors = {"default:water_source", "default:water_flowing"}, -- (any of these)
648      ^ If left out or empty, any neighbor will do
649     interval = 1.0, -- (operation interval)
650     chance = 1, -- (chance of trigger is 1.0/this)
651     action = func(pos, node, active_object_count, active_object_count_wider),
652 }
653
654 Item definition (register_node, register_craftitem, register_tool)
655 {
656     description = "Steel Axe",
657     groups = {}, -- key=name, value=rating; rating=1..3.
658                     if rating not applicable, use 1.
659                     eg. {wool=1, fluffy=3}
660                         {soil=2, outerspace=1, crumbly=1}
661                         {bendy=2, snappy=1},
662                         {hard=1, metal=1, spikes=1}
663     inventory_image = "default_tool_steelaxe.png",
664     wield_image = "",
665     wield_scale = {x=1,y=1,z=1},
666     stack_max = 99,
667     liquids_pointable = false,
668     tool_capabilities = {
669         full_punch_interval = 1.0,
670         max_drop_level=0,
671         groupcaps={
672             -- For example:
673             fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
674             snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1},
675             choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
676         }
677     }
678     on_drop = func(item, dropper, pos),
679     on_place = func(item, placer, pointed_thing),
680     on_use = func(item, user, pointed_thing),
681 }
682
683 Node definition (register_node)
684 {
685     <all fields allowed in item definitions>,
686
687     drawtype = "normal",
688     visual_scale = 1.0,
689     tile_images = {"default_unknown_block.png"},
690     special_materials = {
691         {image="", backface_culling=true},
692         {image="", backface_culling=true},
693     },
694     alpha = 255,
695     post_effect_color = {a=0, r=0, g=0, b=0},
696     paramtype = "none",
697     paramtype2 = "none",
698     is_ground_content = false,
699     sunlight_propagates = false,
700     walkable = true,
701     pointable = true,
702     diggable = true,
703     climbable = false,
704     buildable_to = false,
705     drop = "",
706     -- alternatively drop = { max_items = ..., items = { ... } }
707     metadata_name = "",
708     liquidtype = "none",
709     liquid_alternative_flowing = "",
710     liquid_alternative_source = "",
711     liquid_viscosity = 0,
712     light_source = 0,
713     damage_per_second = 0,
714     selection_box = {type="regular"},
715     legacy_facedir_simple = false, -- Support maps made in and before January 2012
716     legacy_wallmounted = false, -- Support maps made in and before January 2012
717     sounds = {
718         footstep = <SimpleSoundSpec>,
719         dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
720         dug = <SimpleSoundSpec>,
721     },
722 }
723
724 Recipe: (register_craft)
725 {
726     output = 'default:pick_stone',
727     recipe = {
728         {'default:cobble', 'default:cobble', 'default:cobble'},
729         {'', 'default:stick', ''},
730         {'', 'default:stick', ''},
731     },
732     replacements = <optional list of item pairs,
733                     replace one input item with another item on crafting>
734 }
735
736 Recipe (shapeless):
737 {
738     type = "shapeless",
739     output = 'mushrooms:mushroom_stew',
740     recipe = {
741         "mushrooms:bowl",
742         "mushrooms:mushroom_brown",
743         "mushrooms:mushroom_red",
744     },
745     replacements = <optional list of item pairs,
746                     replace one input item with another item on crafting>
747 }
748
749 Recipe (tool repair):
750 {
751     type = "toolrepair",
752     additional_wear = -0.02,
753 }
754
755 Recipe (cooking):
756 {
757     type = "cooking",
758     output = "default:glass",
759     recipe = "default:sand",
760     cooktime = 3,
761 }
762
763 Recipe (furnace fuel):
764 {
765     type = "fuel",
766     recipe = "default:leaves",
767     burntime = 1,
768 }
769
770