[Solved] How do I use hud_add?
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
[Solved] How do I use hud_add?
I am having problems using hud_add to change a menu state. When I use a register on join player, passing in function(player) into a player:hud_add works, but when I do it from register on chat message, hud_add comes up as a null even when I pass in player the same way. Whoever helps will be credited in my project.
Last edited by ChristienChapman on Tue Jun 28, 2022 22:17, edited 1 time in total.
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
- rubenwardy
- Moderator
- Posts: 6972
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: How do I use hud_add?
Hi, are you sure you have a player objectref and not just a name?
Code: Select all
minetest.register_chatcommand("hud", {
func = function(name, params)
local player = minetest.get_player_by_name(name)
if not player then
return false, "You need to be online"
end
player:hud_add({ ... })
end,
})
-
- Member
- Posts: 117
- Joined: Sat May 28, 2022 00:04
Re: How do I use hud_add?
Thanks the solution came to me lol. But now I am having a new problem, removing all hud ids I have added. : o
God bless you.
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
List of releases:
Minetest Zombies Minigame - viewtopic.php?f=9&t=28442&p=412633#p412633
- > cdb_1d60e1a03f83
- sirrobzeroone
- Member
- Posts: 593
- Joined: Mon Jul 16, 2018 07:56
- GitHub: sirrobzeroone
- Contact:
Re: [Solved] How do I use hud_add?
Can't recommend Rubenwardy's modding book highly enough - covers huds really well:
https://rubenwardy.com/minetest_modding ... an-element
copied from the above more complete examples there.
Code: Select all
player:hud_remove(idx)
Who is online
Users browsing this forum: Google [Bot] and 6 guests