New hud_elem_type field
This commit is contained in:
parent
4739958926
commit
c80648b8cd
@ -38,6 +38,13 @@ local ICON_FRAME_SIZE = 2.2
|
|||||||
local S = minetest.get_translator("rp_achievements")
|
local S = minetest.get_translator("rp_achievements")
|
||||||
local NS = function(s) return s end
|
local NS = function(s) return s end
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
achievements = {}
|
achievements = {}
|
||||||
achievements.ACHIEVEMENT_GOTTEN = 1
|
achievements.ACHIEVEMENT_GOTTEN = 1
|
||||||
achievements.ACHIEVEMENT_IN_PROGRESS = 2
|
achievements.ACHIEVEMENT_IN_PROGRESS = 2
|
||||||
@ -209,7 +216,7 @@ local achievement_popup = function(player_name, icon_type, icon, caption, messag
|
|||||||
|
|
||||||
-- Background
|
-- Background
|
||||||
local hud_bg = player:hud_add({
|
local hud_bg = player:hud_add({
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
text = "rp_achievements_hud_bg.png",
|
text = "rp_achievements_hud_bg.png",
|
||||||
position = { x = 0.5, y = 0 },
|
position = { x = 0.5, y = 0 },
|
||||||
alignment = { x = 0, y = 1 },
|
alignment = { x = 0, y = 1 },
|
||||||
@ -237,7 +244,7 @@ local achievement_popup = function(player_name, icon_type, icon, caption, messag
|
|||||||
end
|
end
|
||||||
|
|
||||||
local hud_icon = player:hud_add({
|
local hud_icon = player:hud_add({
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
text = "("..icon_texture..")^[resize:"..HUD_ICON_SIZE.."x"..HUD_ICON_SIZE,
|
text = "("..icon_texture..")^[resize:"..HUD_ICON_SIZE.."x"..HUD_ICON_SIZE,
|
||||||
position = { x = 0.5, y = 0 },
|
position = { x = 0.5, y = 0 },
|
||||||
alignment = { x = 1, y = 1 },
|
alignment = { x = 1, y = 1 },
|
||||||
@ -248,7 +255,7 @@ local achievement_popup = function(player_name, icon_type, icon, caption, messag
|
|||||||
|
|
||||||
-- Caption text
|
-- Caption text
|
||||||
local hud_caption = player:hud_add({
|
local hud_caption = player:hud_add({
|
||||||
hud_elem_type = "text",
|
[hud_def_type_field] = "text",
|
||||||
number = caption_color or 0xFFFFFF,
|
number = caption_color or 0xFFFFFF,
|
||||||
text = caption,
|
text = caption,
|
||||||
position = { x = 0.5, y = 0 },
|
position = { x = 0.5, y = 0 },
|
||||||
@ -262,7 +269,7 @@ local achievement_popup = function(player_name, icon_type, icon, caption, messag
|
|||||||
|
|
||||||
-- Message text
|
-- Message text
|
||||||
local hud_message = player:hud_add({
|
local hud_message = player:hud_add({
|
||||||
hud_elem_type = "text",
|
[hud_def_type_field] = "text",
|
||||||
number = message_color or 0xFFFFFF,
|
number = message_color or 0xFFFFFF,
|
||||||
text = message,
|
text = message,
|
||||||
position = { x = 0.5, y = 0 },
|
position = { x = 0.5, y = 0 },
|
||||||
|
@ -8,6 +8,13 @@ local NS = function(s) return s end
|
|||||||
|
|
||||||
local mod_player_skins = minetest.get_modpath("rp_player_skins") ~= nil
|
local mod_player_skins = minetest.get_modpath("rp_player_skins") ~= nil
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
-- Gain for equip/unequip sounds
|
-- Gain for equip/unequip sounds
|
||||||
local SOUND_GAIN = 0.4
|
local SOUND_GAIN = 0.4
|
||||||
|
|
||||||
@ -392,7 +399,7 @@ local armor_icon_definitions = {}
|
|||||||
|
|
||||||
for a=1, #armor.slots do
|
for a=1, #armor.slots do
|
||||||
armor_icon_definitions[a] = {
|
armor_icon_definitions[a] = {
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
position = { x=0.5, y=1 },
|
position = { x=0.5, y=1 },
|
||||||
text = "blank.png",
|
text = "blank.png",
|
||||||
direction = 0,
|
direction = 0,
|
||||||
|
@ -4,6 +4,13 @@ rp_hud = {}
|
|||||||
|
|
||||||
rp_hud.registered_statbars = {}
|
rp_hud.registered_statbars = {}
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
-- time in seconds the breath bar will still show after going full again
|
-- time in seconds the breath bar will still show after going full again
|
||||||
local BREATH_KEEP_TIME = 2.05
|
local BREATH_KEEP_TIME = 2.05
|
||||||
|
|
||||||
@ -304,7 +311,7 @@ end
|
|||||||
-- * z_index: Statbar Z-index (see lua_api.md)
|
-- * z_index: Statbar Z-index (see lua_api.md)
|
||||||
rp_hud.register_statbar = function(name, def)
|
rp_hud.register_statbar = function(name, def)
|
||||||
local statbar_definition = {
|
local statbar_definition = {
|
||||||
hud_elem_type = "statbar",
|
[hud_def_type_fields] = "statbar",
|
||||||
position = { x=0.5, y=1 },
|
position = { x=0.5, y=1 },
|
||||||
text = def.image,
|
text = def.image,
|
||||||
text2 = def.image_gone,
|
text2 = def.image_gone,
|
||||||
|
@ -40,6 +40,13 @@ local EATING_SPEED_DURATION = 2.0
|
|||||||
local mod_achievements = minetest.get_modpath("rp_achievements") ~= nil
|
local mod_achievements = minetest.get_modpath("rp_achievements") ~= nil
|
||||||
local mod_death_messages = minetest.get_modpath("rp_death_messages") ~= nil
|
local mod_death_messages = minetest.get_modpath("rp_death_messages") ~= nil
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
-- Per-player userdata
|
-- Per-player userdata
|
||||||
|
|
||||||
local userdata = {}
|
local userdata = {}
|
||||||
@ -180,7 +187,7 @@ local function update_bar(player)
|
|||||||
else
|
else
|
||||||
player_debughud[name] = player:hud_add(
|
player_debughud[name] = player:hud_add(
|
||||||
{
|
{
|
||||||
hud_elem_type = "text",
|
[hud_def_type_field] = "text",
|
||||||
position = {x=0.75,y=1.0},
|
position = {x=0.75,y=1.0},
|
||||||
text = text,
|
text = text,
|
||||||
number = 0xFFFFFFFF,
|
number = 0xFFFFFFFF,
|
||||||
@ -201,7 +208,7 @@ local function update_bar(player)
|
|||||||
else
|
else
|
||||||
player_bar[name] = player:hud_add(
|
player_bar[name] = player:hud_add(
|
||||||
{
|
{
|
||||||
hud_elem_type = "statbar",
|
[hud_def_type_field] = "statbar",
|
||||||
position = {x=0.5,y=1.0},
|
position = {x=0.5,y=1.0},
|
||||||
text = "hunger.png",
|
text = "hunger.png",
|
||||||
text2 = "hunger_gone.png",
|
text2 = "hunger_gone.png",
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
local S = minetest.get_translator("rp_player_effects")
|
local S = minetest.get_translator("rp_player_effects")
|
||||||
local DISPLAY_ICONS = false
|
local DISPLAY_ICONS = false
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
player_effects = {}
|
player_effects = {}
|
||||||
|
|
||||||
player_effects.effects = {}
|
player_effects.effects = {}
|
||||||
@ -51,7 +58,7 @@ local function display_effect_icons(player)
|
|||||||
local effect = player_effects.get_registered_effect(en)
|
local effect = player_effects.get_registered_effect(en)
|
||||||
if effect.icon then
|
if effect.icon then
|
||||||
local id = player:hud_add({
|
local id = player:hud_add({
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
position = { x = 1, y = 0 },
|
position = { x = 1, y = 0 },
|
||||||
offset = { x = -52 - i*52, y = 270 },
|
offset = { x = -52 - i*52, y = 270 },
|
||||||
text = effect.icon,
|
text = effect.icon,
|
||||||
|
@ -12,6 +12,13 @@ local settings = {
|
|||||||
}
|
}
|
||||||
local spyglass_users = {}
|
local spyglass_users = {}
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
rp_spyglass = {}
|
rp_spyglass = {}
|
||||||
|
|
||||||
-- check if player is using spyglass
|
-- check if player is using spyglass
|
||||||
@ -57,7 +64,7 @@ local function use_spyglass(player)
|
|||||||
local data = {
|
local data = {
|
||||||
hud = settings.use_hud and player:hud_add({
|
hud = settings.use_hud and player:hud_add({
|
||||||
name = "tph_spyglass",
|
name = "tph_spyglass",
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
text = "tph_spyglass_hud.png", -- image is 52x32, any texture pack or edit to the image should have a resolution that properly factors to said resolution or width = height*1.625
|
text = "tph_spyglass_hud.png", -- image is 52x32, any texture pack or edit to the image should have a resolution that properly factors to said resolution or width = height*1.625
|
||||||
position = {x = 0.5, y = 0.5},
|
position = {x = 0.5, y = 0.5},
|
||||||
scale = { x = -100, y = -100},
|
scale = { x = -100, y = -100},
|
||||||
|
@ -4,9 +4,16 @@
|
|||||||
|
|
||||||
local enable_vignette = minetest.settings:get_bool("vignette_enable")
|
local enable_vignette = minetest.settings:get_bool("vignette_enable")
|
||||||
|
|
||||||
|
local hud_def_type_field
|
||||||
|
if minetest.features.hud_def_type_field then
|
||||||
|
hud_def_type_field = "type"
|
||||||
|
else
|
||||||
|
hud_def_type_field = "hud_elem_type"
|
||||||
|
end
|
||||||
|
|
||||||
if enable_vignette then
|
if enable_vignette then
|
||||||
local vignette_definition = {
|
local vignette_definition = {
|
||||||
hud_elem_type = "image",
|
[hud_def_type_field] = "image",
|
||||||
position = {x = 0.5, y = 0.5},
|
position = {x = 0.5, y = 0.5},
|
||||||
scale = {x = -100, y = -100},
|
scale = {x = -100, y = -100},
|
||||||
alignment = 0,
|
alignment = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user