Skip to content

Commit

Permalink
Merge pull request #18 from SwissalpS/HUDtypeUpdate
Browse files Browse the repository at this point in the history
HUD type update and some more deprication warning silencing
  • Loading branch information
SwissalpS authored Jul 18, 2024
2 parents 7e52747 + ee6e163 commit 299b4ee
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
14 changes: 8 additions & 6 deletions huds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local HUD_POSITION = { x = postool.hudPosX, y = postool.hudPosY }
local HUD_ALIGNMENT = { x = 1, y = 0 }
local HUD_SCALE = { x = 100, y = 100 }
local HUD_STATBAR_SIZE = { x = 160, y = 18 }
local HUD_TYPE_FIELD = minetest.features.hud_def_type_field
and 'type' or 'hud_elem_type'

-- hud id map { playername = {
-- tIDs = { <hud-ids[table]> },
Expand Down Expand Up @@ -236,7 +238,7 @@ postool.rebuildHud = function(oPlayer)

if nil == iID then
tIDs.meseconsUsageFG = oPlayer:hud_add({
hud_elem_type = 'statbar',
[HUD_TYPE_FIELD] = 'statbar',
name = 'postoolMeseconsUsageFG',
position = tPosition,
offset = { x = -2, y = iY - 27 },
Expand All @@ -248,7 +250,7 @@ postool.rebuildHud = function(oPlayer)
z_index = postool.hudPosZ,
})
tIDs.meseconsPenalty = oPlayer:hud_add({
hud_elem_type = 'text',
[HUD_TYPE_FIELD] = 'text',
name = 'postoolMeseconsPenalty',
position = tPosition,
offset = { x = 0, y = -16 },
Expand Down Expand Up @@ -280,7 +282,7 @@ postool.rebuildHud = function(oPlayer)
if tb[4] then
if nil == iID then
tIDs.block = oPlayer:hud_add({
hud_elem_type = 'text',
[HUD_TYPE_FIELD] = 'text',
name = 'postoolBlock',
position = tPosition,
offset = { x = 0, y = iY },
Expand Down Expand Up @@ -308,7 +310,7 @@ postool.rebuildHud = function(oPlayer)

if nil == iID then
tIDs.node = oPlayer:hud_add({
hud_elem_type = 'text',
[HUD_TYPE_FIELD] = 'text',
name = 'postoolNode',
position = tPosition,
offset = { x = 0, y = iY },
Expand Down Expand Up @@ -336,7 +338,7 @@ postool.rebuildHud = function(oPlayer)

if nil == iID then
tIDs.time = oPlayer:hud_add({
hud_elem_type = 'text',
[HUD_TYPE_FIELD] = 'text',
name = 'postoolTime',
position = tPosition,
offset = { x = 0, y = iY },
Expand Down Expand Up @@ -364,7 +366,7 @@ postool.rebuildHud = function(oPlayer)

if nil == iID then
tIDs.trainTime = oPlayer:hud_add({
hud_elem_type = 'text',
[HUD_TYPE_FIELD] = 'text',
name = 'postoolTrainTime',
position = tPosition,
offset = { x = 0, y = iY },
Expand Down
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function S(s) return s end

--settings
postool = {
version = 20240316.2149,
version = 20240718.2107,
S = S,
-- Position of hud
hudPosX = tonumber(minetest.settings:get('postool.hud.offsetx') or 0.8),
Expand Down
40 changes: 24 additions & 16 deletions tool.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- backward compatibility for use_texture_alpha field of node def
local USE_ALPHA_VALUE = minetest.features.use_texture_alpha_string_modes
and 'clip' or true

-- keep track of blocks that are lit up to reduce
-- griefing of players with weak GPUs. Only when
-- using vizlib
Expand Down Expand Up @@ -276,14 +280,16 @@ end -- show
-- display entity shown when postool is used
minetest.register_entity('postool:display', {

physical = false,
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = 'wielditem',
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = { x = 0.67, y = 0.67 },
textures = {'postool:display_node'},
initial_properties = {
physical = false,
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = 'wielditem',
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = { x = 0.67, y = 0.67 },
textures = {'postool:display_node'},
glow = 10,
},
timer = 0,
glow = 10,

on_step = function(self, dtime)

Expand All @@ -302,14 +308,16 @@ minetest.register_entity('postool:display', {
-- display entity shown when postool is used near a chunk border
minetest.register_entity('postool:display_chunk', {

physical = false,
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = 'wielditem',
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = { x = 0.67, y = 0.67 },
textures = {'postool:display_chunk_node'},
initial_properties = {
physical = false,
collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = 'wielditem',
-- wielditem seems to be scaled to 1.5 times original node size
visual_size = { x = 0.67, y = 0.67 },
textures = {'postool:display_chunk_node'},
glow = 10,
},
timer = 0,
glow = 10,

on_step = function(self, dtime)

Expand All @@ -329,7 +337,7 @@ minetest.register_entity('postool:display_chunk', {
minetest.register_node('postool:display_node', {

tiles = { 'postool_display.png' },
use_texture_alpha = true,
use_texture_alpha = USE_ALPHA_VALUE,
walkable = false,
drawtype = 'nodebox',
node_box = {
Expand Down Expand Up @@ -372,7 +380,7 @@ minetest.register_node('postool:display_node', {
minetest.register_node('postool:display_chunk_node', {

tiles = { 'postool_display.png' },
use_texture_alpha = true,
use_texture_alpha = USE_ALPHA_VALUE,
walkable = false,
color = '#0fff0f', --#ff0f0f',
drawtype = 'nodebox',
Expand Down

0 comments on commit 299b4ee

Please sign in to comment.