@@ -401,6 +401,43 @@ Currently supported flags: absheight
401
401
Also produce this same ore between the height range of -height_max and -height_min.
402
402
Useful for having ore in sky realms without having to duplicate ore entries.
403
403
404
+ HUD element types
405
+ -------------------
406
+ The position field is used for all element types.
407
+ To account for differing resolutions, the position coordinates are the percentage of the screen,
408
+ ranging in value from 0 to 1.
409
+ The name field is not yet used, but should contain a description of what the HUD element represents.
410
+ Below are the specific uses for fields in each type; fields not listed for that type are ignored.
411
+
412
+ Note: Future revisions to the HUD API may be incompatible; the HUD API is still in the experimental stages.
413
+
414
+ - image
415
+ Displays an image on the HUD.
416
+ - scale: The scale of the image, with 1 being the original texture size.
417
+ Only the X coordinate scale is used.
418
+ - text: The name of the texture that is displayed.
419
+ - text
420
+ Displays text on the HUD.
421
+ - scale: Defines the bounding rectangle of the text.
422
+ A value such as {x=100, y=100} should work.
423
+ - text: The text to be displayed in the HUD element.
424
+ - number: An integer containing the RGB value of the color used to draw the text.
425
+ Specify 0xFFFFFF for white text, 0xFF0000 for red, and so on.
426
+ - statbar
427
+ Displays a horizontal bar made up of half-images.
428
+ - text: The name of the texture that is used.
429
+ - number: The number of half-textures that are displayed.
430
+ If odd, will end with a vertically center-split texture.
431
+ - inventory
432
+ - text: The name of the inventory list to be displayed.
433
+ - number: Number of items in the inventory to be displayed.
434
+ - item: Position of item that is selected.
435
+ - direction: Direction in which the inventory list is drawn.
436
+ 0 draws from left to right,
437
+ 1 draws from right to left,
438
+ 2 draws from top to bottom, and
439
+ 3 draws from bottom to top.
440
+
404
441
Representations of simple things
405
442
--------------------------------
406
443
Position/vector:
@@ -1379,19 +1416,11 @@ Player-only: (no-op for other objects)
1379
1416
modifies per-player walking speed, jump height, and gravity.
1380
1417
Values default to 1 and act as offsets to the physics settings
1381
1418
in minetest.conf. nil will keep the current setting.
1382
- - hud_add(id, hud definition)
1383
- ^ id is used for later reference
1384
- ^ If this id has already been used, it will reset its drawform
1385
- - hud_rm(id): remove an id from the lua hud
1386
- - hud_change(id, stat, value): change a value of a previously added element
1387
- ^ stat/table key: 0/position, 1/name, 2/scale, 3/text, 4/number,
1388
- ^ 5/item, 6/dir
1389
- - hud_get_next_id(): get the next available id for a hud element
1390
- - hud_lock_next_bar(right): add a non-conflicting statbar
1391
- ^ if right, will claim spot on right side, rather then left
1392
- ^ returns element id on success, false otherwise
1393
- - hud_unlock_bar(id): remove a non-conflicting statbar
1394
- ^ id is the value returned by calling hud_lock_next_bar()
1419
+ - hud_add(hud definition): add a HUD element described by HUD def, returns ID number on success
1420
+ - hud_remove(id): remove the HUD element of the specified id
1421
+ - hud_change(id, stat, value): change a value of a previously added HUD element
1422
+ ^ element stat values: position, name, scale, text, number, item, dir
1423
+ - hud_get(id): gets the HUD element definition structure of the specified ID
1395
1424
1396
1425
InvRef: Reference to an inventory
1397
1426
methods:
@@ -1815,20 +1844,18 @@ Detached inventory callbacks
1815
1844
^ No return value
1816
1845
}
1817
1846
1818
- HUD Definition (hud_add)
1847
+ HUD Definition (hud_add, hud_get )
1819
1848
{
1820
- type = "I", -- One of "I"(image), "S"(statbar),
1821
- ^ "T"(text), "i"(inv)
1822
- position = {x=0.5, y=0.5}, -- Left corner position
1849
+ type = "image",
1850
+ ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
1851
+ position = {x=0.5, y=0.5},
1852
+ ^ Left corner position of element
1823
1853
name = "<name>",
1824
1854
scale = {x=2, y=2},
1825
1855
text = "<text>",
1826
- ^ Used as texture name for statbars and images, and as list name
1827
- ^ for inv
1828
1856
number = 2,
1829
- ^ Used as stat for statbar, and as # of items for inv
1830
- item = 3, -- Selected item in inv. 0 -> no item selected
1857
+ item = 3,
1858
+ ^ Selected item in inventory. 0 for no item selected.
1831
1859
dir = 0,
1832
- ^ dir/inv direction: 0/left-right, 1/right-left,
1833
- ^ 2/top-bottom, 3/bottom-top
1860
+ ^ Direction: 0: left-right, 1: right-left, 2: top-bottom, 3: bottom-top
1834
1861
}
0 commit comments