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 doors mod allows modders to register custom doors and trapdoors.
96 `doors.register_door(name, def)`
99 * `name` Name for door
100 * `def` See [#Door definition]
102 `doors.register_trapdoor(name, def)`
104 * Registers new trapdoor
105 * `name` Name for trapdoor
106 * `def` See [#Trapdoor definition]
108 `doors.register_fencegate(name, def)`
110 * Registers new fence gate
111 * `name` Name for fence gate
112 * `def` See [#Fence gate definition]
116 * `pos` A position as a table, e.g `{x = 1, y = 1, z = 1}`
117 * Returns an ObjectRef to a door, or nil if the position does not contain a door
121 :open(player) -- Open the door object, returns if door was opened
122 :close(player) -- Close the door object, returns if door was closed
123 :toggle(player) -- Toggle the door state, returns if state was toggled
124 :state() -- returns the door state, true = open, false = closed
126 the "player" parameter can be omitted in all methods. If passed then
127 the usual permission checks will be performed to make sure the player
128 has the permissions needed to open this door. If omitted then no
129 permission checks are performed.
133 description = "Door description",
134 inventory_image = "mod_door_inv.png",
135 groups = {choppy = 2},
136 tiles = {"mod_door.png"}, -- UV map.
137 recipe = craftrecipe,
138 sounds = default.node_sound_wood_defaults(), -- optional
139 sound_open = sound play for open door, -- optional
140 sound_close = sound play for close door, -- optional
141 protected = false, -- If true, only placer can open the door (locked for others)
143 ### Trapdoor definition
145 description = "Trapdoor description",
146 inventory_image = "mod_trapdoor_inv.png",
147 groups = {choppy = 2},
148 tile_front = "doors_trapdoor.png", -- the texture for the front and back of the trapdoor
149 tile_side = "doors_trapdoor_side.png", -- the tiles of the four side parts of the trapdoor
150 sounds = default.node_sound_wood_defaults(), -- optional
151 sound_open = sound play for open door, -- optional
152 sound_close = sound play for close door, -- optional
153 protected = false, -- If true, only placer can open the door (locked for others)
155 ### Fence gate definition
157 description = "Wooden Fence Gate",
158 texture = "default_wood.png", -- `backface_culling` will automatically be
159 -- set to `true` if not specified.
160 material = "default:wood",
161 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
162 sounds = default.node_sound_wood_defaults(), -- optional
167 Allows creation of new fences with "fencelike" drawtype.
169 `default.register_fence(name, item definition)`
171 Registers a new fence. Custom fields texture and material are required, as
172 are name and description. The rest is optional. You can pass most normal
173 nodedef fields here except drawtype. The fence group will always be added
178 name = "default:fence_wood",
179 description = "Wooden Fence",
180 texture = "default_wood.png",
181 material = "default:wood",
182 groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
183 sounds = default.node_sound_wood_defaults(),
188 The walls API allows easy addition of stone auto-connecting wall nodes.
190 walls.register(name, desc, texture, mat, sounds)
191 ^ name = "walls:stone_wall". Node name.
192 ^ desc = "A Stone wall"
193 ^ texture = "default_stone.png"
194 ^ mat = "default:stone". Used to auto-generate crafting recipe.
195 ^ sounds = sounds: see [#Default sounds]
200 The farming API allows you to easily register plants and hoes.
202 `farming.register_hoe(name, hoe definition)`
203 * Register a new hoe, see [#hoe definition]
205 `farming.register_plant(name, Plant definition)`
206 * Register a new growing plant, see [#Plant definition]
208 `farming.registered_plants[name] = definition`
209 * Table of registered plants, indexed by plant name
215 description = "", -- Description for tooltip
216 inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
217 max_uses = 30, -- Uses until destroyed
218 material = "", -- Material for recipes
219 recipe = { -- Craft recipe, if material isn't used
220 {"air", "air", "air"},
229 description = "", -- Description of seed item
230 inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
231 steps = 8, -- How many steps the plant has to grow, until it can be harvested
232 -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
233 minlight = 13, -- Minimum light to grow
234 maxlight = default.LIGHT_MAX -- Maximum light to grow
240 New node def property:
244 * Called when fire attempts to remove a burning node.
245 * `pos` Position of the burning node.
247 `on_ignite(pos, igniter)`
249 * Called when Flint and steel (or a mod defined ignitor) is used on a node.
250 Defining it may prevent the default action (spawning flames) from triggering.
251 * `pos` Position of the ignited node.
252 * `igniter` Player that used the tool, when available.
255 Give Initial Stuff API
256 ----------------------
258 `give_initial_stuff.give(player)`
260 ^ Give initial stuff to "player"
262 `give_initial_stuff.add(stack)`
264 ^ Add item to the initial stuff
265 ^ Stack can be an ItemStack or a item name eg: "default:dirt 99"
266 ^ Can be called after the game has loaded
268 `give_initial_stuff.clear()`
270 ^ Removes all items from the initial stuff
271 ^ Can be called after the game has loaded
273 `give_initial_stuff.get_list()`
275 ^ returns list of item stacks
277 `give_initial_stuff.set_list(list)`
279 ^ List of initial items with numeric indices.
281 `give_initial_stuff.add_from_csv(str)`
283 ^ str is a comma separated list of initial stuff
284 ^ Adds items to the list of items to be given
290 The player API can register player models and update the player's appearence
292 * `player_api.register_model(name, def)`
293 * Register a new model to be used by players
294 * name: model filename such as "character.x", "foo.b3d", etc.
295 * def: See [#Model definition]
296 * saved to player_api.registered_models
298 * `player_api.registered_player_models[name]`
299 * Get a model's definition
300 * see [#Model definition]
302 * `player_api.set_model(player, model_name)`
303 * Change a player's model
304 * `player`: PlayerRef
305 * `model_name`: model registered with player_api.register_model()
307 * `player_api.set_animation(player, anim_name [, speed])`
308 * Applies an animation to a player
309 * anim_name: name of the animation.
310 * speed: frames per second. If nil, default from the model is used
312 * `player_api.set_textures(player, textures)`
313 * Sets player textures
314 * `player`: PlayerRef
315 * `textures`: array of textures, If `textures` is nil the default
316 textures from the model def are used
318 * `player_api.get_animation(player)`
319 * Returns a table containing fields `model`, `textures` and `animation`.
320 * Any of the fields of the returned table may be nil.
326 animation_speed = 30, -- Default animation speed, in FPS.
327 textures = {"character.png", }, -- Default array of textures.
328 visual_size = {x = 1, y = 1}, -- Used to scale the model.
330 -- <anim_name> = {x = <start_frame>, y = <end_frame>},
331 foo = {x = 0, y = 19},
332 bar = {x = 20, y = 39},
335 collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.77, 0.3}, -- In nodes from feet position
336 stepheight = 0.6, -- In nodes
343 `tnt.register_tnt(definition)`
345 ^ Register a new type of tnt.
347 * `name` The name of the node. If no prefix is given `tnt` is used.
348 * `description` A description for your TNT.
349 * `radius` The radius within which the TNT can destroy nodes. The default is 3.
350 * `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
351 * `sound` The sound played when explosion occurs. By default it is `tnt_explode`.
352 * `disable_drops` Disable drops. By default it is set to false.
353 * `ignore_protection` Don't check `minetest.is_protected` before removing a node.
354 * `ignore_on_blast` Don't call `on_blast` even if a node has one.
355 * `tiles` Textures for node
356 * `side` Side tiles. By default the name of the tnt with a suffix of `_side.png`.
357 * `top` Top tile. By default the name of the tnt with a suffix of `_top.png`.
358 * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
359 * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
361 `tnt.boom(position[, definition])`
363 ^ Create an explosion.
365 * `position` The center of explosion.
366 * `definition` The TNT definion as passed to `tnt.register` with the following addition:
367 * `explode_center` false by default which removes TNT node on blast, when true will explode center node.
369 `tnt.burn(position, [nodename])`
371 ^ Ignite node at position, triggering its `on_ignite` callback (see fire mod).
372 If no such callback exists, fallback to turn tnt group nodes to their
374 nodename isn't required unless already known.
376 To make dropping items from node inventories easier, you can use the
377 following helper function from 'default':
379 default.get_inventory_drops(pos, inventory, drops)
381 ^ Return drops from node inventory "inventory" in drops.
383 * `pos` - the node position
384 * `inventory` - the name of the inventory (string)
385 * `drops` - an initialized list
387 The function returns no values. The drops are returned in the `drops`
388 parameter, and drops is not reinitialized so you can call it several
389 times in a row to add more inventory items to it.
392 `on_blast` callbacks:
394 Both nodedefs and entitydefs can provide an `on_blast()` callback
396 `nodedef.on_blast(pos, intensity)`
397 ^ Allow drop and node removal overriding
398 * `pos` - node position
399 * `intensity` - TNT explosion measure. larger or equal to 1.0
400 ^ Should return a list of drops (e.g. {"default:stone"})
401 ^ Should perform node removal itself. If callback exists in the nodedef
402 ^ then the TNT code will not destroy this node.
404 `entitydef.on_blast(luaobj, damage)`
405 ^ Allow TNT effects on entities to be overridden
406 * `luaobj` - LuaEntityRef of the entity
407 * `damage` - suggested HP damage value
408 ^ Should return a list of (bool do_damage, bool do_knockback, table drops)
409 * `do_damage` - if true then TNT mod wil damage the entity
410 * `do_knockback` - if true then TNT mod will knock the entity away
411 * `drops` - a list of drops, e.g. {"wool:red"}
417 The screwdriver API allows you to control a node's behaviour when a screwdriver is used on it.
418 To use it, add the `on_screwdriver` function to the node definition.
420 `on_rotate(pos, node, user, mode, new_param2)`
422 * `pos` Position of the node that the screwdriver is being used on
424 * `user` The player who used the screwdriver
425 * `mode` screwdriver.ROTATE_FACE or screwdriver.ROTATE_AXIS
426 * `new_param2` the new value of param2 that would have been set if on_rotate wasn't there
427 * return value: false to disallow rotation, nil to keep default behaviour, true to allow
428 it but to indicate that changed have already been made (so the screwdriver will wear out)
429 * use `on_rotate = false` to always disallow rotation
430 * use `on_rotate = screwdriver.rotate_simple` to allow only face rotation
436 The sethome API adds three global functions to allow mods to read a players home position,
437 set a players home position and teleport a player to home position.
441 * `name` Player who's home position you wish to get
442 * return value: false if no player home coords exist, position table if true
444 `sethome.set(name, pos)`
446 * `name` Player who's home position you wish to set
447 * `pos` Position table containing coords of home position
448 * return value: false if unable to set and save new home position, otherwise true
452 * `name` Player you wish to teleport to their home position
453 * return value: false if player cannot be sent home, otherwise true
463 * sfinv.set_page(player, pagename) - changes the page
464 * sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
465 * sfinv.register_page(name, def) - register a page, see section below
466 * sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
467 * Note: Page must already be defined, (opt)depend on the mod defining it.
468 * sfinv.set_player_inventory_formspec(player) - (re)builds page formspec
469 and calls set_inventory_formspec().
470 * sfinv.get_formspec(player, context) - builds current page's formspec
474 * sfinv.get_or_create_context(player) - gets the player's context
475 * sfinv.set_context(player, context)
479 * sfinv.make_formspec(player, context, content, show_inv, size) - adds a theme to a formspec
480 * show_inv, defaults to false. Whether to show the player's main inventory
481 * size, defaults to `size[8,8.6]` if not specified
482 * sfinv.get_nav_fs(player, context, nav, current_idx) - creates tabheader or ""
486 * pages - table of pages[pagename] = def
487 * pages_unordered - array table of pages in order of addition (used to build navigation tabs).
488 * contexts - contexts[playername] = player_context
489 * enabled - set to false to disable. Good for inventory rehaul mods like unified inventory
493 A table with these keys:
495 * page - current page name
496 * nav - a list of page names
497 * nav_titles - a list of page titles
498 * nav_idx - current nav index (in nav and nav_titles)
499 * any thing you want to store
500 * sfinv will clear the stored data on log out / log in
502 ### sfinv.register_page
504 sfinv.register_page(name, def)
506 def is a table containing:
508 * `title` - human readable page name (required)
509 * `get(self, player, context)` - returns a formspec string. See formspec variables. (required)
510 * `is_in_nav(self, player, context)` - return true to show in the navigation (the tab header, by default)
511 * `on_player_receive_fields(self, player, context, fields)` - on formspec submit.
512 * `on_enter(self, player, context)` - called when the player changes pages, usually using the tabs.
513 * `on_leave(self, player, context)` - when leaving this page to go to another, called before other's on_enter
517 Use sfinv.make_formspec to apply a layout:
519 return sfinv.make_formspec(player, context, [[
520 list[current_player;craft;1.75,0.5;3,3;]
521 list[current_player;craftpreview;5.75,1.5;1,1;]
522 image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
523 listring[current_player;main]
524 listring[current_player;craft]
525 image[0,4.25;1,1;gui_hb_bg.png]
526 image[1,4.25;1,1;gui_hb_bg.png]
527 image[2,4.25;1,1;gui_hb_bg.png]
528 image[3,4.25;1,1;gui_hb_bg.png]
529 image[4,4.25;1,1;gui_hb_bg.png]
530 image[5,4.25;1,1;gui_hb_bg.png]
531 image[6,4.25;1,1;gui_hb_bg.png]
532 image[7,4.25;1,1;gui_hb_bg.png]
535 See above (methods section) for more options.
537 ### Customising themes
539 Simply override this function to change the navigation:
541 function sfinv.get_nav_fs(player, context, nav, current_idx)
545 And override this function to change the layout:
547 function sfinv.make_formspec(player, context, content, show_inv, size)
549 size or "size[8,8.6]",
551 sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
557 return table.concat(tmp, "")
563 The stairs API lets you register stairs and slabs and ensures that they are registered the same way as those
564 delivered with Minetest Game, to keep them compatible with other mods.
566 `stairs.register_stair(subname, recipeitem, groups, images, description, sounds)`
569 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
570 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble", may be `nil`
571 * `groups`: see [Known damage and digging time defining groups]
572 * `images`: see [Tile definition]
573 * `description`: used for the description field in the stair's definition
574 * `sounds`: see [#Default sounds]
576 `stairs.register_slab(subname, recipeitem, groups, images, description, sounds)`
579 * `subname`: Basically the material name (e.g. cobble) used for the stair name. Nodename pattern: "stairs:stair_subname"
580 * `recipeitem`: Item used in the craft recipe, e.g. "default:cobble"
581 * `groups`: see [Known damage and digging time defining groups]
582 * `images`: see [Tile definition]
583 * `description`: used for the description field in the stair's definition
584 * `sounds`: see [#Default sounds]
586 `stairs.register_stair_and_slab(subname, recipeitem, groups, images, desc_stair, desc_slab, sounds)`
588 * A wrapper for stairs.register_stair and stairs.register_slab
589 * Uses almost the same arguments as stairs.register_stair
590 * `desc_stair`: Description for stair node
591 * `desc_slab`: Description for slab node
596 Creates panes that automatically connect to each other
598 `xpanes.register_pane(subname, def)`
600 * `subname`: used for nodename. Result: "xpanes:subname" and "xpanes:subname_{2..15}"
601 * `def`: See [#Pane definition]
606 textures = {"texture for sides", (unused), "texture for top and bottom"}, -- More tiles aren't supported
607 groups = {group = rating}, -- Uses the known node groups, see [Known damage and digging time defining groups]
608 sounds = SoundSpec, -- See [#Default sounds]
609 recipe = {{"","","","","","","","",""}}, -- Recipe field only
615 The following nodes use the group `connect_to_raillike` and will only connect to
616 raillike nodes within this group and the same group value.
617 Use `minetest.raillike_group(<Name>)` to get the group value.
619 | Node type | Raillike group name
620 |-----------------------|---------------------
621 | default:rail | "rail"
622 | tnt:gunpowder | "gunpowder"
623 | tnt:gunpowder_burning | "gunpowder"
626 If you want to add a new rail type and want it to connect with default:rail,
627 add `connect_to_raillike=minetest.raillike_group("rail")` into the `groups` table
634 Sounds inside the default table can be used within the sounds field of node definitions.
636 * `default.node_sound_defaults()`
637 * `default.node_sound_stone_defaults()`
638 * `default.node_sound_dirt_defaults()`
639 * `default.node_sound_sand_defaults()`
640 * `default.node_sound_wood_defaults()`
641 * `default.node_sound_leaves_defaults()`
642 * `default.node_sound_glass_defaults()`
643 * `default.node_sound_metal_defaults()`
648 `default.LIGHT_MAX` The maximum light level (see [Node definition] light_source)
654 `default.get_hotbar_bg(x, y)`
656 * Get the hotbar background as string, containing the formspec elements
657 * x: Horizontal position in the formspec
658 * y: Vertical position in the formspec
662 * Background color formspec element
666 * Image overlay formspec element for the background to use in formspecs
670 * `listcolors` formspec element that is used to format the slots in formspecs
672 `default.gui_survival_form`
674 * Entire formspec for the survival inventory
676 `default.get_chest_formspec(pos)`
678 * Get the chest formspec using the defined GUI elements
679 * pos: Location of the node
681 `default.get_furnace_active_formspec(fuel_percent, item_percent)`
683 * Get the active furnace formspec using the defined GUI elements
684 * fuel_percent: Percent of how much the fuel is used
685 * item_percent: Percent of how much the item is cooked
687 `default.get_furnace_inactive_formspec()`
689 * Get the inactive furnace formspec using the defined GUI elements
695 To enable leaf decay for leaves when a tree is cut down by a player,
696 register the tree with the default.register_leafdecay(leafdecaydef)
699 If `param2` of any registered node is ~= 0, the node will always be
700 preserved. Thus, if the player places a node of that kind, you will
701 want to set `param2 = 1` or so.
703 The function `default.after_place_leaves` can be set as
704 `after_place_node of a node` to set param2 to 1 if the player places
705 the node (should not be used for nodes that use param2 otherwise
708 If the node is in the `leafdecay_drop` group then it will always be
711 `default.register_leafdecay(leafdecaydef)`
713 `leafdecaydef` is a table, with following members:
715 trunks = {"default:tree"}, -- nodes considered trunks
716 leaves = {"default:leaves", "default:apple"},
717 -- nodes considered for removal
718 radius = 3, -- radius to consider for searching
721 Note: all the listed nodes in `trunks` have their `on_after_destruct`
722 callback overridden. All the nodes listed in `leaves` have their
723 `on_timer` callback overridden.
729 To make recipes that will work with any dye ever made by anybody, define
730 them based on groups. You can select any group of groups, based on your need for
745 * `basecolor_magenta`
747 Extended color groups ( * means also base color )
750 * `excolor_lightgrey`
764 * `excolor_magenta` *
765 * `excolor_red_violet`
767 The whole unifieddyes palette as groups:
769 * `unicolor_<excolor>`
771 For the following, no white/grey/black is allowed:
773 * `unicolor_medium_<excolor>`
774 * `unicolor_dark_<excolor>`
775 * `unicolor_light_<excolor>`
776 * `unicolor_<excolor>_s50`
777 * `unicolor_medium_<excolor>_s50`
778 * `unicolor_dark_<excolor>_s50`
780 Example of one shapeless recipe using a color group:
782 minetest.register_craft({
784 output = '<mod>:item_yellow',
785 recipe = {'<mod>:item_no_color', 'group:basecolor_yellow'},
790 * `dye.basecolors` are an array containing the names of available base colors
792 * `dye.excolors` are an array containing the names of the available extended colors
797 * `default.grow_tree(pos, is_apple_tree)`
798 * Grows a mgv6 tree or apple tree at pos
800 * `default.grow_jungle_tree(pos)`
801 * Grows a mgv6 jungletree at pos
803 * `default.grow_pine_tree(pos)`
804 * Grows a mgv6 pinetree at pos
806 * `default.grow_new_apple_tree(pos)`
807 * Grows a new design apple tree at pos
809 * `default.grow_new_jungle_tree(pos)`
810 * Grows a new design jungle tree at pos
812 * `default.grow_new_pine_tree(pos)`
813 * Grows a new design pine tree at pos
815 * `default.grow_new_snowy_pine_tree(pos)`
816 * Grows a new design snowy pine tree at pos
818 * `default.grow_new_acacia_tree(pos)`
819 * Grows a new design acacia tree at pos
821 * `default.grow_new_aspen_tree(pos)`
822 * Grows a new design aspen tree at pos
824 * `default.grow_bush(pos)`
825 * Grows a bush at pos
827 * `default.grow_acacia_bush(pos)`
828 * Grows an acaia bush at pos
834 "mycarts:myrail", -- Rail name
835 nodedef, -- standard nodedef
836 railparams -- rail parameter struct (optional)
840 on_step(obj, dtime), -- Event handler called when
842 acceleration, -- integer acceleration factor (negative
846 The event handler is called after all default calculations
847 are made, so the custom on_step handler can override things
848 like speed, acceleration, player attachment. The handler will
849 likely be called many times per second, so the function needs
850 to make sure that the event is handled properly.
855 The key API allows mods to add key functionality to nodes that have
856 ownership or specific permissions. Using the API will make it so
857 that a node owner can use skeleton keys on their nodes to create keys
858 for that node in that location, and give that key to other players,
859 allowing them some sort of access that they otherwise would not have
860 due to node protection.
862 To make your new nodes work with the key API, you need to register
863 two callback functions in each nodedef:
866 `on_key_use(pos, player)`
867 * Is called when a player right-clicks (uses) a normal key on your
869 * `pos` - position of the node
870 * `player` - PlayerRef
871 * return value: none, ignored
873 The `on_key_use` callback should validate that the player is wielding
874 a key item with the right key meta secret. If needed the code should
875 deny access to the node functionality.
877 If formspecs are used, the formspec callbacks should duplicate these
878 checks in the metadata callback functions.
881 `on_skeleton_key_use(pos, player, newsecret)`
883 * Is called when a player right-clicks (uses) a skeleton key on your
885 * `pos` - position of the node
886 * `player` - PlayerRef
887 * `newsecret` - a secret value(string)
889 * `secret` - `nil` or the secret value that unlocks the door
890 * `name` - a string description of the node ("a locked chest")
891 * `owner` - name of the node owner
893 The `on_skeleton_key_use` function should validate that the player has
894 the right permissions to make a new key for the item. The newsecret
895 value is useful if the node has no secret value. The function should
896 store this secret value somewhere so that in the future it may compare
897 key secrets and match them to allow access. If a node already has a
898 secret value, the function should return that secret value instead
899 of the newsecret value. The secret value stored for the node should
900 not be overwritten, as this would invalidate existing keys.
902 Aside from the secret value, the function should retun a descriptive
903 name for the node and the owner name. The return values are all
904 encoded in the key that will be given to the player in replacement
905 for the wielded skeleton key.
907 if `nil` is returned, it is assumed that the wielder did not have
908 permissions to create a key for this node, and no key is created.