Fix ItemStack method call for keys.
[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 Creative API
71 ------------
72
73 Use `creative.register_tab(name, title, items)` to add a tab with filtered items.
74 For example,
75
76         creative.register_tab("tools", "Tools", minetest.registered_tools)
77
78 is used to show all tools. Name is used in the sfinv page name, title is the
79 human readable title.
80
81 The contents of `creative.formspec_add` is appended to every creative inventory
82 page. Mods can use it to add additional formspec elements onto the default
83 creative inventory formspec to be drawn after each update.
84
85 Doors API
86 ---------
87
88 The doors mod allows modders to register custom doors and trapdoors.
89
90 `doors.register_door(name, def)`
91
92  * Registers new door
93  * `name` Name for door
94  * `def`  See [#Door definition]
95
96 `doors.register_trapdoor(name, def)`
97
98  * Registers new trapdoor
99  * `name` Name for trapdoor
100  * `def`  See [#Trapdoor definition]
101
102 `doors.register_fencegate(name, def)`
103
104  * Registers new fence gate
105  * `name` Name for fence gate
106  * `def`  See [#Fence gate definition]
107
108 `doors.get(pos)`
109
110  * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
111  * Returns an ObjectRef to a door, or nil if the position does not contain a door
112
113     ### Methods
114
115         :open(player)   -- Open the door object, returns if door was opened
116         :close(player)  -- Close the door object, returns if door was closed
117         :toggle(player) -- Toggle the door state, returns if state was toggled
118         :state()        -- returns the door state, true = open, false = closed
119
120     the "player" parameter can be omitted in all methods. If passed then
121     the usual permission checks will be performed to make sure the player
122     has the permissions needed to open this door. If omitted then no
123     permission checks are performed.
124
125 ### Door definition
126
127         description = "Door description",
128         inventory_image = "mod_door_inv.png",
129         groups = {choppy = 2},
130         tiles = {"mod_door.png"}, -- UV map.
131         recipe = craftrecipe,
132         sounds = default.node_sound_wood_defaults(), -- optional
133         sound_open = sound play for open door, -- optional
134         sound_close = sound play for close door, -- optional
135         protected = false, -- If true, only placer can open the door (locked for others)
136
137 ### Trapdoor definition
138
139         description = "Trapdoor description",
140         inventory_image = "mod_trapdoor_inv.png",
141         groups = {choppy = 2},
142         tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
143         tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
144         sounds = default.node_sound_wood_defaults(), -- optional
145         sound_open = sound play for open door, -- optional
146         sound_close = sound play for close door, -- optional
147         protected = false, -- If true, only placer can open the door (locked for others)
148
149 ### Fence gate definition
150
151         description = "Wooden Fence Gate",
152         texture = "default_wood.png",
153         material = "default:wood",
154         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
155         sounds = default.node_sound_wood_defaults(), -- optional
156
157 Fence API
158 ---------
159
160 Allows creation of new fences with "fencelike" drawtype.
161
162 `default.register_fence(name, item definition)`
163
164  Registers a new fence. Custom fields texture and material are required, as
165  are name and description. The rest is optional. You can pass most normal
166  nodedef fields here except drawtype. The fence group will always be added
167  for this node.
168
169 ### fence definition
170
171         name = "default:fence_wood",
172         description = "Wooden Fence",
173         texture = "default_wood.png",
174         material = "default:wood",
175         groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
176         sounds = default.node_sound_wood_defaults(),
177
178 Walls API
179 ---------
180
181 The walls API allows easy addition of stone auto-connecting wall nodes.
182
183 walls.register(name, desc, texture, mat, sounds)
184 ^ name = "walls:stone_wall". Node name.
185 ^ desc = "A Stone wall"
186 ^ texture = "default_stone.png"
187 ^ mat = "default:stone". Used to auto-generate crafting recipe.
188 ^ sounds = sounds: see [#Default sounds]
189
190 Farming API
191 -----------
192
193 The farming API allows you to easily register plants and hoes.
194
195 `farming.register_hoe(name, hoe definition)`
196  * Register a new hoe, see [#hoe definition]
197
198 `farming.register_plant(name, Plant definition)`
199  * Register a new growing plant, see [#Plant definition]
200
201 `farming.registered_plants[name] = definition`
202  * Table of registered plants, indexed by plant name
203
204 ### Hoe Definition
205
206
207         {
208                 description = "",                      -- Description for tooltip
209                 inventory_image = "unknown_item.png",  -- Image to be used as wield- and inventory image
210                 max_uses = 30,                         -- Uses until destroyed
211                 material = "",                         -- Material for recipes
212                 recipe = {                             -- Craft recipe, if material isn't used
213                         {"air", "air", "air"},
214                         {"", "group:stick"},
215                         {"", "group:stick"},
216                 }
217         }
218
219 ### Plant definition
220
221         {
222                 description = "",                      -- Description of seed item
223                 inventory_image = "unknown_item.png",  -- Image to be used as seed's wield- and inventory image
224                 steps = 8,                             -- How many steps the plant has to grow, until it can be harvested
225                 -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
226                 minlight = 13,                         -- Minimum light to grow
227                 maxlight = default.LIGHT_MAX           -- Maximum light to grow
228         }
229
230 Fire API
231 --------
232
233 New node def property:
234
235 `on_burn(pos)`
236
237  * Called when fire attempts to remove a burning node.
238  * `pos` Position of the burning node.
239
240  `on_ignite(pos, igniter)`
241
242   * Called when Flint and steel (or a mod defined ignitor) is used on a node.
243     Defining it may prevent the default action (spawning flames) from triggering.
244   * `pos` Position of the ignited node.
245   * `igniter` Player that used the tool, when available.
246
247
248 Give Initial Stuff API
249 ----------------------
250
251 `give_initial_stuff.give(player)`
252
253 ^ Give initial stuff to "player"
254
255 `give_initial_stuff.add(stack)`
256
257 ^ Add item to the initial stuff
258 ^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
259 ^ Can be called after the game has loaded
260
261 `give_initial_stuff.clear()`
262
263 ^ Removes all items from the initial stuff
264 ^ Can be called after the game has loaded
265
266 `give_initial_stuff.get_list()`
267
268 ^ returns list of item stacks
269
270 `give_initial_stuff.set_list(list)`
271
272 ^ List of initial items with numeric indices.
273
274 `give_initial_stuff.add_from_csv(str)`
275
276 ^ str is a comma separated list of initial stuff
277 ^ Adds items to the list of items to be given
278
279 Nyancat API
280 -----------
281
282 `nyancat.place(pos, facedir, length)`
283
284 ^ Place a cat at `pos` facing `facedir` with tail length `length`
285   Only accepts facedir 0-3, if facedir > 3 then it will be interpreted as facedir = 0
286
287 `nyancat.generate(minp, maxp, seed)`
288
289 ^ Called by `minetest.register_on_generated`. To disable nyancat generation,
290   you can redefine nyancat.generate() to be an empty function
291
292 TNT API
293 ----------
294
295 `tnt.register_tnt(definition)`
296
297 ^ Register a new type of tnt.
298
299  * `name` The name of the node. If no prefix is given `tnt` is used.
300  * `description` A description for your TNT.
301  * `radius` The radius within which the TNT can destroy nodes. The default is 3.
302  * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
303  * `disable_drops` Disable drops. By default it is set to false.
304  * `ignore_protection` Don't check `minetest.is_protected` before removing a node.
305  * `ignore_on_blast` Don't call `on_blast` even if a node has one.
306  * `tiles` Textures for node
307   * `side`  Side tiles. By default the name of the tnt with a suffix of `_side.png`.
308   * `top`  Top tile. By default the name of the tnt with a suffix of `_top.png`.
309   * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
310   * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
311
312 `tnt.boom(position, definition)`
313
314 ^ Create an explosion.
315
316 * `position` The center of explosion.
317 * `definition` The TNT definion as passed to `tnt.register`
318
319 `tnt.burn(position, [nodename])`
320
321 ^ Ignite TNT at position, nodename isn't required unless already known.
322
323
324 To make dropping items from node inventories easier, you can use the
325 following helper function from 'default':
326
327 default.get_inventory_drops(pos, inventory, drops)
328
329 ^ Return drops from node inventory "inventory" in drops.
330
331 * `pos` - the node position
332 * `inventory` - the name of the inventory (string)
333 * `drops` - an initialized list
334
335 The function returns no values. The drops are returned in the `drops`
336 parameter, and drops is not reinitialized so you can call it several
337 times in a row to add more inventory items to it.
338
339
340 `on_blast` callbacks:
341
342 Both nodedefs and entitydefs can provide an `on_blast()` callback
343
344 `nodedef.on_blast(pos, intensity)`
345 ^ Allow drop and node removal overriding
346 * `pos` - node position
347 * `intensity` - TNT explosion measure. larger or equal to 1.0
348 ^ Should return a list of drops (e.g. {"default:stone"})
349 ^ Should perform node removal itself. If callback exists in the nodedef
350 ^ then the TNT code will not destroy this node.
351
352 `entitydef.on_blast(luaobj, damage)`
353 ^ Allow TNT effects on entities to be overridden
354 * `luaobj` - LuaEntityRef of the entity
355 * `damage` - suggested HP damage value
356 ^ Should return a list of (bool do_damage, bool do_knockback, table drops)
357 * `do_damage` - if true then TNT mod wil damage the entity
358 * `do_knockback` - if true then TNT mod will knock the entity away
359 * `drops` - a list of drops, e.g. {"wool:red"}
360
361
362 Screwdriver API
363 ---------------
364
365 The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
366 To use it, add the `on_screwdriver` function to the node definition.
367
368 `on_rotate(pos, node, user, mode, new_param2)`
369
370  * `pos` Position of the node that the screwdriver is being used on
371  * `node` that node
372  * `user` The player who used the screwdriver
373  * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
374  * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
375  * return value: false to disallow rotation, nil to keep default behaviour, true to allow
376         it but to indicate that changed have already been made (so the screwdriver will wear out)
377  * use `on_rotate = false` to always disallow rotation
378  * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
379
380
381 Sethome API
382 -----------
383
384 The sethome API adds three global functions to allow mods to read a players home position,
385 set a players home position and teleport a player to home position.
386
387 `sethome.get(name)`
388
389  * `name` Player who's home position you wish to get
390  * return value: false if no player home coords exist, position table if true
391
392 `sethome.set(name, pos)`
393
394  * `name` Player who's home position you wish to set
395  * `pos` Position table containing coords of home position
396  * return value: false if unable to set and save new home position, otherwise true
397
398 `sethome.go(name)`
399
400  * `name` Player you wish to teleport to their home position
401  * return value: false if player cannot be sent home, otherwise true
402
403
404 Sfinv API
405 ---------
406
407 ### sfinv Methods
408
409 * sfinv.set_player_inventory_formspec(player, context) - builds page formspec
410             and calls set_inventory_formspec().
411             If context is nil, it is either found or created.
412 * sfinv.get_formspec(player, context) - builds current page's formspec
413 * sfinv.get_nav_fs(player, context, nav, current_idx) - see above
414 * sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
415     * show_inv, defaults to false. Whether to show the player's main inventory
416     * size, defaults to `size[8,8.6]` if not specified
417 * sfinv.register_page(name, def) - register a page, see section below
418 * sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
419     * Note: Page must already be defined, (opt)depend on the mod defining it.
420
421 ### sfinv Members
422
423 * pages - table of pages[pagename] = def
424 * pages_unordered - array table of pages in order of addition (used to build navigation tabs).
425 * homepage_name - name of default page
426 * contexts - contexts[playername] = player_context
427 * enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
428
429 ### Context
430
431 A table with these keys:
432
433 * page - current page name
434 * nav - a list of page names
435 * nav_titles - a list of page titles
436 * nav_idx - current nav index (in nav and nav_titles)
437 * any thing you want to store
438     * sfinv will clear the stored data on log out / log in
439
440 ### sfinv.register_page
441
442 sfinv.register_page(name, def)
443
444 def is a table containing:
445
446 * `title` - human readable page name (required)
447 * `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
448 * `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
449 * `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
450 * `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
451 * `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
452
453 ### get formspec
454
455 Use sfinv.make_formspec to apply a layout:
456
457         return sfinv.make_formspec(player, context, [[
458                 list[current_player;craft;1.75,0.5;3,3;]
459                 list[current_player;craftpreview;5.75,1.5;1,1;]
460                 image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
461                 listring[current_player;main]
462                 listring[current_player;craft]
463                 image[0,4.25;1,1;gui_hb_bg.png]
464                 image[1,4.25;1,1;gui_hb_bg.png]
465                 image[2,4.25;1,1;gui_hb_bg.png]
466                 image[3,4.25;1,1;gui_hb_bg.png]
467                 image[4,4.25;1,1;gui_hb_bg.png]
468                 image[5,4.25;1,1;gui_hb_bg.png]
469                 image[6,4.25;1,1;gui_hb_bg.png]
470                 image[7,4.25;1,1;gui_hb_bg.png]
471         ]], true)
472
473 See above (methods section) for more options.
474
475 ### Customising themes
476
477 Simply override this function to change the navigation:
478
479         function sfinv.get_nav_fs(player, context, nav, current_idx)
480                 return "navformspec"
481         end
482
483 And override this function to change the layout:
484
485         function sfinv.make_formspec(player, context, content, show_inv, size)
486                 local tmp = {
487                         size or "size[8,8.6]",
488                         theme_main,
489                         sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
490                         content
491                 }
492                 if show_inv then
493                         tmp[4] = theme_inv
494                 end
495                 return table.concat(tmp, "")
496         end
497
498 Stairs API
499 ----------
500
501 The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
502 delivered with Minetest Game, to keep them compatible with other mods.
503
504 `stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
505
506  * Registers a stair.
507  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
508  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
509  * `groups`: see [Known damage and digging time defining groups]
510  * `images`: see [Tile definition]
511  * `description`: used for the description field in the stair's definition
512  * `sounds`: see [#Default sounds]
513
514 `stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
515
516  * Registers a slabs
517  * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
518  * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
519  * `groups`: see [Known damage and digging time defining groups]
520  * `images`: see [Tile definition]
521  * `description`: used for the description field in the stair's definition
522  * `sounds`: see [#Default sounds]
523
524 `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)`
525
526  * A wrapper for stairs.register_stair and stairs.register_slab
527  * Uses almost the same arguments as stairs.register_stair
528  * `desc_stair`: Description for stair node
529  * `desc_slab`: Description for slab node
530
531 Xpanes API
532 ----------
533
534 Creates panes that automatically connect to each other
535
536 `xpanes.register_pane(subname, def)`
537
538  * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
539  * `def`: See [#Pane definition]
540
541 ### Pane definition
542
543         {
544                 textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
545                 groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
546                 sounds = SoundSpec,        -- See [#Default sounds]
547                 recipe = {{"","","","","","","","",""}}, -- Recipe field only
548         }
549
550 Raillike definitions
551 --------------------
552
553 The following nodes use the group `connect_to_raillike` and will only connect to
554 raillike nodes within this group and the same group value.
555 Use `minetest.raillike_group(<Name>)` to get the group value.
556
557 | Node type             | Raillike group name
558 |-----------------------|---------------------
559 | default:rail          | "rail"
560 | tnt:gunpowder         | "gunpowder"
561 | tnt:gunpowder_burning | "gunpowder"
562
563 Example:
564 If you want to add a new rail type and want it to connect with default:rail,
565 add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
566 of your node.
567
568
569 Default sounds
570 --------------
571
572 Sounds inside the default table can be used within the sounds field of node definitions.
573
574  * `default.node_sound_defaults()`
575  * `default.node_sound_stone_defaults()`
576  * `default.node_sound_dirt_defaults()`
577  * `default.node_sound_sand_defaults()`
578  * `default.node_sound_wood_defaults()`
579  * `default.node_sound_leaves_defaults()`
580  * `default.node_sound_glass_defaults()`
581  * `default.node_sound_metal_defaults()`
582
583 Default constants
584 -----------------
585
586 `default.LIGHT_MAX`  The maximum light level (see [Node definition] light_source)
587
588 Player API
589 ----------
590
591 The player API can register player models and update the player's appearence
592
593 `default.player_register_model(name, def)`
594
595  * Register a new model to be used by players.
596  * name: model filename such as "character.x", "foo.b3d", etc.
597  * def: See [#Model definition]
598
599 `default.registered_player_models[name]`
600
601  * Get a model's definition
602  * see [#Model definition]
603
604 `default.player_set_model(player, model_name)`
605
606  * Change a player's model
607  * `player`: PlayerRef
608  * `model_name`: model registered with player_register_model()
609
610 `default.player_set_animation(player, anim_name [, speed])`
611
612  * Applies an animation to a player
613  * anim_name: name of the animation.
614  * speed: frames per second. If nil, default from the model is used
615
616 `default.player_set_textures(player, textures)`
617
618  * Sets player textures
619  * `player`: PlayerRef
620  * `textures`: array of textures, If `textures` is nil, the default textures from the model def are used
621
622 default.player_get_animation(player)
623
624  * Returns a table containing fields `model`, `textures` and `animation`.
625  * Any of the fields of the returned table may be nil.
626  * player: PlayerRef
627
628 ### Model Definition
629
630         {
631                 animation_speed = 30,            -- Default animation speed, in FPS.
632                 textures = {"character.png", },  -- Default array of textures.
633                 visual_size = {x = 1, y = 1},    -- Used to scale the model.
634                 animations = {
635                         -- <anim_name> = {x = <start_frame>, y = <end_frame>},
636                         foo = {x = 0, y = 19},
637                         bar = {x = 20, y = 39},
638                 -- ...
639                 },
640         }
641
642 Leafdecay
643 ---------
644
645 To enable leaf decay for a node, add it to the `leafdecay` group.
646
647 The rating of the group determines how far from a node in the group `tree`
648 the node can be without decaying.
649
650 If `param2` of the node is ~= 0, the node will always be preserved. Thus, if
651 the player places a node of that kind, you will want to set `param2 = 1` or so.
652
653 The function `default.after_place_leaves` can be set as `after_place_node of a node`
654 to set param2 to 1 if the player places the node (should not be used for nodes
655 that use param2 otherwise (e.g. facedir)).
656
657 If the node is in the `leafdecay_drop` group then it will always be dropped as an
658 item.
659
660 Dyes
661 ----
662
663 To make recipes that will work with any dye ever made by anybody, define
664 them based on groups. You can select any group of groups, based on your need for
665 amount of colors.
666
667 ### Color groups
668
669 Base color groups:
670
671  * `basecolor_white`
672  * `basecolor_grey`
673  * `basecolor_black`
674  * `basecolor_red`
675  * `basecolor_yellow`
676  * `basecolor_green`
677  * `basecolor_cyan`
678  * `basecolor_blue`
679  * `basecolor_magenta`
680
681 Extended color groups ( * means also base color )
682
683  * `excolor_white` *
684  * `excolor_lightgrey`
685  * `excolor_grey` *
686  * `excolor_darkgrey`
687  * `excolor_black` *
688  * `excolor_red` *
689  * `excolor_orange`
690  * `excolor_yellow` *
691  * `excolor_lime`
692  * `excolor_green` *
693  * `excolor_aqua`
694  * `excolor_cyan` *
695  * `excolor_sky_blue`
696  * `excolor_blue` *
697  * `excolor_violet`
698  * `excolor_magenta` *
699  * `excolor_red_violet`
700
701 The whole unifieddyes palette as groups:
702
703  * `unicolor_<excolor>`
704
705 For the following, no white/grey/black is allowed:
706
707  * `unicolor_medium_<excolor>`
708  * `unicolor_dark_<excolor>`
709  * `unicolor_light_<excolor>`
710  * `unicolor_<excolor>_s50`
711  * `unicolor_medium_<excolor>_s50`
712  * `unicolor_dark_<excolor>_s50`
713
714 Example of one shapeless recipe using a color group:
715
716         minetest.register_craft({
717                 type = "shapeless",
718                 output = '<mod>:item_yellow',
719                 recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
720         })
721
722 ### Color lists
723
724  * `dye.basecolors` are an array containing the names of available base colors
725
726  * `dye.excolors` are an array containing the names of the available extended colors
727
728 Trees
729 -----
730
731  * `default.grow_tree(pos, is_apple_tree)`
732   * Grows a mgv6 tree or apple tree at pos
733
734  * `default.grow_jungle_tree(pos)`
735   * Grows a mgv6 jungletree at pos
736
737  * `default.grow_pine_tree(pos)`
738   * Grows a mgv6 pinetree at pos
739
740  * `default.grow_new_apple_tree(pos)`
741   * Grows a new design apple tree at pos
742
743  * `default.grow_new_jungle_tree(pos)`
744   * Grows a new design jungle tree at pos
745
746  * `default.grow_new_pine_tree(pos)`
747   * Grows a new design pine tree at pos
748
749  * `default.grow_new_acacia_tree(pos)`
750   * Grows a new design acacia tree at pos
751
752  * `default.grow_new_aspen_tree(pos)`
753   * Grows a new design aspen tree at pos
754
755  * `default.grow_new_snowy_pine_tree(pos)`
756   * Grows a new design snowy pine tree at pos
757
758 Carts
759 -----
760
761         carts.register_rail(
762                 "mycarts:myrail", -- Rail name
763                 nodedef,          -- standard nodedef
764                 railparams        -- rail parameter struct (optional)
765         )
766
767         railparams = {
768                 on_step(obj, dtime), -- Event handler called when
769                                      -- cart is on rail
770                 acceleration, -- integer acceleration factor (negative
771                               -- values to brake)
772         }
773
774         The event handler is called after all default calculations
775         are made, so the custom on_step handler can override things
776         like speed, acceleration, player attachment. The handler will
777         likely be called many times per second, so the function needs
778         to make sure that the event is handled properly.
779
780 Key API
781 -------
782
783 The key API allows mods to add key functionality to nodes that have
784 ownership or specific permissions. Using the API will make it so
785 that a node owner can use skeleton keys on their nodes to create keys
786 for that node in that location, and give that key to other players,
787 allowing them some sort of access that they otherwise would not have
788 due to node protection.
789
790 To make your new nodes work with the key API, you need to register
791 two callback functions in each nodedef:
792
793
794 `on_key_use(pos, player)`
795  * Is called when a player right-clicks (uses) a normal key on your
796  * node.
797  * `pos` - position of the node
798  * `player` - PlayerRef
799  * return value: none, ignored
800
801 The `on_key_use` callback should validate that the player is wielding
802 a key item with the right key meta secret. If needed the code should
803 deny access to the node functionality.
804
805 If formspecs are used, the formspec callbacks should duplicate these
806 checks in the metadata callback functions.
807
808
809 `on_skeleton_key_use(pos, player, newsecret)`
810
811  * Is called when a player right-clicks (uses) a skeleton key on your
812  * node.
813  * `pos` - position of the node
814  * `player` - PlayerRef
815  * `newsecret` - a secret value(string)
816  * return values:
817  * `secret` - `nil` or the secret value that unlocks the door
818  * `name` - a string description of the node ("a locked chest")
819  * `owner` - name of the node owner
820
821 The `on_skeleton_key_use` function should validate that the player has
822 the right permissions to make a new key for the item. The newsecret
823 value is useful if the node has no secret value. The function should
824 store this secret value somewhere so that in the future it may compare
825 key secrets and match them to allow access. If a node already has a
826 secret value, the function should return that secret value instead
827 of the newsecret value. The secret value stored for the node should
828 not be overwritten, as this would invalidate existing keys.
829
830 Aside from the secret value, the function should retun a descriptive
831 name for the node and the owner name. The return values are all
832 encoded in the key that will be given to the player in replacement
833 for the wielded skeleton key.
834
835 if `nil` is returned, it is assumed that the wielder did not have
836 permissions to create a key for this node, and no key is created.