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