tModLoader Hotbar Swapper

Solo-Ion

Dungeon Spirit
Here's a little mod that I put together in less than a week. It allows you to quickly swap items between the top and second row of your inventory. You can swap the entire row by pressing Caps Lock, or swap individual items by double tapping the corresponding number.

The button for swapping the entire row defaults to Caps Lock, but can now be changed in keybindings. To change the keybindings ingame, bring up the menu then click Settings, Controls and scroll down to the Mod Controls section.

You have the option to swap items with a single press of a number key. This feature can be enabled by pressing the letter O. See above for how to check if it is bound.

If you are on a server with this mod enabled, you can turn off swapping completely by pressing P.

Recently updated for tModLoader/Terraria 1.4.x. I'll leave the legacy version as an attachment, though.

Current mod version: 1.3
For tModLoader 2022.7.58.8

Have a look at my other mods.
Terrarian Dreamkeepers
Double Player Example
 

Attachments

  • HotBarSwapper v1.2.2.2.zip
    10.6 KB · Views: 468
Last edited:
Here's a little mod that I put together in less than a week. It allows you to quickly swap items between the top and second row of your inventory. You can swap the entire row by pressing Caps Lock, or swap individual items by double tapping the corresponding number.

Currently, you cannot change from Caps Lock to a custom button. If enough people want to change this, I'll learn how to add this option.

Now updated to tModLoader.

Have a look at my other mod.
Terrarian Dreamkeepers

i LOVE this! This will come in handy VERY often, thank you! and yes, PLEASE add a way to be able to change the button!
 

jopojelly

Retinazer
tModLoader
It works well, and should be handy. Here is a video for people to see it in action.
Changing the hotkey should be pretty easy, I can help if you want.
 

Solo-Ion

Dungeon Spirit
i LOVE this! This will come in handy VERY often, thank you! and yes, PLEASE add a way to be able to change the button!
I
Changing the hotkey should be pretty easy, I can help if you want.
Thank you both. I'm in the process of updating this and my other to the latest tMod version, and getting my other mod working in multiplayer. Once I've done that, I'll ask for your help with changing the shortcut.

Edit: Updated to tModLoader v0.7.1.1
 
Last edited:

Betailas

Terrarian
Hi! Awesome mod! Is it possible somehow to make a similar thing for the armor? For example, you have 2 sets of armor - ranger and mage, and it would be great to make a possibility to swap between armor sets just with one button.
 

Solo-Ion

Dungeon Spirit
Hi! Awesome mod! Is it possible somehow to make a similar thing for the armor? For example, you have 2 sets of armor - ranger and mage, and it would be great to make a possibility to swap between armor sets just with one button.
Hmmm, it should be possible to designate three inventory slots that could be swapped with a single button press. I wouldn't know how to let the player choose which slots to use, though. It would need to be fixed. I would also need to wait for interface support so that I could highlight the slots.

I think there was a similar feature in a tAPI mod, but I don't know which one.
 

Solo-Ion

Dungeon Spirit
when i flip hotbar,i able to use zoom for some reason.after fliping back,zoom gone
Hm, have you bound Caps Lock to something in keyboard options? That's the only thing that I can think of that might cause this.

Edit: Also, was this happening before the recent 1.3.1 update?
 

Backrevol

Skeletron Prime
Hm, have you bound Caps Lock to something in keyboard options? That's the only thing that I can think of that might cause this.

Edit: Also, was this happening before the recent 1.3.1 update?
Nope,nothin bound on Caps Lock
And no,this did't happend before 1.3.1
 

Backrevol

Skeletron Prime
I'll have to look into this, then. When you say 'zoom in', do you mean for the minimap, full screen map or both?
it's like zoom from sniper rifle or spiner scope or binoculars.It works not permanently,only on right click after flip

Oh.I just tested it without mods.There no "zoom in" mode after flip.I guess it's from another mods.False alarm,sorry
 
Last edited:

Solo-Ion

Dungeon Spirit
i LOVE this! This will come in handy VERY often, thank you! and yes, PLEASE add a way to be able to change the button!
And after much procrastinating, I've added the ability to change the swapper button. Instructions are in the OP.

This mod was updated ?
Yes, I just updated it a few days ago with a new feature, but was too lazy to make a post about it. More details in the OP.
 

Esterni

