Bones: Iterate player inventory lists dynamically (#1229)
[oweals/minetest_game.git] / game_api.txt
1 Minetest Game API
2 =================
3 GitHub Repo: https://github.com/minetest/minetest_game
4
5 Introduction
6 ------------
7
8 The Minetest Game subgame offers multiple new possibilities in addition to the Minetest engine's built-in API,
9 allowing you to add new plants to farming mod, buckets for new liquids, new stairs and custom panes.
10 For information on the Minetest API, visit https://github.com/minetest/minetest/blob/master/doc/lua_api.txt
11 Please note:
12
13  * [XYZ] refers to a section the Minetest API
14  * [#ABC] refers to a section in this document
15  * [pos] refers to a position table `{x = -5, y = 0, z = 200}`
16
17 Bucket API
18 ----------
19
20 The bucket API allows registering new types of buckets for non-default liquids.
21
22         bucket.register_liquid(
23                 "default:lava_source",   -- name of the source node
24                 "default:lava_flowing",  -- name of the flowing node
25                 "bucket:bucket_lava",    -- name of the new bucket item (or nil if liquid is not takeable)
26                 "bucket_lava.png",       -- texture of the new bucket item (ignored if itemname == nil)
27                 "Lava Bucket",           -- text description of the bucket item
28                 {lava_bucket = 1},       -- groups of the bucket item, OPTIONAL
29                 false                    -- force-renew, OPTIONAL. Force the liquid source to renew if it has
30                                          -- a source neighbour, even if defined as 'liquid_renewable = false'.
31                                          -- Needed to avoid creating holes in sloping rivers.
32         )
33
34 The filled bucket item is returned to the player that uses an empty bucket pointing to the given liquid source.
35 When punching with an empty bucket pointing to an entity or a non-liquid node, the on_punch of the entity or node will be triggered.
36
37 Beds API
38 --------
39
40         beds.register_bed(
41                 "beds:bed",    -- Bed name
42                 def            -- See [#Bed definition]
43         )
44
45  * `beds.read_spawns() `   Returns a table containing players respawn positions
46  * `beds.kick_players()`  Forces all players to leave bed
47  * `beds.skip_night()`   Sets world time to morning and saves respawn position of all players currently sleeping
48
49 ### Bed definition
50
51         {
52                 description = "Simple Bed",
53                 inventory_image = "beds_bed.png",
54                 wield_image = "beds_bed.png",
55                 tiles = {
56                         bottom = {'Tile definition'}, -- the tiles of the bottom part of the bed.
57                         top = {Tile definition} -- the tiles of the bottom part of the bed.
58                 },
59                 nodebox = {
60                         bottom = 'regular nodebox',     -- bottom part of bed (see [Node boxes])
61                         top = 'regular nodebox',        -- top part of bed (see [Node boxes])
62                 },
63                 selectionbox = 'regular nodebox',  -- for both nodeboxes (see [Node boxes])
64                 recipe = {                                         -- Craft recipe
65                         {"group:wool", "group:wool", "group:wool"},
66                         {"group:wood", "group:wood", "group:wood"}
67                 }
68         }
69
70 Bones API
71 ---------
72
73 An ordered list of listnames (default: "main", "craft") of the player inventory,
74 that will be placed into bones or dropped on player death can be looked up or changed
75 in `bones.player_inventory_lists`.
76
77 e.g. `table.insert(bones.player_inventory_lists, "backpack")`
78
79 Creative API
80 ------------
81
82 Use `creative.register_tab(name, title, items)` to add a tab with filtered items.
83 For example,
84
85         creative.register_tab("tools", "Tools", minetest.registered_tools)
86
87 is used to show all tools. Name is used in the sfinv page name, title is the
88 human readable title.
89
90 `is_enabled_for` is used to check whether a player is in creative mode:
91
92     creative.is_enabled_for(name)
93
94 Override this to allow per-player game modes.
95
96 The contents of `creative.formspec_add` is appended to every creative inventory
97 page. Mods can use it to add additional formspec elements onto the default
98 creative inventory formspec to be drawn after each update.
99
100 Chests API
101 ----------
102
103 The chests API allows the creation of chests, which have their own inventories for holding items.
104
105 `default.chest.get_chest_formspec(pos)`
106
107  * Returns a formspec for a specific chest.
108  * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
109
110 `default.chest.chest_lid_obstructed(pos)`
111
112  * Returns a boolean depending on whether or not a chest has its top obstructed by a solid node.
113  * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
114
115 `default.chest.chest_lid_close(pn)`
116
117  * Closes the chest that a player is currently looking in.
118  * `pn` The name of the player whose chest is going to be closed
119
120 `default.chest.open_chests`
121
122  * A table indexed by player name to keep track of who opened what chest.
123  * Key: The name of the player.
124  * Value: A table containing information about the chest the player is looking at.
125    e.g `{ pos = {1, 1, 1}, sound = null, swap = "chest" }`
126
127 `default.chest.register_chest(name, def)`
128
129  * Registers new chest
130  * `name` Name for chest
131  * `def`  See [#Chest Definition]
132
133 ### Chest Definition
134
135         description = "Chest",
136         tiles = {
137                 "default_chest_top.png",
138                 "default_chest_top.png",
139                 "default_chest_side.png",
140                 "default_chest_side.png",
141                 "default_chest_front.png",
142                 "default_chest_inside.png"
143         }, -- Textures which are applied to the chest model.
144         sounds = default.node_sound_wood_defaults(),
145         sound_open = "default_chest_open",
146         sound_close = "default_chest_close",
147         groups = {choppy = 2, oddly_breakable_by_hand = 2},
148         protected = false, -- If true, only placer can modify chest.
149
150 Doors API
151 ---------
152
153 The doors mod allows modders to register custom doors and trapdoors.
154
155 `doors.register_door(name, def)`
156
157  * Registers new door
158  * `name` Name for door
159  * `def`  See [#Door definition]
160
161 `doors.register_trapdoor(name, def)`
162
163  * Registers new trapdoor
164  * `name` Name for trapdoor
165  * `def`  See [#Trapdoor definition]
166
167 `doors.register_fencegate(name, def)`
168
169  * Registers new fence gate
170  * `name` Name for fence gate
171  * `def`  See [#Fence gate definition]
172
173 `doors.get(pos)`
174
175  * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
176  * Returns an ObjectRef to a door, or nil if the position does not contain a door
177
178     ### Methods
179
180         :open(player)   -- Open the door object, returns if door was opened
181         :close(player)  -- Close the door object, returns if door was closed
182         :toggle(player) -- Toggle the door state, returns if state was toggled
183         :state()        -- returns the door state, true = open, false = closed
184
185     the "player" parameter can be omitted in all methods. If passed then
186     the usual permission checks will be performed to make sure the player
187     has the permissions needed to open this door. If omitted then no
188     permission checks are performed.
189
190 ### Door definition
191
192         description = "Door description",
193         inventory_image = "mod_door_inv.png",
194         groups = {choppy = 2},
195         tiles = {"mod_door.png"}, -- UV map.
196         recipe = craftrecipe,
197         sounds = default.node_sound_wood_defaults(), -- optional
198         sound_open = sound play for open door, -- optional
199         sound_close = sound play for close door, -- optional
200         protected = false, -- If true, only placer can open the door (locked for others)
201
202 ### Trapdoor definition
203
204         description = "Trapdoor description",
205         inventory_image = "mod_trapdoor_inv.png",
206         groups = {choppy = 2},
207         tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
208         tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
209         sounds = default.node_sound_wood_defaults(), -- optional
210         sound_open = sound play for open door, -- optional
211         sound_close = sound play for close door, -- optional
212         protected = false, -- If true, only placer can open the door (locked for others)
213
214 ### Fence gate definition
215
216         description = "Wooden Fence Gate",
217         texture = "default_wood.png", -- `backface_culling` will automatically be
218                                       -- set to `true` if not specified.
219         material = "default:wood",
220         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
221         sounds = default.node_sound_wood_defaults(), -- optional
222
223 Dungeon Loot API
224 ----------------
225
226 The mod that places chests with loot in dungeons provides an API to register additional loot.
227
228 `dungeon_loot.register(def)`
229
230  * Registers one or more loot items
231  * `def` Can be a single [#Loot definition] or a list of them
232
233 `dungeon_loot.registered_loot`
234
235  * Table of all registered loot, not to be modified manually
236
237 ### Loot definition
238
239         name = "item:name",
240         chance = 0.5,
241         -- ^ chance value from 0.0 to 1.0 that the item will appear in the chest when chosen
242         --   due to an extra step in the selection process, 0.5 does not(!) mean that
243         --   on average every second chest will have this item
244         count = {1, 4},
245         -- ^ table with minimum and maximum amounts of this item
246         --   optional, defaults to always single item
247         y = {-32768, -512},
248         -- ^ table with minimum and maximum heights this item can be found at
249         --   optional, defaults to no height restrictions
250         types = {"desert"},
251         -- ^ table with types of dungeons this item can be found in
252         --   supported types: "normal" (the cobble/mossycobble one), "sandstone", "desert"
253         --   optional, defaults to no type restrictions
254
255 Fence API
256 ---------
257
258 Allows creation of new fences with "fencelike" drawtype.
259
260 `default.register_fence(name, item definition)`
261
262  Registers a new fence. Custom fields texture and material are required, as
263  are name and description. The rest is optional. You can pass most normal
264  nodedef fields here except drawtype. The fence group will always be added
265  for this node.
266
267 ### fence definition
268
269         name = "default:fence_wood",
270         description = "Wooden Fence",
271         texture = "default_wood.png",
272         material = "default:wood",
273         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
274         sounds = default.node_sound_wood_defaults(),
275
276 Walls API
277 ---------
278
279 The walls API allows easy addition of stone auto-connecting wall nodes.
280
281 walls.register(name, desc, texture, mat, sounds)
282 ^ name = "walls:stone_wall". Node name.
283 ^ desc = "A Stone wall"
284 ^ texture = "default_stone.png"
285 ^ mat = "default:stone". Used to auto-generate crafting recipe.
286 ^ sounds = sounds: see [#Default sounds]
287
288 Farming API
289 -----------
290
291 The farming API allows you to easily register plants and hoes.
292
293 `farming.register_hoe(name, hoe definition)`
294  * Register a new hoe, see [#hoe definition]
295
296 `farming.register_plant(name, Plant definition)`
297  * Register a new growing plant, see [#Plant definition]
298
299 `farming.registered_plants[name] = definition`
300  * Table of registered plants, indexed by plant name
301
302 ### Hoe Definition
303
304
305         {
306                 description = "",                      -- Description for tooltip
307                 inventory_image = "unknown_item.png",  -- Image to be used as wield- and inventory image
308                 max_uses = 30,                         -- Uses until destroyed
309                 material = "",                         -- Material for recipes
310                 recipe = {                             -- Craft recipe, if material isn't used
311                         {"air", "air", "air"},
312                         {"", "group:stick"},
313                         {"", "group:stick"},
314                 }
315         }
316
317 ### Plant definition
318
319         {
320                 description = "",                      -- Description of seed item
321                 inventory_image = "unknown_item.png",  -- Image to be used as seed's wield- and inventory image
322                 steps = 8,                             -- How many steps the plant has to grow, until it can be harvested
323                 -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
324                 minlight = 13,                         -- Minimum light to grow
325                 maxlight = default.LIGHT_MAX           -- Maximum light to grow
326         }
327
328 Fire API
329 --------
330
331 New node def property:
332
333 `on_burn(pos)`
334
335  * Called when fire attempts to remove a burning node.
336  * `pos` Position of the burning node.
337
338  `on_ignite(pos, igniter)`
339
340   * Called when Flint and steel (or a mod defined ignitor) is used on a node.
341     Defining it may prevent the default action (spawning flames) from triggering.
342   * `pos` Position of the ignited node.
343   * `igniter` Player that used the tool, when available.
344
345
346 Give Initial Stuff API
347 ----------------------
348
349 `give_initial_stuff.give(player)`
350
351 ^ Give initial stuff to "player"
352
353 `give_initial_stuff.add(stack)`
354
355 ^ Add item to the initial stuff
356 ^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
357 ^ Can be called after the game has loaded
358
359 `give_initial_stuff.clear()`
360
361 ^ Removes all items from the initial stuff
362 ^ Can be called after the game has loaded
363
364 `give_initial_stuff.get_list()`
365
366 ^ returns list of item stacks
367
368 `give_initial_stuff.set_list(list)`
369
370 ^ List of initial items with numeric indices.
371
372 `give_initial_stuff.add_from_csv(str)`
373
374 ^ str is a comma separated list of initial stuff
375 ^ Adds items to the list of items to be given
376
377
378 Players API
379 -----------
380
381 The player API can register player models and update the player's appearence
382
383 * `player_api.register_model(name, def)`
384         * Register a new model to be used by players
385         * name: model filename such as "character.x", "foo.b3d", etc.
386         * def: See [#Model definition]
387     * saved to player_api.registered_models
388
389 * `player_api.registered_player_models[name]`
390          * Get a model's definition
391          * see [#Model definition]
392
393 * `player_api.set_model(player, model_name)`
394         * Change a player's model
395         * `player`: PlayerRef
396         * `model_name`: model registered with player_api.register_model()
397
398 * `player_api.set_animation(player, anim_name [, speed])`
399         * Applies an animation to a player
400         * anim_name: name of the animation.
401         * speed: frames per second. If nil, default from the model is used
402
403 * `player_api.set_textures(player, textures)`
404         * Sets player textures
405         * `player`: PlayerRef
406         * `textures`: array of textures, If `textures` is nil the default
407           textures from the model def are used
408
409 * `player_api.get_animation(player)`
410         * Returns a table containing fields `model`, `textures` and `animation`.
411         * Any of the fields of the returned table may be nil.
412         * player: PlayerRef
413
414 ### Model Definition
415
416         {
417                 animation_speed = 30,            -- Default animation speed, in FPS.
418                 textures = {"character.png", },  -- Default array of textures.
419                 visual_size = {x = 1, y = 1},    -- Used to scale the model.
420                 animations = {
421                         -- <anim_name> = {x = <start_frame>, y = <end_frame>},
422                         foo = {x = 0, y = 19},
423                         bar = {x = 20, y = 39},
424                 -- ...
425                 },
426                 collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, -- In nodes from feet position
427                 stepheight = 0.6, -- In nodes
428                 eye_height = 1.47, -- In nodes above feet position
429         }
430
431
432 TNT API
433 -------
434
435 `tnt.register_tnt(definition)`
436
437 ^ Register a new type of tnt.
438
439  * `name` The name of the node. If no prefix is given `tnt` is used.
440  * `description` A description for your TNT.
441  * `radius` The radius within which the TNT can destroy nodes. The default is 3.
442  * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
443  * `sound` The sound played when explosion occurs. By default it is `tnt_explode`.
444  * `disable_drops` Disable drops. By default it is set to false.
445  * `ignore_protection` Don't check `minetest.is_protected` before removing a node.
446  * `ignore_on_blast` Don't call `on_blast` even if a node has one.
447  * `tiles` Textures for node
448   * `side`  Side tiles. By default the name of the tnt with a suffix of `_side.png`.
449   * `top`  Top tile. By default the name of the tnt with a suffix of `_top.png`.
450   * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
451   * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
452
453 `tnt.boom(position[, definition])`
454
455 ^ Create an explosion.
456
457 * `position` The center of explosion.
458 * `definition` The TNT definion as passed to `tnt.register` with the following addition:
459  * `explode_center` false by default which removes TNT node on blast, when true will explode center node.
460
461 `tnt.burn(position, [nodename])`
462
463 ^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
464 If no such callback exists, fallback to turn tnt group nodes to their
465 "_burning" variant.
466   nodename isn't required unless already known.
467
468 To make dropping items from node inventories easier, you can use the
469 following helper function from 'default':
470
471 default.get_inventory_drops(pos, inventory, drops)
472
473 ^ Return drops from node inventory "inventory" in drops.
474
475 * `pos` - the node position
476 * `inventory` - the name of the inventory (string)
477 * `drops` - an initialized list
478
479 The function returns no values. The drops are returned in the `drops`
480 parameter, and drops is not reinitialized so you can call it several
481 times in a row to add more inventory items to it.
482
483
484 `on_blast` callbacks:
485
486 Both nodedefs and entitydefs can provide an `on_blast()` callback
487
488 `nodedef.on_blast(pos, intensity)`
489 ^ Allow drop and node removal overriding
490 * `pos` - node position
491 * `intensity` - TNT explosion measure. larger or equal to 1.0
492 ^ Should return a list of drops (e.g. {"default:stone"})
493 ^ Should perform node removal itself. If callback exists in the nodedef
494 ^ then the TNT code will not destroy this node.
495
496 `entitydef.on_blast(luaobj, damage)`
497 ^ Allow TNT effects on entities to be overridden
498 * `luaobj` - LuaEntityRef of the entity
499 * `damage` - suggested HP damage value
500 ^ Should return a list of (bool do_damage, bool do_knockback, table drops)
501 * `do_damage` - if true then TNT mod wil damage the entity
502 * `do_knockback` - if true then TNT mod will knock the entity away
503 * `drops` - a list of drops, e.g. {"wool:red"}
504
505
506 Screwdriver API
507 ---------------
508
509 The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
510 To use it, add the `on_screwdriver` function to the node definition.
511
512 `on_rotate(pos, node, user, mode, new_param2)`
513
514  * `pos` Position of the node that the screwdriver is being used on
515  * `node` that node
516  * `user` The player who used the screwdriver
517  * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
518  * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
519  * return value: false to disallow rotation, nil to keep default behaviour, true to allow
520         it but to indicate that changed have already been made (so the screwdriver will wear out)
521  * use `on_rotate = false` to always disallow rotation
522  * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
523
524
525 Sethome API
526 -----------
527
528 The sethome API adds three global functions to allow mods to read a players home position,
529 set a players home position and teleport a player to home position.
530
531 `sethome.get(name)`
532
533  * `name` Player who's home position you wish to get
534  * return value: false if no player home coords exist, position table if true
535
536 `sethome.set(name, pos)`
537
538  * `name` Player who's home position you wish to set
539  * `pos` Position table containing coords of home position
540  * return value: false if unable to set and save new home position, otherwise true
541
542 `sethome.go(name)`
543
544  * `name` Player you wish to teleport to their home position
545  * return value: false if player cannot be sent home, otherwise true
546
547
548 Sfinv API
549 ---------
550
551 ### sfinv Methods
552
553 **Pages**
554
555 * sfinv.set_page(player, pagename) - changes the page
556 * sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
557 * sfinv.register_page(name, def) - register a page, see section below
558 * sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
559     * Note: Page must already be defined, (opt)depend on the mod defining it.
560 * sfinv.set_player_inventory_formspec(player) - (re)builds page formspec
561              and calls set_inventory_formspec().
562 * sfinv.get_formspec(player, context) - builds current page's formspec
563
564 **Contexts**
565
566 * sfinv.get_or_create_context(player) - gets the player's context
567 * sfinv.set_context(player, context)
568
569 **Theming**
570
571 * sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
572     * show_inv, defaults to false. Whether to show the player's main inventory
573     * size, defaults to `size[8,8.6]` if not specified
574 * sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or ""
575
576 ### sfinv Members
577
578 * pages - table of pages[pagename] = def
579 * pages_unordered - array table of pages in order of addition (used to build navigation tabs).
580 * contexts - contexts[playername] = player_context
581 * enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
582
583 ### Context
584
585 A table with these keys:
586
587 * page - current page name
588 * nav - a list of page names
589 * nav_titles - a list of page titles
590 * nav_idx - current nav index (in nav and nav_titles)
591 * any thing you want to store
592     * sfinv will clear the stored data on log out / log in
593
594 ### sfinv.register_page
595
596 sfinv.register_page(name, def)
597
598 def is a table containing:
599
600 * `title` - human readable page name (required)
601 * `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
602 * `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
603 * `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
604 * `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
605 * `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
606
607 ### get formspec
608
609 Use sfinv.make_formspec to apply a layout:
610
611         return sfinv.make_formspec(player, context, [[
612                 list[current_player;craft;1.75,0.5;3,3;]
613                 list[current_player;craftpreview;5.75,1.5;1,1;]
614                 image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
615                 listring[current_player;main]
616                 listring[current_player;craft]
617                 image[0,4.25;1,1;gui_hb_bg.png]
618                 image[1,4.25;1,1;gui_hb_bg.png]
619                 image[2,4.25;1,1;gui_hb_bg.png]
620                 image[3,4.25;1,1;gui_hb_bg.png]
621                 image[4,4.25;1,1;gui_hb_bg.png]
622                 image[5,4.25;1,1;gui_hb_bg.png]
623                 image[6,4.25;1,1;gui_hb_bg.png]
624                 image[7,4.25;1,1;gui_hb_bg.png]
625         ]], true)
626
627 See above (methods section) for more options.
628
629 ### Customising themes
630
631 Simply override this function to change the navigation:
632
633         function sfinv.get_nav_fs(player, context, nav, current_idx)
634                 return "navformspec"
635         end
636
637 And override this function to change the layout:
638
639         function sfinv.make_formspec(player, context, content, show_inv, size)
640                 local tmp = {
641                         size or "size[8,8.6]",
642                         theme_main,
643                         sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
644                         content
645                 }
646                 if show_inv then
647                         tmp[4] = theme_inv
648                 end
649                 return table.concat(tmp, "")
650         end
651
652 Stairs API
653 ----------
654
655 The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
656 delivered with Minetest Game, to keep them compatible with other mods.
657
658 `stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
659
660  * Registers a stair.
661  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
662  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
663  * `groups`: see [Known damage and digging time defining groups]
664  * `images`: see [Tile definition]
665  * `description`: used for the description field in the stair's definition
666  * `sounds`: see [#Default sounds]
667
668 `stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
669
670  * Registers a slabs
671  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
672  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
673  * `groups`: see [Known damage and digging time defining groups]
674  * `images`: see [Tile definition]
675  * `description`: used for the description field in the stair's definition
676  * `sounds`: see [#Default sounds]
677
678 `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)`
679
680  * A wrapper for stairs.register_stair and stairs.register_slab
681  * Uses almost the same arguments as stairs.register_stair
682  * `desc_stair`: Description for stair node
683  * `desc_slab`: Description for slab node
684
685 Xpanes API
686 ----------
687
688 Creates panes that automatically connect to each other
689
690 `xpanes.register_pane(subname, def)`
691
692  * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
693  * `def`: See [#Pane definition]
694
695 ### Pane definition
696
697         {
698                 textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
699                 groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
700                 sounds = SoundSpec,        -- See [#Default sounds]
701                 recipe = {{"","","","","","","","",""}}, -- Recipe field only
702                 use_texture_alpha = true, -- Optional boolean (default: `false`) for colored glass panes
703         }
704
705 Raillike definitions
706 --------------------
707
708 The following nodes use the group `connect_to_raillike` and will only connect to
709 raillike nodes within this group and the same group value.
710 Use `minetest.raillike_group(<Name>)` to get the group value.
711
712 | Node type             | Raillike group name
713 |-----------------------|---------------------
714 | default:rail          | "rail"
715 | tnt:gunpowder         | "gunpowder"
716 | tnt:gunpowder_burning | "gunpowder"
717
718 Example:
719 If you want to add a new rail type and want it to connect with default:rail,
720 add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
721 of your node.
722
723
724 Default sounds
725 --------------
726
727 Sounds inside the default table can be used within the sounds field of node definitions.
728
729  * `default.node_sound_defaults()`
730  * `default.node_sound_stone_defaults()`
731  * `default.node_sound_dirt_defaults()`
732  * `default.node_sound_sand_defaults()`
733  * `default.node_sound_wood_defaults()`
734  * `default.node_sound_leaves_defaults()`
735  * `default.node_sound_glass_defaults()`
736  * `default.node_sound_metal_defaults()`
737
738 Default constants
739 -----------------
740
741 `default.LIGHT_MAX`  The maximum light level (see [Node definition] light_source)
742
743
744 GUI and formspecs
745 -----------------
746
747 `default.get_hotbar_bg(x, y)`
748
749  * Get the hotbar background as string, containing the formspec elements
750  * x: Horizontal position in the formspec
751  * y: Vertical position in the formspec
752
753 `default.gui_bg`
754
755  * Background color formspec element
756
757 `default.gui_bg_img`
758
759  * Image overlay formspec element for the background to use in formspecs
760
761 `default.gui_slots`
762
763  * `listcolors` formspec element that is used to format the slots in formspecs
764
765 `default.gui_survival_form`
766
767  * Entire formspec for the survival inventory
768
769 `default.get_furnace_active_formspec(fuel_percent, item_percent)`
770
771  * Get the active furnace formspec using the defined GUI elements
772  * fuel_percent: Percent of how much the fuel is used
773  * item_percent: Percent of how much the item is cooked
774
775 `default.get_furnace_inactive_formspec()`
776
777  * Get the inactive furnace formspec using the defined GUI elements
778
779
780 Leafdecay
781 ---------
782
783 To enable leaf decay for leaves when a tree is cut down by a player,
784 register the tree with the default.register_leafdecay(leafdecaydef)
785 function.
786
787 If `param2` of any registered node is ~= 0, the node will always be
788 preserved. Thus, if the player places a node of that kind, you will
789 want to set `param2 = 1` or so.
790
791 The function `default.after_place_leaves` can be set as
792 `after_place_node of a node` to set param2 to 1 if the player places
793 the node (should not be used for nodes that use param2 otherwise
794 (e.g. facedir)).
795
796 If the node is in the `leafdecay_drop` group then it will always be
797 dropped as an item.
798
799 `default.register_leafdecay(leafdecaydef)`
800
801 `leafdecaydef` is a table, with following members:
802         {
803                 trunks = {"default:tree"}, -- nodes considered trunks
804                 leaves = {"default:leaves", "default:apple"},
805                         -- nodes considered for removal
806                 radius = 3, -- radius to consider for searching
807         }
808
809 Note: all the listed nodes in `trunks` have their `on_after_destruct`
810 callback overridden. All the nodes listed in `leaves` have their
811 `on_timer` callback overridden.
812
813
814 Dyes
815 ----
816
817 To make recipes that will work with any dye ever made by anybody, define
818 them based on groups. You can select any group of groups, based on your need for
819 amount of colors.
820
821 ### Color groups
822
823 Base color groups:
824
825  * `basecolor_white`
826  * `basecolor_grey`
827  * `basecolor_black`
828  * `basecolor_red`
829  * `basecolor_yellow`
830  * `basecolor_green`
831  * `basecolor_cyan`
832  * `basecolor_blue`
833  * `basecolor_magenta`
834
835 Extended color groups ( * means also base color )
836
837  * `excolor_white` *
838  * `excolor_lightgrey`
839  * `excolor_grey` *
840  * `excolor_darkgrey`
841  * `excolor_black` *
842  * `excolor_red` *
843  * `excolor_orange`
844  * `excolor_yellow` *
845  * `excolor_lime`
846  * `excolor_green` *
847  * `excolor_aqua`
848  * `excolor_cyan` *
849  * `excolor_sky_blue`
850  * `excolor_blue` *
851  * `excolor_violet`
852  * `excolor_magenta` *
853  * `excolor_red_violet`
854
855 The whole unifieddyes palette as groups:
856
857  * `unicolor_<excolor>`
858
859 For the following, no white/grey/black is allowed:
860
861  * `unicolor_medium_<excolor>`
862  * `unicolor_dark_<excolor>`
863  * `unicolor_light_<excolor>`
864  * `unicolor_<excolor>_s50`
865  * `unicolor_medium_<excolor>_s50`
866  * `unicolor_dark_<excolor>_s50`
867
868 Example of one shapeless recipe using a color group:
869
870         minetest.register_craft({
871                 type = "shapeless",
872                 output = '<mod>:item_yellow',
873                 recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
874         })
875
876 ### Color lists
877
878  * `dye.basecolors` are an array containing the names of available base colors
879
880  * `dye.excolors` are an array containing the names of the available extended colors
881
882 Trees
883 -----
884
885  * `default.grow_tree(pos, is_apple_tree)`
886   * Grows a mgv6 tree or apple tree at pos
887
888  * `default.grow_jungle_tree(pos)`
889   * Grows a mgv6 jungletree at pos
890
891  * `default.grow_pine_tree(pos)`
892   * Grows a mgv6 pinetree at pos
893
894  * `default.grow_new_apple_tree(pos)`
895   * Grows a new design apple tree at pos
896
897  * `default.grow_new_jungle_tree(pos)`
898   * Grows a new design jungle tree at pos
899
900  * `default.grow_new_pine_tree(pos)`
901   * Grows a new design pine tree at pos
902
903  * `default.grow_new_snowy_pine_tree(pos)`
904   * Grows a new design snowy pine tree at pos
905
906  * `default.grow_new_acacia_tree(pos)`
907   * Grows a new design acacia tree at pos
908
909  * `default.grow_new_aspen_tree(pos)`
910   * Grows a new design aspen tree at pos
911
912  * `default.grow_bush(pos)`
913   * Grows a bush at pos
914
915  * `default.grow_acacia_bush(pos)`
916   * Grows an acaia bush at pos
917
918 Carts
919 -----
920
921         carts.register_rail(
922                 "mycarts:myrail", -- Rail name
923                 nodedef,          -- standard nodedef
924                 railparams        -- rail parameter struct (optional)
925         )
926
927         railparams = {
928                 on_step(obj, dtime), -- Event handler called when
929                                      -- cart is on rail
930                 acceleration, -- integer acceleration factor (negative
931                               -- values to brake)
932         }
933
934         The event handler is called after all default calculations
935         are made, so the custom on_step handler can override things
936         like speed, acceleration, player attachment. The handler will
937         likely be called many times per second, so the function needs
938         to make sure that the event is handled properly.
939
940 Key API
941 -------
942
943 The key API allows mods to add key functionality to nodes that have
944 ownership or specific permissions. Using the API will make it so
945 that a node owner can use skeleton keys on their nodes to create keys
946 for that node in that location, and give that key to other players,
947 allowing them some sort of access that they otherwise would not have
948 due to node protection.
949
950 To make your new nodes work with the key API, you need to register
951 two callback functions in each nodedef:
952
953
954 `on_key_use(pos, player)`
955  * Is called when a player right-clicks (uses) a normal key on your
956  * node.
957  * `pos` - position of the node
958  * `player` - PlayerRef
959  * return value: none, ignored
960
961 The `on_key_use` callback should validate that the player is wielding
962 a key item with the right key meta secret. If needed the code should
963 deny access to the node functionality.
964
965 If formspecs are used, the formspec callbacks should duplicate these
966 checks in the metadata callback functions.
967
968
969 `on_skeleton_key_use(pos, player, newsecret)`
970
971  * Is called when a player right-clicks (uses) a skeleton key on your
972  * node.
973  * `pos` - position of the node
974  * `player` - PlayerRef
975  * `newsecret` - a secret value(string)
976  * return values:
977  * `secret` - `nil` or the secret value that unlocks the door
978  * `name` - a string description of the node ("a locked chest")
979  * `owner` - name of the node owner
980
981 The `on_skeleton_key_use` function should validate that the player has
982 the right permissions to make a new key for the item. The newsecret
983 value is useful if the node has no secret value. The function should
984 store this secret value somewhere so that in the future it may compare
985 key secrets and match them to allow access. If a node already has a
986 secret value, the function should return that secret value instead
987 of the newsecret value. The secret value stored for the node should
988 not be overwritten, as this would invalidate existing keys.
989
990 Aside from the secret value, the function should retun a descriptive
991 name for the node and the owner name. The return values are all
992 encoded in the key that will be given to the player in replacement
993 for the wielded skeleton key.
994
995 if `nil` is returned, it is assumed that the wielder did not have
996 permissions to create a key for this node, and no key is created.