Merge pull request 'Pumpkin hud' (#1754) from pumpkin_hud into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1754
This commit is contained in:
Elias Fleckenstein 2021-06-08 11:06:22 +00:00
commit 4324e97db0
3 changed files with 45 additions and 1 deletions

View File

@ -121,8 +121,52 @@ pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman"
pumpkin_face_base_def._mcl_armor_element = "head" pumpkin_face_base_def._mcl_armor_element = "head"
pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png" pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png"
pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png" pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png"
if minetest.get_modpath("mcl_armor") then if minetest.get_modpath("mcl_armor") then
local pumpkin_hud = {}
local function add_pumpkin_hud(player)
pumpkin_hud[player] = {
pumpkin_blur = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
scale = {x = -100, y = -100},
text = "mcl_farming_pumpkin_hud.png",
z_index = -200
}),
--this is a fake crosshair, because hotbar and crosshair doesn't support z_index
--TODO: remove this and add correct z_index values
fake_crosshair = player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
scale = {x = 1, y = 1},
text = "crosshair.png",
z_index = -100
})
}
end
local function remove_pumpkin_hud(player)
if pumpkin_hud[player] then
player:hud_remove(pumpkin_hud[player].pumpkin_blur)
player:hud_remove(pumpkin_hud[player].fake_crosshair)
pumpkin_hud[player] = nil
end
end
pumpkin_face_base_def.on_secondary_use = mcl_armor.equip_on_use pumpkin_face_base_def.on_secondary_use = mcl_armor.equip_on_use
pumpkin_face_base_def._on_equip = add_pumpkin_hud
pumpkin_face_base_def._on_unequip = remove_pumpkin_hud
minetest.register_on_joinplayer(function(player)
if player:get_inventory():get_stack("armor", 2):get_name() == "mcl_farming:pumpkin_face" then
add_pumpkin_hud(player)
end
end)
minetest.register_on_dieplayer(function(player)
remove_pumpkin_hud(player)
end)
minetest.register_on_leaveplayer(function(player)
pumpkin_hud[player] = nil
end)
end end
-- Register stem growth -- Register stem growth

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,4 +1,4 @@
# This file contains settings of MineClone 2that can be changed in # This file contains settings of MineClone 2 that can be changed in
# minetest.conf # minetest.conf
[World] [World]