mirror of
https://github.com/minetest/minetest.git
synced 2024-12-22 14:12:24 +01:00
Rename hud_elem_type
to type
(#14065)
This commit is contained in:
parent
bc336480e6
commit
467d3a8c62
@ -29,6 +29,7 @@ core.features = {
|
||||
compress_zstd = true,
|
||||
sound_params_start_time = true,
|
||||
physics_overrides_v2 = true,
|
||||
hud_def_type_field = true,
|
||||
}
|
||||
|
||||
function core.has_feature(arg)
|
||||
|
@ -3,7 +3,7 @@ local enable_damage = core.settings:get_bool("enable_damage")
|
||||
|
||||
local bar_definitions = {
|
||||
hp = {
|
||||
hud_elem_type = "statbar",
|
||||
type = "statbar",
|
||||
position = {x = 0.5, y = 1},
|
||||
text = "heart.png",
|
||||
text2 = "heart_gone.png",
|
||||
@ -14,7 +14,7 @@ local bar_definitions = {
|
||||
offset = {x = (-10 * 24) - 25, y = -(48 + 24 + 16)},
|
||||
},
|
||||
breath = {
|
||||
hud_elem_type = "statbar",
|
||||
type = "statbar",
|
||||
position = {x = 0.5, y = 1},
|
||||
text = "bubble.png",
|
||||
text2 = "bubble_gone.png",
|
||||
@ -139,7 +139,7 @@ end
|
||||
|
||||
function core.hud_replace_builtin(hud_name, definition)
|
||||
if type(definition) ~= "table" or
|
||||
definition.hud_elem_type ~= "statbar" then
|
||||
(definition.type or definition.hud_elem_type) ~= "statbar" then
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ end)
|
||||
core.after(1, function()
|
||||
print("armor: " .. dump(core.localplayer:get_armor_groups()))
|
||||
id = core.localplayer:hud_add({
|
||||
hud_elem_type = "text",
|
||||
type = "text",
|
||||
name = "example",
|
||||
number = 0xff0000,
|
||||
position = {x=0, y=1},
|
||||
|
@ -1332,8 +1332,10 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
|
||||
|
||||
```lua
|
||||
{
|
||||
hud_elem_type = "image", -- see HUD element types, default "text"
|
||||
type = "image", -- see HUD element types, default "text"
|
||||
-- ^ type of HUD element, can be either of "image", "text", "statbar", or "inventory"
|
||||
hud_elem_type = "image",
|
||||
-- ^ Deprecated, same as `type`. In case both are specified `type` will be used.
|
||||
position = {x=0.5, y=0.5},
|
||||
-- ^ Left corner position of element, default `{x=0,y=0}`.
|
||||
name = "<name>", -- default ""
|
||||
|
@ -5278,6 +5278,8 @@ Utilities
|
||||
-- liquid_fluidity, liquid_fluidity_smooth, liquid_sink,
|
||||
-- acceleration_default, acceleration_air (5.8.0)
|
||||
physics_overrides_v2 = true,
|
||||
-- In HUD definitions the field `type` is used and `hud_elem_type` is deprecated (5.9.0)
|
||||
hud_def_type_field = true,
|
||||
}
|
||||
```
|
||||
|
||||
@ -7790,7 +7792,7 @@ child will follow movement and rotation of that bone.
|
||||
* `hud_change(id, stat, value)`: change a value of a previously added HUD
|
||||
element.
|
||||
* `stat` supports the same keys as in the hud definition table except for
|
||||
`"hud_elem_type"`.
|
||||
`"type"` (or the deprecated `"hud_elem_type"`).
|
||||
* `hud_get(id)`: gets the HUD element definition structure of the specified ID
|
||||
* `hud_set_flags(flags)`: sets specified HUD flags of player.
|
||||
* `flags`: A table with the following fields set to boolean values
|
||||
@ -10050,9 +10052,14 @@ Used by `ObjectRef:hud_add`. Returned by `ObjectRef:hud_get`.
|
||||
|
||||
```lua
|
||||
{
|
||||
hud_elem_type = "image",
|
||||
type = "image",
|
||||
-- Type of element, can be "image", "text", "statbar", "inventory",
|
||||
-- "waypoint", "image_waypoint", "compass" or "minimap"
|
||||
-- If undefined "text" will be used.
|
||||
|
||||
hud_elem_type = "image",
|
||||
-- Deprecated, same as `type`.
|
||||
-- In case both are specified `type` will be used.
|
||||
|
||||
position = {x=0.5, y=0.5},
|
||||
-- Top left corner position of element
|
||||
|
@ -66,7 +66,7 @@ minetest.register_globalstep(function()
|
||||
local ent = pointed_thing.ref:get_luaentity()
|
||||
if ent and ent.name == "testentities:selectionbox" then
|
||||
hud_ids[pname] = hud_id or player:hud_add({
|
||||
hud_elem_type = "text", -- See HUD element types
|
||||
type = "text", -- See HUD element types
|
||||
position = {x=0.5, y=0.5},
|
||||
text = "X",
|
||||
number = 0xFF0000,
|
||||
|
@ -12,7 +12,7 @@ local font_states = {
|
||||
|
||||
|
||||
local font_default_def = {
|
||||
hud_elem_type = "text",
|
||||
type = "text",
|
||||
position = {x = 0.5, y = 0.5},
|
||||
scale = {x = 2, y = 2},
|
||||
alignment = { x = 0, y = 0 },
|
||||
@ -102,14 +102,14 @@ minetest.register_chatcommand("hudwaypoints", {
|
||||
return false
|
||||
end
|
||||
local regular = player:hud_add {
|
||||
hud_elem_type = "waypoint",
|
||||
type = "waypoint",
|
||||
name = "regular waypoint",
|
||||
text = "m",
|
||||
number = 0xFFFFFF,
|
||||
world_pos = vector.add(player:get_pos(), {x = 0, y = 1.5, z = 0})
|
||||
}
|
||||
local reduced_precision = player:hud_add {
|
||||
hud_elem_type = "waypoint",
|
||||
type = "waypoint",
|
||||
name = "imprecise waypoint",
|
||||
text = "m (0.1 steps, precision = 10)",
|
||||
precision = 10,
|
||||
@ -117,7 +117,7 @@ minetest.register_chatcommand("hudwaypoints", {
|
||||
world_pos = vector.add(player:get_pos(), {x = 0, y = 1, z = 0})
|
||||
}
|
||||
local hidden_distance = player:hud_add {
|
||||
hud_elem_type = "waypoint",
|
||||
type = "waypoint",
|
||||
name = "waypoint with hidden distance",
|
||||
text = "this text is hidden as well (precision = 0)",
|
||||
precision = 0,
|
||||
@ -149,7 +149,7 @@ minetest.register_chatcommand("hudwaypoints", {
|
||||
minetest.after(0.5, change, player)
|
||||
end
|
||||
local image_waypoint = player:hud_add {
|
||||
hud_elem_type = "image_waypoint",
|
||||
type = "image_waypoint",
|
||||
text = "testhud_waypoint.png",
|
||||
world_pos = player:get_pos(),
|
||||
scale = {x = 3, y = 3},
|
||||
|
@ -1959,8 +1959,28 @@ void push_objectRef(lua_State *L, const u16 id)
|
||||
|
||||
void read_hud_element(lua_State *L, HudElement *elem)
|
||||
{
|
||||
elem->type = (HudElementType)getenumfield(L, 2, "hud_elem_type",
|
||||
es_HudElementType, HUD_ELEM_TEXT);
|
||||
std::string type_string;
|
||||
bool has_type = getstringfield(L, 2, "type", type_string);
|
||||
|
||||
// Handle deprecated hud_elem_type
|
||||
std::string deprecated_type_string;
|
||||
if (getstringfield(L, 2, "hud_elem_type", deprecated_type_string)) {
|
||||
if (has_type && deprecated_type_string != type_string) {
|
||||
log_deprecated(L, "Ambiguous HUD element fields \"type\" and \"hud_elem_type\", "
|
||||
"\"type\" will be used.", 1, true);
|
||||
} else {
|
||||
has_type = true;
|
||||
type_string = deprecated_type_string;
|
||||
log_deprecated(L, "Deprecated \"hud_elem_type\" field, use \"type\" instead.",
|
||||
1, true);
|
||||
}
|
||||
}
|
||||
|
||||
int type_enum;
|
||||
if (has_type && string_to_enum(es_HudElementType, type_enum, type_string))
|
||||
elem->type = static_cast<HudElementType>(type_enum);
|
||||
else
|
||||
elem->type = HUD_ELEM_TEXT;
|
||||
|
||||
lua_getfield(L, 2, "position");
|
||||
elem->pos = lua_istable(L, -1) ? read_v2f(L, -1) : v2f();
|
||||
|
Loading…
Reference in New Issue
Block a user