[Mod] hotbar [v0.1.5a][hotbar]
Posted: Mon Apr 23, 2018 07:09
This (my very first MT) mod adds one command:
hotbar
to control the slots number and the mod current behavior besides showing its settings.
The idea comes from the empowered hotbar I always miss when I cannot run VanessaE's Dreambuilder modpack.
Syntax
hotbar [size|mode]
By itself, hotbar displays the hotbar slots number and the current hotbar mode in the chat;
when it is followed by a number in the correct range that is currently [0,23], it accordingly sets the new slots number.
If set to zero, the hotbar gets hidden together with the wielded item and the hand: to restore everything you just need to set a slots number greater than zero.
Again, the command can be even invoked followed by one of the supported modes: LEGACY, WORLD, SESSION.
At startup, the mod should by default automatically choose the best supported mode, but - if supported and possible - its behavior can be overridden at any time.
In singleplayer, WORLD is the suggested mode for a MT v0.4.16+ client: the slots size can be in fact set to a different value in each world.
LEGACY will instead force a global slots number to be managed, saved and retrieved: this is the only mode a MT < 0.4.16 will be set to in singleplayer.
On a server, SESSION is the only supported mode: no data is saved and each user should be able to set an independent slots number every time he/she logs in.
Features
It may permanently store the user's preferences by setting and retrieving the hotbar_slots and the hotbar_mode keys in the minetest configuration file.
On recent MT clients, the mod_storage API can be used and is the preferred storage.
Usage Examples
] hotbar
issued command: /hotbar
[_] WORLD / 10 <== Chat output (note inside the square brackets the underscore: that tells us that MineTest is running in singleplayer mode - not connected to a server - otherwise our nickname would replace it).
] hotbar 4
issued command: /hotbar 4
[_] Hotbar slots number set to 4. <== We have overridden the default value in the current world / map.
] hotbar legacy
issued command: /hotbar legacy
[_] Hotbar slots number set to 16. <== Each mode has a default value that can be changed at any time.
[_] Hotbar mode changed to LEGACY. <== Changing hotbar mode in singleplayer is possible at any time: no restart is required.
] hotbar world
issued command: /hotbar world
[_] Hotbar slots number set to 4. <== The value we had set before in the current world has been restored.
[_] Hotbar mode changed to WORLD. <== This is in fact the hotbar mode we have chosen.
... We can then have a look at what happens when we connect to our home server. Let's start it with something like this:
[mynick@mylinuxbox] minetestserver --terminal --logfile /home/mynick/.minetest/RevolutionaryArchitect.log --worldname RevolutionaryArchitect --verbose
Lots of stuff follows... when all those text messages end and the server is up, we are ready to connect to it from the Play Online tab of our latest MineTest client!
Once we are in, we start checking how the mod we have used before in singleplayer has been automatically loaded:
] hotbar
issued command: /hotbar
[mt_super_nick] SESSION / 12 <== Chat output (note inside the square brackets our nickname: that tells us that MineTest is running in server mode). As specified before, the only supported mode on a server is SESSION and that allows temporary changes to the player's hotbar. At every login, in fact, the default hotbar size will be automatically set.
] hotbar 18
issued command: /hotbar 18
[mt_super_nick] Hotbar slots number set to 18. <== The default temporary value (currently 12) has been overridden by ours: 18.
When MT is run as a server, SESSION should be the only supported hotbar mode: let's check if that is true!
] hotbar legacy
issued command: /hotbar legacy
[mt_super_nick] LEGACY mode cannot be set on a server. <== Once again the world has not exploded. :P
Future Improvements (I am currently working on while offline for some time)
v0.1.6
- Some interface fixes.
v0.1.7
- A ClientMod? (Still not sure)
Browse the source code on github
Download Latest - v0.1.5a
Previous versions Changelog
v0.1.5a
- luacheck activation.
- FIXES:
- Fraction control was bypassed in get_and_set_initial_slots for an already existing legacy mode value.
- A possible float in minetest.conf or in the modstorage is now automatically converted into an int.
- normalize() scope is now local
v0.1.5
- Some code refactoring: hotbar and hotbar_mode have been merged into just hotbar.
- FIXES:
- Some feedback messages did not report the player's name.
v0.1.4
- Three modes have been identified: LEGACY, WORLD, SESSION.
- The slots number has been extended to include the zero.
- FIXES:
- The accepted slots number is now checked to cut out fractions
v0.1.3
- New update to assure the full API support because the v0.1.2
update seems to have gone wrong for some reason. (SORRY!)
The accepted slots number should now be in the range [1,23]
v0.1.2
- The size range [1,23] specified by the API is now fully supported
- Some textures have been added, others modified, some renamed
v0.1.1
- Small bug fix (the error message was not displayed when the slots number was out of the accepted range)
- Range extension from [4,16] to [1,16]
- Some code clean up
v0.1.0
- The hotbar is now correctly resized even when there are no items in it.
Sample screenshots:
5 slots
12 slots
16 slots
4 empty slots
hotbar
to control the slots number and the mod current behavior besides showing its settings.
The idea comes from the empowered hotbar I always miss when I cannot run VanessaE's Dreambuilder modpack.
Syntax
hotbar [size|mode]
By itself, hotbar displays the hotbar slots number and the current hotbar mode in the chat;
when it is followed by a number in the correct range that is currently [0,23], it accordingly sets the new slots number.
If set to zero, the hotbar gets hidden together with the wielded item and the hand: to restore everything you just need to set a slots number greater than zero.
Again, the command can be even invoked followed by one of the supported modes: LEGACY, WORLD, SESSION.
At startup, the mod should by default automatically choose the best supported mode, but - if supported and possible - its behavior can be overridden at any time.
In singleplayer, WORLD is the suggested mode for a MT v0.4.16+ client: the slots size can be in fact set to a different value in each world.
LEGACY will instead force a global slots number to be managed, saved and retrieved: this is the only mode a MT < 0.4.16 will be set to in singleplayer.
On a server, SESSION is the only supported mode: no data is saved and each user should be able to set an independent slots number every time he/she logs in.
Features
It may permanently store the user's preferences by setting and retrieving the hotbar_slots and the hotbar_mode keys in the minetest configuration file.
On recent MT clients, the mod_storage API can be used and is the preferred storage.
Usage Examples
] hotbar
issued command: /hotbar
[_] WORLD / 10 <== Chat output (note inside the square brackets the underscore: that tells us that MineTest is running in singleplayer mode - not connected to a server - otherwise our nickname would replace it).
] hotbar 4
issued command: /hotbar 4
[_] Hotbar slots number set to 4. <== We have overridden the default value in the current world / map.
] hotbar legacy
issued command: /hotbar legacy
[_] Hotbar slots number set to 16. <== Each mode has a default value that can be changed at any time.
[_] Hotbar mode changed to LEGACY. <== Changing hotbar mode in singleplayer is possible at any time: no restart is required.
] hotbar world
issued command: /hotbar world
[_] Hotbar slots number set to 4. <== The value we had set before in the current world has been restored.
[_] Hotbar mode changed to WORLD. <== This is in fact the hotbar mode we have chosen.
... We can then have a look at what happens when we connect to our home server. Let's start it with something like this:
[mynick@mylinuxbox] minetestserver --terminal --logfile /home/mynick/.minetest/RevolutionaryArchitect.log --worldname RevolutionaryArchitect --verbose
Lots of stuff follows... when all those text messages end and the server is up, we are ready to connect to it from the Play Online tab of our latest MineTest client!
Once we are in, we start checking how the mod we have used before in singleplayer has been automatically loaded:
] hotbar
issued command: /hotbar
[mt_super_nick] SESSION / 12 <== Chat output (note inside the square brackets our nickname: that tells us that MineTest is running in server mode). As specified before, the only supported mode on a server is SESSION and that allows temporary changes to the player's hotbar. At every login, in fact, the default hotbar size will be automatically set.
] hotbar 18
issued command: /hotbar 18
[mt_super_nick] Hotbar slots number set to 18. <== The default temporary value (currently 12) has been overridden by ours: 18.
When MT is run as a server, SESSION should be the only supported hotbar mode: let's check if that is true!
] hotbar legacy
issued command: /hotbar legacy
[mt_super_nick] LEGACY mode cannot be set on a server. <== Once again the world has not exploded. :P
Future Improvements (I am currently working on while offline for some time)
v0.1.6
- Some interface fixes.
v0.1.7
- A ClientMod? (Still not sure)
Browse the source code on github
Download Latest - v0.1.5a
Previous versions Changelog
v0.1.5a
- luacheck activation.
- FIXES:
- Fraction control was bypassed in get_and_set_initial_slots for an already existing legacy mode value.
- A possible float in minetest.conf or in the modstorage is now automatically converted into an int.
- normalize() scope is now local
v0.1.5
- Some code refactoring: hotbar and hotbar_mode have been merged into just hotbar.
- FIXES:
- Some feedback messages did not report the player's name.
v0.1.4
- Three modes have been identified: LEGACY, WORLD, SESSION.
- The slots number has been extended to include the zero.
- FIXES:
- The accepted slots number is now checked to cut out fractions
v0.1.3
- New update to assure the full API support because the v0.1.2
update seems to have gone wrong for some reason. (SORRY!)
The accepted slots number should now be in the range [1,23]
v0.1.2
- The size range [1,23] specified by the API is now fully supported
- Some textures have been added, others modified, some renamed
v0.1.1
- Small bug fix (the error message was not displayed when the slots number was out of the accepted range)
- Range extension from [4,16] to [1,16]
- Some code clean up
v0.1.0
- The hotbar is now correctly resized even when there are no items in it.
Sample screenshots:
5 slots
12 slots
16 slots
4 empty slots