Hud für eine begrenzte zeit anzeigen

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

Hud für eine begrenzte zeit anzeigen

by niwla23 » Tue Jan 22, 2019 19:11

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: 77
Joined: Sat Jul 30, 2016 14:23
GitHub: acmgit
In-game: clyde

Re: Hud für eine begrenzte zeit anzeigen

by Clyde » Tue Jan 22, 2019 20:12

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.
 


Return to Deutsch



Who is online

Users browsing this forum: No registered users and 1 guest