minetest-mods / hbsprint

A flexible sprint mod supporting stamina, hunger and monoids.
GNU Lesser General Public License v2.1
14 stars 11 forks source link

Error with hunger_ng and damage off setting #30

Open daretmavi opened 4 years ago

daretmavi commented 4 years ago

If you use hunger_ng and try to print, while damage is off, then you get this error:

2020-11-09 17:52:22: WARNING[Server]: +m tried to use hunger_ng.get_hunger_information() but Hunger NG is disabled because damage is disabled.
2020-11-09 17:52:22: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod '' in callback environment_Step(): ...etest/games/a-planet-alive/mods/player/hbsprint/init.lua:234: attempt to index a nil value
2020-11-09 17:52:22: ERROR[Main]: stack traceback:
2020-11-09 17:52:22: ERROR[Main]:   ...etest/games/a-planet-alive/mods/player/hbsprint/init.lua:234: in function 'sprint_step'
2020-11-09 17:52:22: ERROR[Main]:   ...etest/games/a-planet-alive/mods/player/hbsprint/init.lua:257: in function <...etest/games/a-planet-alive/mods/player/hbsprint/init.lua:253>
2020-11-09 17:52:22: ERROR[Main]:   /home/thomas/git/minetest/bin/../builtin/game/register.lua:435: in function </home/thomas/git/minetest/bin/../builtin/game/register.lua:419>
2020-11-09 17:52:22: ERROR[Main]: stack traceback:
2020-11-09 17:52:22: WARNING[Server]: +m tried to use hunger_ng.get_hunger_information() but Hunger NG is disabled because damage is disabled.

Possible repair is to change init.lua (line 233) elseif starve == "hunger_ng" then to elseif starve == "hunger_ng" and minetest.is_yes(minetest.settings:get('enable_damage')) then