3 GitHub Repo: https://github.com/minetest/minetest_game
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
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}`
20 The bucket API allows registering new types of buckets for non-default liquids.
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.
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.
41 "beds:bed", -- Bed name
42 def -- See [#Bed definition]
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
52 description = "Simple Bed",
53 inventory_image = "beds_bed.png",
54 wield_image = "beds_bed.png",
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.
60 bottom = 'regular nodebox', -- bottom part of bed (see [Node boxes])
61 top = 'regular nodebox', -- top part of bed (see [Node boxes])
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"}
73 Use `creative.register_tab(name, title, items)` to add a tab with filtered items.
76 creative.register_tab("tools", "Tools", minetest.registered_tools)
78 is used to show all tools. Name is used in the sfinv page name, title is the
81 `is_enabled_for` is used to check whether a player is in creative mode:
83 creative.is_enabled_for(name)
85 Override this to allow per-player game modes.
87 The contents of `creative.formspec_add` is appended to every creative inventory
88 page. Mods can use it to add additional formspec elements onto the default
89 creative inventory formspec to be drawn after each update.
94 The chests API allows the creation of chests, which have their own inventories for holding items.
96 `default.chest.get_chest_formspec(pos)`
98 * Returns a formspec for a specific chest.
99 * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
101 `default.chest.chest_lid_obstructed(pos)`
103 * Returns a boolean depending on whether or not a chest has its top obstructed by a solid node.
104 * `pos` Location of the chest node, e.g `{x = 1, y = 1, z = 1}`
106 `default.chest.chest_lid_close(pn)`
108 * Closes the chest that a player is currently looking in.
109 * `pn` The name of the player whose chest is going to be closed
111 `default.chest.open_chests`
113 * A table indexed by player name to keep track of who opened what chest.
114 * Key: The name of the player.
115 * Value: A table containing information about the chest the player is looking at.
116 e.g `{ pos = {1, 1, 1}, sound = null, swap = "chest" }`
118 `default.chest.register_chest(name, def)`
120 * Registers new chest
121 * `name` Name for chest
122 * `def` See [#Chest Definition]
126 description = "Chest",
128 "default_chest_top.png",
129 "default_chest_top.png",
130 "default_chest_side.png",
131 "default_chest_side.png",
132 "default_chest_front.png",
133 "default_chest_inside.png"
134 }, -- Textures which are applied to the chest model.
135 sounds = default.node_sound_wood_defaults(),
136 sound_open = "default_chest_open",
137 sound_close = "default_chest_close",
138 groups = {choppy = 2, oddly_breakable_by_hand = 2},
139 protected = false, -- If true, only placer can modify chest.
144 The doors mod allows modders to register custom doors and trapdoors.
146 `doors.register_door(name, def)`
149 * `name` Name for door
150 * `def` See [#Door definition]
152 `doors.register_trapdoor(name, def)`
154 * Registers new trapdoor
155 * `name` Name for trapdoor
156 * `def` See [#Trapdoor definition]
158 `doors.register_fencegate(name, def)`
160 * Registers new fence gate
161 * `name` Name for fence gate
162 * `def` See [#Fence gate definition]
166 * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
167 * Returns an ObjectRef to a door, or nil if the position does not contain a door
171 :open(player) -- Open the door object, returns if door was opened
172 :close(player) -- Close the door object, returns if door was closed
173 :toggle(player) -- Toggle the door state, returns if state was toggled
174 :state() -- returns the door state, true = open, false = closed
176 the "player" parameter can be omitted in all methods. If passed then
177 the usual permission checks will be performed to make sure the player
178 has the permissions needed to open this door. If omitted then no
179 permission checks are performed.
183 description = "Door description",
184 inventory_image = "mod_door_inv.png",
185 groups = {choppy = 2},
186 tiles = {"mod_door.png"}, -- UV map.
187 recipe = craftrecipe,
188 sounds = default.node_sound_wood_defaults(), -- optional
189 sound_open = sound play for open door, -- optional
190 sound_close = sound play for close door, -- optional
191 protected = false, -- If true, only placer can open the door (locked for others)
193 ### Trapdoor definition
195 description = "Trapdoor description",
196 inventory_image = "mod_trapdoor_inv.png",
197 groups = {choppy = 2},
198 tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
199 tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
200 sounds = default.node_sound_wood_defaults(), -- optional
201 sound_open = sound play for open door, -- optional
202 sound_close = sound play for close door, -- optional
203 protected = false, -- If true, only placer can open the door (locked for others)
205 ### Fence gate definition
207 description = "Wooden Fence Gate",
208 texture = "default_wood.png", -- `backface_culling` will automatically be
209 -- set to `true` if not specified.
210 material = "default:wood",
211 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
212 sounds = default.node_sound_wood_defaults(), -- optional
217 The mod that places chests with loot in dungeons provides an API to register additional loot.
219 `dungeon_loot.register(def)`
221 * Registers one or more loot items
222 * `def` Can be a single [#Loot definition] or a list of them
224 `dungeon_loot.registered_loot`
226 * Table of all registered loot, not to be modified manually
232 -- ^ chance value from 0.0 to 1.0 that the item will appear in the chest when chosen
233 -- due to an extra step in the selection process, 0.5 does not(!) mean that
234 -- on average every second chest will have this item
236 -- ^ table with minimum and maximum amounts of this item
237 -- optional, defaults to always single item
239 -- ^ table with minimum and maximum heights this item can be found at
240 -- optional, defaults to no height restrictions
242 -- ^ table with types of dungeons this item can be found in
243 -- supported types: "normal" (the cobble/mossycobble one), "sandstone", "desert"
244 -- optional, defaults to no type restrictions
249 Allows creation of new fences with "fencelike" drawtype.
251 `default.register_fence(name, item definition)`
253 Registers a new fence. Custom fields texture and material are required, as
254 are name and description. The rest is optional. You can pass most normal
255 nodedef fields here except drawtype. The fence group will always be added
260 name = "default:fence_wood",
261 description = "Wooden Fence",
262 texture = "default_wood.png",
263 material = "default:wood",
264 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
265 sounds = default.node_sound_wood_defaults(),
270 The walls API allows easy addition of stone auto-connecting wall nodes.
272 walls.register(name, desc, texture, mat, sounds)
273 ^ name = "walls:stone_wall". Node name.
274 ^ desc = "A Stone wall"
275 ^ texture = "default_stone.png"
276 ^ mat = "default:stone". Used to auto-generate crafting recipe.
277 ^ sounds = sounds: see [#Default sounds]
282 The farming API allows you to easily register plants and hoes.
284 `farming.register_hoe(name, hoe definition)`
285 * Register a new hoe, see [#hoe definition]
287 `farming.register_plant(name, Plant definition)`
288 * Register a new growing plant, see [#Plant definition]
290 `farming.registered_plants[name] = definition`
291 * Table of registered plants, indexed by plant name
297 description = "", -- Description for tooltip
298 inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
299 max_uses = 30, -- Uses until destroyed
300 material = "", -- Material for recipes
301 recipe = { -- Craft recipe, if material isn't used
302 {"air", "air", "air"},
311 description = "", -- Description of seed item
312 inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
313 steps = 8, -- How many steps the plant has to grow, until it can be harvested
314 -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
315 minlight = 13, -- Minimum light to grow
316 maxlight = default.LIGHT_MAX -- Maximum light to grow
322 New node def property:
326 * Called when fire attempts to remove a burning node.
327 * `pos` Position of the burning node.
329 `on_ignite(pos, igniter)`
331 * Called when Flint and steel (or a mod defined ignitor) is used on a node.
332 Defining it may prevent the default action (spawning flames) from triggering.
333 * `pos` Position of the ignited node.
334 * `igniter` Player that used the tool, when available.
337 Give Initial Stuff API
338 ----------------------
340 `give_initial_stuff.give(player)`
342 ^ Give initial stuff to "player"
344 `give_initial_stuff.add(stack)`
346 ^ Add item to the initial stuff
347 ^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
348 ^ Can be called after the game has loaded
350 `give_initial_stuff.clear()`
352 ^ Removes all items from the initial stuff
353 ^ Can be called after the game has loaded
355 `give_initial_stuff.get_list()`
357 ^ returns list of item stacks
359 `give_initial_stuff.set_list(list)`
361 ^ List of initial items with numeric indices.
363 `give_initial_stuff.add_from_csv(str)`
365 ^ str is a comma separated list of initial stuff
366 ^ Adds items to the list of items to be given
372 The player API can register player models and update the player's appearence
374 * `player_api.register_model(name, def)`
375 * Register a new model to be used by players
376 * name: model filename such as "character.x", "foo.b3d", etc.
377 * def: See [#Model definition]
378 * saved to player_api.registered_models
380 * `player_api.registered_player_models[name]`
381 * Get a model's definition
382 * see [#Model definition]
384 * `player_api.set_model(player, model_name)`
385 * Change a player's model
386 * `player`: PlayerRef
387 * `model_name`: model registered with player_api.register_model()
389 * `player_api.set_animation(player, anim_name [, speed])`
390 * Applies an animation to a player
391 * anim_name: name of the animation.
392 * speed: frames per second. If nil, default from the model is used
394 * `player_api.set_textures(player, textures)`
395 * Sets player textures
396 * `player`: PlayerRef
397 * `textures`: array of textures, If `textures` is nil the default
398 textures from the model def are used
400 * `player_api.get_animation(player)`
401 * Returns a table containing fields `model`, `textures` and `animation`.
402 * Any of the fields of the returned table may be nil.
408 animation_speed = 30, -- Default animation speed, in FPS.
409 textures = {"character.png", }, -- Default array of textures.
410 visual_size = {x = 1, y = 1}, -- Used to scale the model.
412 -- <anim_name> = {x = <start_frame>, y = <end_frame>},
413 foo = {x = 0, y = 19},
414 bar = {x = 20, y = 39},
417 collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, -- In nodes from feet position
418 stepheight = 0.6, -- In nodes
419 eye_height = 1.47, -- In nodes above feet position
426 `tnt.register_tnt(definition)`
428 ^ Register a new type of tnt.
430 * `name` The name of the node. If no prefix is given `tnt` is used.
431 * `description` A description for your TNT.
432 * `radius` The radius within which the TNT can destroy nodes. The default is 3.
433 * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
434 * `sound` The sound played when explosion occurs. By default it is `tnt_explode`.
435 * `disable_drops` Disable drops. By default it is set to false.
436 * `ignore_protection` Don't check `minetest.is_protected` before removing a node.
437 * `ignore_on_blast` Don't call `on_blast` even if a node has one.
438 * `tiles` Textures for node
439 * `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`.
440 * `top` Top tile. By default the name of the tnt with a suffix of `_top.png`.
441 * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
442 * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
444 `tnt.boom(position[, definition])`
446 ^ Create an explosion.
448 * `position` The center of explosion.
449 * `definition` The TNT definion as passed to `tnt.register` with the following addition:
450 * `explode_center` false by default which removes TNT node on blast, when true will explode center node.
452 `tnt.burn(position, [nodename])`
454 ^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
455 If no such callback exists, fallback to turn tnt group nodes to their
457 nodename isn't required unless already known.
459 To make dropping items from node inventories easier, you can use the
460 following helper function from 'default':
462 default.get_inventory_drops(pos, inventory, drops)
464 ^ Return drops from node inventory "inventory" in drops.
466 * `pos` - the node position
467 * `inventory` - the name of the inventory (string)
468 * `drops` - an initialized list
470 The function returns no values. The drops are returned in the `drops`
471 parameter, and drops is not reinitialized so you can call it several
472 times in a row to add more inventory items to it.
475 `on_blast` callbacks:
477 Both nodedefs and entitydefs can provide an `on_blast()` callback
479 `nodedef.on_blast(pos, intensity)`
480 ^ Allow drop and node removal overriding
481 * `pos` - node position
482 * `intensity` - TNT explosion measure. larger or equal to 1.0
483 ^ Should return a list of drops (e.g. {"default:stone"})
484 ^ Should perform node removal itself. If callback exists in the nodedef
485 ^ then the TNT code will not destroy this node.
487 `entitydef.on_blast(luaobj, damage)`
488 ^ Allow TNT effects on entities to be overridden
489 * `luaobj` - LuaEntityRef of the entity
490 * `damage` - suggested HP damage value
491 ^ Should return a list of (bool do_damage, bool do_knockback, table drops)
492 * `do_damage` - if true then TNT mod wil damage the entity
493 * `do_knockback` - if true then TNT mod will knock the entity away
494 * `drops` - a list of drops, e.g. {"wool:red"}
500 The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
501 To use it, add the `on_screwdriver` function to the node definition.
503 `on_rotate(pos, node, user, mode, new_param2)`
505 * `pos` Position of the node that the screwdriver is being used on
507 * `user` The player who used the screwdriver
508 * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
509 * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
510 * return value: false to disallow rotation, nil to keep default behaviour, true to allow
511 it but to indicate that changed have already been made (so the screwdriver will wear out)
512 * use `on_rotate = false` to always disallow rotation
513 * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
519 The sethome API adds three global functions to allow mods to read a players home position,
520 set a players home position and teleport a player to home position.
524 * `name` Player who's home position you wish to get
525 * return value: false if no player home coords exist, position table if true
527 `sethome.set(name, pos)`
529 * `name` Player who's home position you wish to set
530 * `pos` Position table containing coords of home position
531 * return value: false if unable to set and save new home position, otherwise true
535 * `name` Player you wish to teleport to their home position
536 * return value: false if player cannot be sent home, otherwise true
546 * sfinv.set_page(player, pagename) - changes the page
547 * sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
548 * sfinv.register_page(name, def) - register a page, see section below
549 * sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
550 * Note: Page must already be defined, (opt)depend on the mod defining it.
551 * sfinv.set_player_inventory_formspec(player) - (re)builds page formspec
552 and calls set_inventory_formspec().
553 * sfinv.get_formspec(player, context) - builds current page's formspec
557 * sfinv.get_or_create_context(player) - gets the player's context
558 * sfinv.set_context(player, context)
562 * sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
563 * show_inv, defaults to false. Whether to show the player's main inventory
564 * size, defaults to `size[8,8.6]` if not specified
565 * sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or ""
569 * pages - table of pages[pagename] = def
570 * pages_unordered - array table of pages in order of addition (used to build navigation tabs).
571 * contexts - contexts[playername] = player_context
572 * enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
576 A table with these keys:
578 * page - current page name
579 * nav - a list of page names
580 * nav_titles - a list of page titles
581 * nav_idx - current nav index (in nav and nav_titles)
582 * any thing you want to store
583 * sfinv will clear the stored data on log out / log in
585 ### sfinv.register_page
587 sfinv.register_page(name, def)
589 def is a table containing:
591 * `title` - human readable page name (required)
592 * `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
593 * `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
594 * `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
595 * `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
596 * `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
600 Use sfinv.make_formspec to apply a layout:
602 return sfinv.make_formspec(player, context, [[
603 list[current_player;craft;1.75,0.5;3,3;]
604 list[current_player;craftpreview;5.75,1.5;1,1;]
605 image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
606 listring[current_player;main]
607 listring[current_player;craft]
608 image[0,4.25;1,1;gui_hb_bg.png]
609 image[1,4.25;1,1;gui_hb_bg.png]
610 image[2,4.25;1,1;gui_hb_bg.png]
611 image[3,4.25;1,1;gui_hb_bg.png]
612 image[4,4.25;1,1;gui_hb_bg.png]
613 image[5,4.25;1,1;gui_hb_bg.png]
614 image[6,4.25;1,1;gui_hb_bg.png]
615 image[7,4.25;1,1;gui_hb_bg.png]
618 See above (methods section) for more options.
620 ### Customising themes
622 Simply override this function to change the navigation:
624 function sfinv.get_nav_fs(player, context, nav, current_idx)
628 And override this function to change the layout:
630 function sfinv.make_formspec(player, context, content, show_inv, size)
632 size or "size[8,8.6]",
634 sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
640 return table.concat(tmp, "")
646 The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
647 delivered with Minetest Game, to keep them compatible with other mods.
649 `stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
652 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
653 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
654 * `groups`: see [Known damage and digging time defining groups]
655 * `images`: see [Tile definition]
656 * `description`: used for the description field in the stair's definition
657 * `sounds`: see [#Default sounds]
659 `stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
662 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
663 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
664 * `groups`: see [Known damage and digging time defining groups]
665 * `images`: see [Tile definition]
666 * `description`: used for the description field in the stair's definition
667 * `sounds`: see [#Default sounds]
669 `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)`
671 * A wrapper for stairs.register_stair and stairs.register_slab
672 * Uses almost the same arguments as stairs.register_stair
673 * `desc_stair`: Description for stair node
674 * `desc_slab`: Description for slab node
679 Creates panes that automatically connect to each other
681 `xpanes.register_pane(subname, def)`
683 * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
684 * `def`: See [#Pane definition]
689 textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
690 groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
691 sounds = SoundSpec, -- See [#Default sounds]
692 recipe = {{"","","","","","","","",""}}, -- Recipe field only
693 use_texture_alpha = true, -- Optional boolean (default: `false`) for colored glass panes
699 The following nodes use the group `connect_to_raillike` and will only connect to
700 raillike nodes within this group and the same group value.
701 Use `minetest.raillike_group(<Name>)` to get the group value.
703 | Node type | Raillike group name
704 |-----------------------|---------------------
705 | default:rail | "rail"
706 | tnt:gunpowder | "gunpowder"
707 | tnt:gunpowder_burning | "gunpowder"
710 If you want to add a new rail type and want it to connect with default:rail,
711 add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
718 Sounds inside the default table can be used within the sounds field of node definitions.
720 * `default.node_sound_defaults()`
721 * `default.node_sound_stone_defaults()`
722 * `default.node_sound_dirt_defaults()`
723 * `default.node_sound_sand_defaults()`
724 * `default.node_sound_wood_defaults()`
725 * `default.node_sound_leaves_defaults()`
726 * `default.node_sound_glass_defaults()`
727 * `default.node_sound_metal_defaults()`
732 `default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
738 `default.get_hotbar_bg(x, y)`
740 * Get the hotbar background as string, containing the formspec elements
741 * x: Horizontal position in the formspec
742 * y: Vertical position in the formspec
746 * Background color formspec element
750 * Image overlay formspec element for the background to use in formspecs
754 * `listcolors` formspec element that is used to format the slots in formspecs
756 `default.gui_survival_form`
758 * Entire formspec for the survival inventory
760 `default.get_furnace_active_formspec(fuel_percent, item_percent)`
762 * Get the active furnace formspec using the defined GUI elements
763 * fuel_percent: Percent of how much the fuel is used
764 * item_percent: Percent of how much the item is cooked
766 `default.get_furnace_inactive_formspec()`
768 * Get the inactive furnace formspec using the defined GUI elements
774 To enable leaf decay for leaves when a tree is cut down by a player,
775 register the tree with the default.register_leafdecay(leafdecaydef)
778 If `param2` of any registered node is ~= 0, the node will always be
779 preserved. Thus, if the player places a node of that kind, you will
780 want to set `param2 = 1` or so.
782 The function `default.after_place_leaves` can be set as
783 `after_place_node of a node` to set param2 to 1 if the player places
784 the node (should not be used for nodes that use param2 otherwise
787 If the node is in the `leafdecay_drop` group then it will always be
790 `default.register_leafdecay(leafdecaydef)`
792 `leafdecaydef` is a table, with following members:
794 trunks = {"default:tree"}, -- nodes considered trunks
795 leaves = {"default:leaves", "default:apple"},
796 -- nodes considered for removal
797 radius = 3, -- radius to consider for searching
800 Note: all the listed nodes in `trunks` have their `on_after_destruct`
801 callback overridden. All the nodes listed in `leaves` have their
802 `on_timer` callback overridden.
808 To make recipes that will work with any dye ever made by anybody, define
809 them based on groups. You can select any group of groups, based on your need for
824 * `basecolor_magenta`
826 Extended color groups ( * means also base color )
829 * `excolor_lightgrey`
843 * `excolor_magenta` *
844 * `excolor_red_violet`
846 The whole unifieddyes palette as groups:
848 * `unicolor_<excolor>`
850 For the following, no white/grey/black is allowed:
852 * `unicolor_medium_<excolor>`
853 * `unicolor_dark_<excolor>`
854 * `unicolor_light_<excolor>`
855 * `unicolor_<excolor>_s50`
856 * `unicolor_medium_<excolor>_s50`
857 * `unicolor_dark_<excolor>_s50`
859 Example of one shapeless recipe using a color group:
861 minetest.register_craft({
863 output = '<mod>:item_yellow',
864 recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
869 * `dye.basecolors` are an array containing the names of available base colors
871 * `dye.excolors` are an array containing the names of the available extended colors
876 * `default.grow_tree(pos, is_apple_tree)`
877 * Grows a mgv6 tree or apple tree at pos
879 * `default.grow_jungle_tree(pos)`
880 * Grows a mgv6 jungletree at pos
882 * `default.grow_pine_tree(pos)`
883 * Grows a mgv6 pinetree at pos
885 * `default.grow_new_apple_tree(pos)`
886 * Grows a new design apple tree at pos
888 * `default.grow_new_jungle_tree(pos)`
889 * Grows a new design jungle tree at pos
891 * `default.grow_new_pine_tree(pos)`
892 * Grows a new design pine tree at pos
894 * `default.grow_new_snowy_pine_tree(pos)`
895 * Grows a new design snowy pine tree at pos
897 * `default.grow_new_acacia_tree(pos)`
898 * Grows a new design acacia tree at pos
900 * `default.grow_new_aspen_tree(pos)`
901 * Grows a new design aspen tree at pos
903 * `default.grow_bush(pos)`
904 * Grows a bush at pos
906 * `default.grow_acacia_bush(pos)`
907 * Grows an acaia bush at pos
913 "mycarts:myrail", -- Rail name
914 nodedef, -- standard nodedef
915 railparams -- rail parameter struct (optional)
919 on_step(obj, dtime), -- Event handler called when
921 acceleration, -- integer acceleration factor (negative
925 The event handler is called after all default calculations
926 are made, so the custom on_step handler can override things
927 like speed, acceleration, player attachment. The handler will
928 likely be called many times per second, so the function needs
929 to make sure that the event is handled properly.
934 The key API allows mods to add key functionality to nodes that have
935 ownership or specific permissions. Using the API will make it so
936 that a node owner can use skeleton keys on their nodes to create keys
937 for that node in that location, and give that key to other players,
938 allowing them some sort of access that they otherwise would not have
939 due to node protection.
941 To make your new nodes work with the key API, you need to register
942 two callback functions in each nodedef:
945 `on_key_use(pos, player)`
946 * Is called when a player right-clicks (uses) a normal key on your
948 * `pos` - position of the node
949 * `player` - PlayerRef
950 * return value: none, ignored
952 The `on_key_use` callback should validate that the player is wielding
953 a key item with the right key meta secret. If needed the code should
954 deny access to the node functionality.
956 If formspecs are used, the formspec callbacks should duplicate these
957 checks in the metadata callback functions.
960 `on_skeleton_key_use(pos, player, newsecret)`
962 * Is called when a player right-clicks (uses) a skeleton key on your
964 * `pos` - position of the node
965 * `player` - PlayerRef
966 * `newsecret` - a secret value(string)
968 * `secret` - `nil` or the secret value that unlocks the door
969 * `name` - a string description of the node ("a locked chest")
970 * `owner` - name of the node owner
972 The `on_skeleton_key_use` function should validate that the player has
973 the right permissions to make a new key for the item. The newsecret
974 value is useful if the node has no secret value. The function should
975 store this secret value somewhere so that in the future it may compare
976 key secrets and match them to allow access. If a node already has a
977 secret value, the function should return that secret value instead
978 of the newsecret value. The secret value stored for the node should
979 not be overwritten, as this would invalidate existing keys.
981 Aside from the secret value, the function should retun a descriptive
982 name for the node and the owner name. The return values are all
983 encoded in the key that will be given to the player in replacement
984 for the wielded skeleton key.
986 if `nil` is returned, it is assumed that the wielder did not have
987 permissions to create a key for this node, and no key is created.