X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=doc%2Flua_api.txt;h=7ba2ed0011fa69249cb9fed6321faa1213542686;hb=13358c29b8a754709c49b0ba997f029af26134bc;hp=61bc8e1c22b98a01d5babe4f72dad54aef42c63b;hpb=81554fbf720300e36060a628c786902918328612;p=oweals%2Fminetest.git diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 61bc8e1c2..7ba2ed001 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,4 +1,4 @@ -Minetest Lua Modding API Reference 0.4.dev +Minetest Lua Modding API Reference 0.4.4 ========================================== More information at http://c55.me/minetest/ @@ -254,9 +254,9 @@ Nodes are passed by value between Lua and the engine. They are represented by a table: {name="name", param1=num, param2=num} -param1 and param2 are 8 bit and 4 bit integers, respectively. The engine -uses them for certain automated functions. If you don't use these -functions, you can use them to store arbitrary values. +param1 and param2 are 8 bit integers. The engine uses them for certain +automated functions. If you don't use these functions, you can use them to +store arbitrary values. The functions of param1 and param2 are determined by certain fields in the node definition: @@ -280,6 +280,61 @@ param2 is reserved for the engine when any of these are used: Nodes can also contain extra data. See "Node Metadata". +Node drawtypes +--------------- +There are a bunch of different looking node types. These are mostly just +copied from Minetest 0.3; more may be made in the future. + +Look for examples in games/minimal or games/minetest_game. + +- normal +- airlike +- liquid +- flowingliquid +- glasslike +- allfaces +- allfaces_optional +- torchlike +- signlike +- plantlike +- fencelike +- raillike +- nodebox -- See below. EXPERIMENTAL + +Node boxes +----------- +Node selection boxes are defined using "node boxes" + +The "nodebox" node drawtype allows defining visual of nodes consisting of +arbitrary number of boxes. It allows defining stuff like stairs. Only the +"fixed" box type is supported for these. +^ Please note that this is still experimental, and may be incompatibly + changed in the future. + +A nodebox is defined as any of: +{ + -- A normal cube; the default in most things + type = "regular" +} +{ + -- A fixed box (facedir param2 is used, if applicable) + type = "fixed", + fixed = box OR {box1, box2, ...} +} +{ + -- A box like the selection box for torches + -- (wallmounted param2 is used, if applicable) + type = "wallmounted", + wall_top = box, + wall_bottom = box, + wall_side = box +} + +A box is defined as: + {x1, y1, z1, x2, y2, z2} +A box of a regular node would look like: + {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + Representations of simple things -------------------------------- Position/vector: @@ -287,6 +342,11 @@ Position/vector: Currently the API does not provide any helper functions for addition, subtraction and whatever; you can define those that you need yourself. +pointed_thing: + {type="nothing"} + {type="node", under=pos, above=pos} + {type="object", ref=ObjectRef} + Items ------ Node (register_node): @@ -363,7 +423,7 @@ effective towards. Groups in crafting recipes --------------------------- -An example: +An example: Make meat soup from any meat, any water and any bowl { output = 'food:meat_soup_raw', recipe = { @@ -371,7 +431,13 @@ An example: {'group:water'}, {'group:bowl'}, }, - preserve = {'group:bowl'}, -- Not implemented yet (TODO) + -- preserve = {'group:bowl'}, -- Not implemented yet (TODO) +} +An another example: Make red wool from white wool and red dye +{ + type = 'shapeless', + output = 'wool:red', + recipe = {'wool:white', 'group:dye,basecolor_red'}, } Special groups @@ -387,6 +453,13 @@ Special groups - 2: node is removed without tool wear after 0.5 seconds or so (rail, sign) - 3: node is removed without tool wear immediately (torch) +- disable_jump: Player (and possibly other things) cannot jump from node +- fall_damage_add_percent: damage speed = speed * (1 + value/100) +- bouncy: value is bounce speed in percent +- falling_node: if there is no walkable block under the node it will fall +- attached_node: if the node under it is not a walkable block the node will be + dropped as an item. If the node is wallmounted the + wallmounted direction is checked. Known damage and digging time defining groups ---------------------------------------------- @@ -612,32 +685,85 @@ Examples: Elements: -invsize[,;] +size[,] ^ Define the size of the menu in inventory slots +^ deprecated: invsize[,;] list[;;,;,;] +list[;;,;,;] ^ Show an inventory list image[,;,;] ^ Show an image ^ Position and size units are inventory slots +item_image[,;,;] +^ Show an inventory image of registered item/node +^ Position and size units are inventory slots + +background[,;,;] +^ Use a background. Inventory rectangles are not drawn then. +^ Position and size units are inventory slots +^ Example for formspec 8x4 in 16x resolution: image shall be sized 8*16px x 4*16px + field[,;,;;