Hud für eine begrenzte zeit anzeigen

German
Post Reply
User avatar
niwla23
Member
Posts: 118
Joined: Sat Nov 17, 2018 17:40
In-game: Niwla

Hud für eine begrenzte zeit anzeigen

by niwla23 » Post

Hallo, ich versuche einem Spieler einen HUD für 5 Sekunden anzuzeigen.Wie macht man das? Das hier geht nicht:

Code: Select all

minetest.register_node("parcour:endpoint", {
	description = "Zielpont",
	drawtype = "plantlike",
	waving = 0,
	tiles = {"checkpoint.png"},
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy = 5,},

  on_punch = function(pos, node, player, pointed_thing)
    -- place a random dry grass node
    minetest.chat_send_all(player:get_player_name().." Hat den parcour geschafft!")


    local idx = player:hud_add({
    hud_elem_type = "text",
    position  = {x = 1, y = 0.5},
    offset    = {x = -120, y = -25},
    text      = "Du hast den Parcour geschafft!",
    alignment = 0,
    scale     = { x = 100, y = 30},
    number    = 0xFF0000,

    minetest.after(5, func, player:remove_hud(idx)())


})
  end,

})
Viele Grüße, Niwla23

User avatar
Clyde
Member
Posts: 222
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

Re: Hud für eine begrenzte zeit anzeigen

by Clyde » Post

Code: Select all

minetest.register_node("parcour:endpoint", {
	description = "Zielpont",
	drawtype = "plantlike",
	waving = 0,
	tiles = {"checkpoint.png"},
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy = 5,},

  on_punch = function(pos, node, player, pointed_thing)
    -- place a random dry grass node
    minetest.chat_send_all(player:get_player_name().." Hat den parcour geschafft!")


    local idx = player:hud_add({
    hud_elem_type = "text",
    position  = {x = 1, y = 0.5},
    offset    = {x = -120, y = -25},
    text      = "Du hast den Parcour geschafft!",
    alignment = 0,
    scale     = { x = 100, y = 30},
    number    = 0xFF0000,
})
    minetest.after(5, function() player:hud_remove(idx) end)

  end,

})
Vorsicht, die Funktion heißt hud_remove() und nicht remove_hud() ;-)
und minetest.after() ist bei mir kein Teil der Beschreibung der Hud.

Gruß, Clyde.
My Server: Welcome to Zeitsprung - deadsoft.org:49152 Jungle The next Gundul - jungle-tng.deadsoft.org:49152

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests