This post is more or less a converted copy of the README.md file.
Description
This server mod provides upgradeable packs in form of items to players which give them additional health or breath. However, the better the health packs are and the more of them you use, the faster they will wear out.
Please note that the builtin HP bar maximum is always 10 hearts. With two additional "+10 HP" packs, one heart equals 4 HP (instead of previously 2).
Features
Unified Inventory and sfinv support
Chat command fallback formspec when no inventory mod was detected
+ 10 HP pack (damages player on craft)
+ 5 breath pack (takes breath on craft)
Dependencies: default, vessels (minetest_game content) Optional dependencies: unified_inventory, sfinv Requires Minetest 5.0.0-dev and optionally #7360 to ensure that everything is displayed correctly License: MIT Links:GitHub Source (.git), Nasty *.zip
Hi, so I've found a rather big bug in your mod.
What I've noticed is that everytime a player leaves the game the server crashes if said player has any upgrade packs equipped. Minetest crashes with this error:
AsyncErr: ServerThread::run Lua: Runtime error from mod 'upgrade_packs' in callback on_leaveplayer(): ...minetest-5.2.0-win64\bin\..\builtin\common\serialize.lua:151: Can't serialize data of type userdata
stack traceback:
[C]: in function 'error'
...minetest-5.2.0-win64\bin\..\builtin\common\serialize.lua:151: in function 'dump_or_ref_val'
...minetest-5.2.0-win64\bin\..\builtin\common\serialize.lua:138: in function 'dump_or_ref_val'
...minetest-5.2.0-win64\bin\..\builtin\common\serialize.lua:166: in function 'serialize'
...t\minetest-5.2.0-win64\bin\..\mods\upgrade_packs/api.lua:29: in function <...t\minetest-5.2.0-win64\bin\..\mods\upgrade_packs/api.lua:24>
...nt\minetest-5.2.0-win64\bin\..\builtin\game\register.lua:429: in function <...nt\minetest-5.2.0-win64\bin\..\builtin\game\register.lua:413>
I've tested this with most 5.x versions already and it happens on all of them (including, but not limited to 5.2.0 and 5.1.1).
I would really appreciate if you could fix this bug as I would love to deploy this mod on my private server.
You cannot eat the hearts. They are items that you can put into the new upgrade slots of your inventory to increase the maximal health of your character. The heart count in the status bar will not change, but 1 HP no longer corresponds to 1/2 status bar heart.
You should find these upgrade slots in a separate tab (for Minetest Game's sfinv inventory) or as the button shown in the second part of the image (for Unified Inventory). Other inventory mods (such as inventory_plus and i3) are currently not supported.
Krock, first love this mod. Second, I am trying to make it so the items appear on the HUD to give the player some warning when the items wear out. However I set my function to run when 'upgrade_packs.update_player(player)' is run in 'register_on_player_inventory_action' but surely this only covers when items are placed or removed in the inventory by the player. I cannot see in the code how 'update_player' is called when the items wear out. To my eye, the hp_max and breath_max thus do not change when an item wears out. Is there some magic to your code i am not seeing?
To my eye, the hp_max and breath_max thus do not change when an item wears out. Is there some magic to your code i am not seeing?
Sorry for the delay - I only found this reply by chance.
Your observation is correct. The newest version on GitHub now includes the bugfix. Thank you for reporting.