HUD disappearing in all Solarus games

Started by CopperKatana, July 21, 2019, 05:36:45 AM

Previous topic - Next topic
Hello, I seem to be having a mysterious issue with Solarus. Whenever I die in a game and respawn, my HUD disappears and will not return. That, and anytime my character has low health and it tries to play the low health sound, I get this error:

Error: In timer callback: scripts/hud/hearts.lua:105: attempt to index global 'audio_manager' (a nil value)

What I find very strange is that this is the case for all Solarus games I have on my computer. It isn't just my own game with some messed up script. I'm having the same issues with the Sample Quest and my other projects, but interestingly, not with the Mystery of Solarus dev quest. The sample quest actually has its own issue, which is that when you die and respawn, not only does the HUD disappear, but the music stops too.

Does this sound like an issue anyone might be familiar with? I'm a bit perplexed.

Which game did you fork as a basis?

Do you have a file called audio_manager.lua in your scripts folder? If not, this is because you forked a game which it was used in. Just remove audio_manager and use the standard play_sound.

I forked the initial quest. I see now that the audio manager is a separate thing. As for the HUD, I tried to add this script to re-enable the HUD when the game starts:

require("scripts/multi_events")
local game_meta = sol.main.get_metatable("game")

local function game_over_restart_game(game)
  game:start()
  game:set_hud_enabled(true)
end

local function game_restart_hud(game)
  game:set_hud_enabled(true)
end

game_meta:register_event("on_game_over_started", game_over_restart_game)
game_meta:register_event("on_started", game_restart_hud)


This didn't change anything, however.

I've also been experiencing an issue with the hud disappearing when I die and respawn. I assumed it has something to do with my last saved ground position? Not really sure but definitely an issue I need to figure out before my game will be playable.

I also created a script that would start the hud when I ran a console command but if I run it after I die, it will not start the hud. I'll have to do some more testing to see what might be the issue, but there are no errors thrown so it will be trial and error.
Build a man a fire, he will be warm for the night. Set a man on fire, he will be warm for the rest of his life.
Other Handles: Kamigousu, Xejk, Mr Sheik

This is now fixed in the development version of 1.6.1, which will be released in a few days.
You will have to update hud.lua and hearts.lua from the free resource pack 1.6.1 then. Don't hesitate to ask here if you need help for that.
Thanks for reporting the issue!