Terrarian
Is there a way to disable the double tab functionality? Playing on a server and while I (the host of the server) dont have any issues, someone on my server has an issue where only pressing the button of an active item will swap that one out. Say he's swinging a sword, and presses that key once, it swaps the item out.
 

Solo-Ion

Dungeon Spirit
Is there a way to disable the double tab functionality? Playing on a server and while I (the host of the server) dont have any issues, someone on my server has an issue where only pressing the button of an active item will swap that one out. Say he's swinging a sword, and presses that key once, it swaps the item out.
Currently there isn't, though I could add some way to disable it. I don't know what could cause this to happen for just one person, though.
 

Solo-Ion

Dungeon Spirit
Can you make the key configurable in the game's gui like the other mods?
I'd like to know how. I can't see anything in the ExampleMod or Wiki about options. Perhaps I'll just have to ask.

It works well, and should be handy. Here is a video for people to see it in action.
Changing the hotkey should be pretty easy, I can help if you want.
Hey, jopojelly? Could I have a little help here? Is there some documentation about how to add options to your mod. Also, I havn't been able to work out how public ModHotKey RegisterHotKey(string name, string defaultKey) works. Could you help me with that to?

Thanks.
 

jopojelly

Retinazer
tModLoader
I'd like to know how. I can't see anything in the ExampleMod or Wiki about options. Perhaps I'll just have to ask.


Hey, jopojelly? Could I have a little help here? Is there some documentation about how to add options to your mod. Also, I havn't been able to work out how public ModHotKey RegisterHotKey(string name, string defaultKey) works. Could you help me with that to?

Thanks.
A hotkey isn't an option. Options aren't implemented yet, but configurable hotkeys have been for quite some time now.

Here's how I setup my hotkeys in Helpful Hotkeys

In Mod:
Code:
namespace HelpfulHotkeys
{
    public class HelpfulHotkeys : Mod
    {
......................
        internal static ModHotKey SwapArmorVanityHotkey;
......................
        public HelpfulHotkeys()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
......................
        public override void Load()
        {
            SwapArmorVanityHotkey = RegisterHotKey("Swap Armor with Vanity", "P");
......................
And then in my ModPlayer
Code:
public override void ProcessTriggers(TriggersSet triggersSet)
        {
......................
            if (HelpfulHotkeys.SwapArmorVanityHotkey.JustPressed)
            {
                SwapArmorVanity();
            }
......................
        }
......................
public void SwapArmorVanity()
        {
......................
 

Solo-Ion

Dungeon Spirit
A hotkey isn't an option. Options aren't implemented yet, but configurable hotkeys have been for quite some time now.

Here's how I setup my hotkeys in Helpful Hotkeys

In Mod:
Code:
namespace HelpfulHotkeys
{
    public class HelpfulHotkeys : Mod
    {
......................
        internal static ModHotKey SwapArmorVanityHotkey;
......................
        public HelpfulHotkeys()
        {
            Properties = new ModProperties()
            {
                Autoload = true,
            };
        }
......................
        public override void Load()
        {
            SwapArmorVanityHotkey = RegisterHotKey("Swap Armor with Vanity", "P");
......................
And then in my ModPlayer
Code:
public override void ProcessTriggers(TriggersSet triggersSet)
        {
......................
            if (HelpfulHotkeys.SwapArmorVanityHotkey.JustPressed)
            {
                SwapArmorVanity();
            }
......................
        }
......................
public void SwapArmorVanity()
        {
......................
Thank you very much. This is much more user-friendly than my old way.

However, I'm still having one small problem. I can't get the default key to work. I have the following in my Mod class.
Code:
public override void Load()
{
    hotBarSwap = RegisterHotKey("Swap Hot Bar", /*"CapsLock"*/ /*Keys.CapsLock.ToString()*/ "P");
}
Neither "CapsLock", Keys.CapsLock.ToString() or even "P" was recognised as the default key. I can manually change the key allright, but when I click Reset To Defaults it just goes back to <Unbound>. Any thoughts?

On a slightly different topic, on very rare occasions I've had the following error pop up when I click Build & Reload:
Code:
The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Terraria.GameInput.PlayerInput.PostInput()
   at Terraria.GameInput.PlayerInput.UpdateInput()
   at Terraria.Main.DoUpdate(GameTime gameTime)
   at Terraria.Main.Update(GameTime gameTime)
After this happened, I'd click Continue, then reload again and everything would be fine. I've put this down to a tModLoader quirk, but I wonder if it could be this mod causing this glitch?
 
Top Bottom