minetest-mods / stamina

Adds hunger (stamina) to minetest.
17 stars 18 forks source link

[CRASH] Crash when "Enable Damage" is off; no functionality at all #39

Open twity1337 opened 2 years ago

twity1337 commented 2 years ago

The mod is not working with "Enable damage" turned off in the game settings. Either sprinting is not possible, nor consuming of items works.

Furthermore, when an item is consumed, the game crashes with the stacktraces shown below. The reason for the crashes seem to be the missing stamina hud bar. A solution would be to display the hud even with "Enable damage" turned off, and just don't reduce the health on starvation. With "Enable damage" turned off, it might be enough to just prevent the player from sprinting with an empty stamina.

Eating normal item:

AsyncErr: Lua: Runtime error from mod 'flowers' in callback item_OnUse(): ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:50: bad argument #1 to 'hud_change' (number expected, got nil)
stack traceback:
    [C]: in function 'hud_change'
    ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:50: in function 'stamina_update_level'
    ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:294: in function 'eat'
    ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:267: in function <...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:265>

Eating poisened item:

AsyncErr: Lua: Runtime error from mod 'flowers' in callback item_OnUse(): ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:298: bad argument #1 to 'hud_change' (number expected, got nil)
stack traceback:
    [C]: in function 'hud_change'
    ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:298: in function 'eat'
    ...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:267: in function <...nloads\minetest-5.6.0-win64\bin\..\mods\stamina\init.lua:265>
fluxionary commented 2 years ago

stamina is not meant to work in a meaningful way when playing in a creative world, but i agree that it should not crash, and perhaps sprinting should work.

fluxionary commented 2 years ago

@twity1337 just double checking, did you remove these lines from the mod so that it'd load when enable_damage = false?

https://github.com/minetest-mods/stamina/blob/1a6e893f096dd0c120719e918fc1998e9a6175f8/init.lua#L1-L4

fluxionary commented 2 years ago

actually, the biggest problem here is that the player is using a very old copy of stamina mod, which is what's in the content DB. can someone update that?

twity1337 commented 2 years ago

actually, the biggest problem here is that the player is using a very old copy of stamina mod, which is what's in the content DB. can someone update that?

I can confirm that I downloaded the version from contentDB (it is release "13133").

just double checking, did you remove these lines from the mod so that it'd load when enable_damage = false?

No, I didn't change any of the files. There might have been a warning showing up. However, a warning does not prevent the game from crashing.

I think, a adequate fix would include:

SmallJoker commented 2 years ago

Someone created a new release on ContentDB 7-8 days ago. Does that fix the issue?