aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt80
1 files changed, 75 insertions, 5 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 285f3d205..44b2a0b63 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -401,6 +401,43 @@ Currently supported flags: absheight
Also produce this same ore between the height range of -height_max and -height_min.
Useful for having ore in sky realms without having to duplicate ore entries.
+HUD element types
+-------------------
+The position field is used for all element types.
+To account for differing resolutions, the position coordinates are the percentage of the screen,
+ranging in value from 0 to 1.
+The name field is not yet used, but should contain a description of what the HUD element represents.
+Below are the specific uses for fields in each type; fields not listed for that type are ignored.
+
+Note: Future revisions to the HUD API may be incompatible; the HUD API is still in the experimental stages.
+
+- image
+ Displays an image on the HUD.
+ - scale: The scale of the image, with 1 being the original texture size.
+ Only the X coordinate scale is used.
+ - text: The name of the texture that is displayed.
+- text
+ Displays text on the HUD.
+ - scale: Defines the bounding rectangle of the text.
+ A value such as {x=100, y=100} should work.
+ - text: The text to be displayed in the HUD element.
+ - number: An integer containing the RGB value of the color used to draw the text.
+ Specify 0xFFFFFF for white text, 0xFF0000 for red, and so on.
+- statbar
+ Displays a horizontal bar made up of half-images.
+ - text: The name of the texture that is used.
+ - number: The number of half-textures that are displayed.
+ If odd, will end with a vertically center-split texture.
+- inventory
+ - text: The name of the inventory list to be displayed.
+ - number: Number of items in the inventory to be displayed.
+ - item: Position of item that is selected.
+ - direction: Direction in which the inventory list is drawn.
+ 0 draws from left to right,
+ 1 draws from right to left,
+ 2 draws from top to bottom, and
+ 3 draws from bottom to top.
+
Representations of simple things
--------------------------------
Position/vector:
@@ -1002,10 +1039,23 @@ minetest.get_craft_recipe(output) -> input
^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
stack 5, stack 6, stack 7, stack 8, stack 9 }
^ input.items = nil if no recipe found
-minetest.get_all_craft_recipes(output) -> table or nil
-^ returns table with all registered recipes for output item (node)
-^ returns nil if no recipe was found
-^ table entries have same format as minetest.get_craft_recipe
+minetest.get_all_craft_recipes(query item) -> table or nil
+^ returns indexed table with all registered recipes for query item (node)
+ or nil if no recipe was found
+ recipe entry table:
+ {
+ method = 'normal' or 'cooking' or 'fuel'
+ width = 0-3, 0 means shapeless recipe
+ items = indexed [1-9] table with recipe items
+ output = string with item name and quantity
+ }
+ Example query for default:gold_ingot will return table:
+ {
+ 1={type = "cooking", width = 3, output = "default:gold_ingot",
+ items = {1 = "default:gold_lump"}},
+ 2={type = "normal", width = 1, output = "default:gold_ingot 9",
+ items = {1 = "default:goldblock"}}
+ }
minetest.handle_node_drops(pos, drops, digger)
^ drops: list of itemstrings
^ Handles drops from nodes after digging: Default action is to put them into
@@ -1366,7 +1416,12 @@ Player-only: (no-op for other objects)
modifies per-player walking speed, jump height, and gravity.
Values default to 1 and act as offsets to the physics settings
in minetest.conf. nil will keep the current setting.
-
+- hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success
+- hud_remove(id): remove the HUD element of the specified id
+- hud_change(id, stat, value): change a value of a previously added HUD element
+ ^ element stat values: position, name, scale, text, number, item, dir
+- hud_get(id): gets the HUD element definition structure of the specified ID
+
InvRef: Reference to an inventory
methods:
- is_empty(listname): return true if list is empty
@@ -1789,3 +1844,18 @@ Detached inventory callbacks
^ No return value
}
+HUD Definition (hud_add, hud_get)
+{
+ type = "image",
+ ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
+ position = {x=0.5, y=0.5},
+ ^ Left corner position of element
+ name = "<name>",
+ scale = {x=2, y=2},
+ text = "<text>",
+ number = 2,
+ item = 3,
+ ^ Selected item in inventory. 0 for no item selected.
+ dir = 0,
+ ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
+}