tAPI "The Invisible Hand" -- Inventory Management for the Organizationally-Challenged

Discussion in 'Released' started by wuli1986, Dec 20, 2014.

  1. wuli1986

    wuli1986 Terrarian

    IHicon.png
    The Invisible Hand
    Inventory Management Assistance for the Lazy "Organizationally-Challenged"
    version 1.2.0 for tAPI r16 and Terraria 1.2.4.1
    OPEN QUESTION: Is there any interest in having this mod updated to Terraria 1.3 with Mac/Linux support?
    In short, if there's enough interest in getting this mod to work both for Terraria 1.3 and on all of Mac/Linux/Windows--as I believe no other inventory management currently works for all three platforms--then I'll take a stab at it. Drop a comment if you're keen on this.

    With the release of Terraria 1.3, and in the month since, I've become increasingly unsure whether there's a niche left for The Invisible Hand--which would be fine if other, better solutions were available. Several of the mod's features have made it to Terraria proper*, and a couple other inventory-management mods have popped up that, while they may not have precisely the same mix of functionalities found here, do have a number of other fancy features (some likely too advanced for my C# skills to match) which recommend them.

    The One Big Reason that I may like to continue development is Mac and Linux support. I use (Arch) Linux exclusively these days, and now that Terraria has native *nix support--which as of Open Beta Patch 5 seems to work pretty much perfectly--I'm not interested in using or developing mods that only work on Windows. TIH was entirely developed and tested using tAPI through WINE, and while this worked (when it worked) almost flawlessly, the dev/testing process was tedious at best, infuriatingly frustrating at worst.

    But I know there's at least one modding framework being developed that already has support for *nix and doesn't require de/re-compiling Terraria (the cause of many bugs in tAPI and various standalone mods). As it stands now, to the best I can tell, none of the other inventory-management mods are available for Unix-based systems, nor do they look to be headed that way. So there's the niche--assuming there's anyone in that niche.

    Should the audience be there, I'll gladly put in the work to make the update. While it may not be trivial, I believe that porting to a new framework would not be intractable, but there's little point in that effort if no one will use the mod. So please let me know if this is something you'd like to happen!


    * including Restock--which not only functions exactly the same as it does in TIH, but has the same name and, if I understand correctly, was originally called "Smart Loot"--the exact same naming cycle that I went through. . . . Coincidence? I think . . . yeah, probably :p

    UPDATE: July 30, 2015 - TIH version 1.2.0 for Terraria 1.2.4.1
    It's later than I'd hoped, but here it is. I may not have been able to give this mod the attention or support it and its users deserved, but I never really stopped working on it. So, whether or not it still holds relevance, I did put a lot of work into this project, and now I release it into the wild to meet its fate.

    Without further ado, here are the new features (with fancy screenshots.gif!):
    • Buttons!
      • Chest-side button enhancements -- All the same customizable key-binds are still there, but if you sometimes just feel mousey or your mind blanks on which key to press, you're in luck. Courtesy of a nuclear accident The Invisible Hand, the words "Loot All", "Quick Stack", etc. that appear beside a chest's inventory when open have not only received new abilities, but can even morph into a new form. The options are:
        • Plain text (Vanilla-style) buttons -- if you don't want to mess with the aesthetic that Re-Logic have created, choose this option and your interface will look the same as ever, but have hidden powers. Right-click on Quick Stack or Deposit All to lock them (more on that below), or hold shift to see additional options like Sort, Restock, or Smart Deposit. See the spoiler on the "Right click..." feature further down for a look at these
        • Graphical button icons -- Go to the mod-options page and set "Use Chest Buttons" to "True" to transform those boring old words into something that's not words! Thanks to my "finest" graphic design "skills," you'll receive "fancy" button icons in their place, with "exciting" hover effects and "informative" tooltips (which can be turned off in the options if you so desire). Yes, all the originals--including "Rename"-- have received their own button, and I've even included a Sort button at the top. Once again, holding Shift will reveal the extra functions, and right-clicking on QS or DA will toggle their "locked" status.
          shift_buttons_demo2.gif
          Here's a showcase of the new buttons, including the Shift-toggle feature. Note the tooltips with the keybind-reminder at the end (can be disabled in mod options). The beginning is just showing how the icons change; it's a little hard to see, and I guess that you just have to trust me that I'm pressing shift to make this happen. That's followed by a rundown of all the buttons and which alternate-button they change to when shift is held down (Loot All and Rename don't change atm).

          rename2.gif
          Just showing off the Rename button here (well, mainly I wanted to show that it actually still works).
      • Player inventory buttons -- when you have your inventory open but are not investigating a chest or dealing with an NPC, two buttons will appear above the Coin & Ammo slots: one for Sort (which can be shift-toggled [or just right-clicked] to Reverse-Sort) and one for Clean Stacks...if anyone actually uses that function. In order to be less distracting and avoid becoming an eyesore, these will fade out to near-transparency at all times except when the mouse is actively hovered above them. If you still find them annoying or you just never use them at all, they can be turned off entirely by going to the mod options page and setting "Inventory Buttons" (on page 2) to "False".
        inv-sort-fr.gif
        ...a somewhat silly demo, to show what they look like. It just shift-toggles between sort & reverse-sort several times, though at the end there is a series of left-click-then-right-click (of course you can't tell which button I'm clicking...) to illustrate that right-click also performs a reverse-sort. This also happens to show how items in locked slots aren't affected by the sort operations. And oh yeah the Clean Stacks button is there too or whatever.
    • Right click on Deposit-All/Quick-Stack buttons to prevent them from affecting locked inventory slots
      • As mentioned above, right-clicking on the buttons for Quick Stack or Deposit All will "lock" them, which really means that they will now ignore any locked inventory slots when performing their respective operations. This is somewhat like the "favorite" ability found in Terraria 1.3 (though I swear I had this idea months before I knew anything like this was coming to Terraria! :p ). When QS or DA are locked (indicated by a little lock-icon beside their names/buttons), any of your items in locked slots will not be transferred nor have their stack-size changed when using Quick Stack or Deposit All either through the hotkey or the chest-side buttons. Note that, unlike a "favorited" item in 1.3, this status is tied to the slot an item resides in, not the item itself; thus, moving an item to unlocked slot will again cause it to be affected by QS/DA.
        depall-locked2.gif
        Here's the "Vanilla-style" text version of the buttons--with key-bind hints enabled--and a demonstration of the locking feature. At the beginning, Quick Stack and Deposit All are both unlocked. They're then right-clicked to toggle locking on; notice how the lock icon shows up to indicate this. Clicking on Loot All tosses the contents of the chest into the inventory where several of the items happen to land in open locked slots. Finally, a click of Deposit All shows that all items except those in the locked slots were deposited back into the chest (a.k.a. Gordon). I don't have a demo of the Quick Stack button, but it too ignores locked slots in a similar fashion.
    • Mod-option to show key-bind reminders in button names/tooltips
      • If you occasionally find yourself forgetting which keys you've assigned the various inventory-management functions to, you can set "Show KeyBind Hints" to "True" in the mod options page to show a little reminder at the end of the button's name (if using text buttons) or tooltip (if using icons). For example, if you've assigned the Sort function to the R-key, you'll see something like "Sort (R)".
    • Mod-option to disable tooltips
      • Should you find my artistic skills beyond reproach and need no reminder of which action each of the beautiful new icons is meant to represent, you can go to the mod options and set "Show Button Tooltips" to "False" for a cleaner experience. This option has no effect when using the text-only buttons.
    • Better(?) multiplayer support (need testers!)
      • Previous versions of the The Invisible Hand had some issues with inventory<->chest transfers not syncing correctly during multiplayer. @krageon was kind enough to dig through my code, identify the problem (as well as one related to texture-loading), and write up a patch for it. I've taken his patch and extended it to cover the new features of this update as well as (hopefully) fixing shift-click-to-move. The catch is that I'm not actually able to test this functionality, so I'll need testers and reports on any bugs that crop up with it. I think I've got a better handle on how all that stuff works now, so I'd like to think that there won't be any problems--but experience has taught me that code rarely runs on computers the same as it runs in your head, so I'm ready to fix any issues that appear.
    What is "The Invisible Hand"?

    "The Invisible Hand" is a mod that strives to improve the Terraria gaming experience without getting in the way. A number of customizable key-binds and other settings have been added for various tasks related to managing and organizing one's inventory and vast hoard of glorious goodies. The inventory interface has been tweaked in certain ways to add new functionality and improve old ones. Most everything can be tweaked or disabled according to your preferences using the mod-options menu.

    Mod Features

    Here's a summarized version of the mod's features:
    Note: (these are all the features prior to version 1.2.0; they're still relevant, but see the update post at the top for info on the new button enhancements
    • Adds hotkeys (defaults in parentheses) for the vanilla Quick Stack ("Q"), Loot All ("Z"), and Deposit All ("Y") actions.
    • Adds FOUR new actions and hotkeys to aid in inventory management:
      • Sort ("R") - sorts items in Main Inventory or open chest according to item-category, amount in stack, and numerous other sub-traits.
        • Hold Shift while pressing this key to reverse the sort order.
      • Stack ("X") - this consolidates all item stacks in the inventory or open chest into as few maximized stacks as possible.
      • Smart Deposit (Shift + Deposit-All) - deposits into the currently open chest any (and only) items in your inventory that match the category of an item already in the chest.
      • Restock (Shift + Quick-Stack) - previously called Reverse-Stack, this will attempt to refill any stack in your inventory with items from the currently open chest.
    • Supplementary Features (enable in Mod-Options menu):
      • Slot locking - Shift + Right-click any individual slot in the player's main inventory to toggle the "locked" state of that slot. Put an item in a locked slot and it won't be affected by the Sort or Smart Deposit features. Use this to keep your carefully planned organization of special and essential items in place!
      • End-of-inventory item placement - When picking up an item, Vanilla Terraria always places the item in the first available empty slot from the end of the player's inventory; enable this mod option for the inventory, chests, or both to use this placement style when sorting items.
      • Reverse default sort order - If you prefer the way items are sorted when using the "Reverse Sort" (Shift + Sort) command, you can use this mod-option to set reversed ordering as default for your inventory, chest, or both.
      • Shift-click to move item (NOTE: if you use a different mod with this functionality, you'll likely want to disable the feature in one of the mods to avoid conflicts) - If you enable this option, you can simply hold shift and left-click on an item/stack to instantly move that item back-and-forth between the player's inventory and an open chest,the Guide's crafting-info slot, or the Tinkerer's Reforge slot (assuming there's room in the destination for the item, of course)!
    Note that all the primary key-bindings can be changed in the Mod-Options menu for The Invisible Hand. Be sure to set the options to your liking before loading a world!

    Three key-binding options were added for these actions that already exist in game:
    • Quick Stack -- Default "Q"
    • Loot All -- Default "Z"
    • Deposit All -- Default "Y" (placed a bit further away to avoid hitting it accidentally...like I always do)
    These should all act exactly as if you had hit the corresponding button next to a chest inventory, and should have no effect without a chest open.

    These new actions were added, along with their corresponding key-binds:
    • Sort Inventory
      • Default key "R"
      • Hold shift while pressing this key to reverse the sort order.
      • If your main inventory is open, this will sort all your items (excluding the hotbar) first by category and then by several other factors. All stacks of items will be consolidated to the smallest number of full stacks possible, with all remainder items of that type placed in a single stack.
      • If a chest, safe, or piggy bank is open, that container is sorted instead. Stacks consolidated here, as well.
    • Consolidate Stacks
      • Default key "X"
      • This just performs the same stack-consolidation as the sort operation, but without, well . . . the sorting. Stacks are converged as much as possible in the player's inventory or a chest if one is open.
    • Smart Deposit
      • Hold Shift and press the Deposit All hot-key
      • With a chest/bank/safe open, this deposits all items from your inventory that match the category of an item already in that container.
      • Items in locked inventory slots will not be deposited by this action.
    • Restock
      • Press Shift + your designated Quickstack hot-key.
      • Any stack of items in your inventory that is not already at its maximum will pull matching items from the open chest to refill its stack (either to maximum or as much as it can).
      • Good for a fast refill of materials when building and crafting or for replenishing your waning reserves of potions and ammo.
    And here are the current mod-options and their corresponding features:
    • Enable/Disable slot-locking
      • Enabled by default
      • In-game, hold shift and right click on a slot in your player inventory (other than the hotbar) to lock it. A little lock icon will appear in the upper right corner to indicate this.
      • Any item/stack placed in a locked slot will not be moved around when you perform a sort operation. This can be useful if you like to keep certain potions, weapons, blocks, etc. in a certain spot in your inventory.
      • Shift + right click a locked slot to unlock it.
    • Set sorted items to be placed at the end of a container
      • Basically, rather than filling your containers from the top-left slot down, this will change the sort operation to fill from the bottom-right slot and up.
      • This is like how vanilla Terraria places items in your inventory when you pick up an item from the ground or do a loot-all on a chest.
      • The option is disabled by default, but you can set it for your player inventory, for chests/banks, or both.
    • Reverse the default sort order
      • If you find you prefer the reversed ordering of items, you can set that to be the default sort order, without having to hold Shift while pressing Sort.
      • Shift+Sort will do a forward-sort in this instance.
      • Disabled by default, but can also be set for player, chests, or both.
    Play with various combinations of the last two options until you get a set-up that you really like!

    And that's it. At the moment anyway. All-in-all, it's like an "Invisible Hand" managing your inventory for you! Get it? :D

    Ahem. Right. So, the default key-bindings are a bit arbitrary, I'll admit. I didn't spend too much time thinking about them, so they may very well conflict with other things. I'll tweak them if need be, but since they can easily be changed after activating the mod, you can switch them all around at your whim!

    Category Details
    These are the currently implemented categories, and the order in which they will be sorted by the mod. This is currently not configurable (without modifying the source code and recompiling).

    1. Coins
      • Money. New car, caviar, four star daydream.
    2. Picks/Drills
      • Because you must dig it.
    3. Axes/Chainsaws
      • For murdering trees (you monster).
    4. Hammers
      • "Mr. Redigit, tear down this wall!"
    5. Tools (other)
      • Non-pick/axe/hammer useful things, e.g. bug net, fishing poles, ropes, glowsticks, ...
    6. Mechanisms
      • Wire, switches, wrenches, most anything related to the wiring system. And minecart tracks.
    7. Melee Weapons
      • Swords, Flails, Spears. The classics. (Also boomerangs).
    8. Ranged Weapons
      • Bows, guns, shurikens--anything that keeps you out of poking distance.
    9. Bombs
      • Grenades, bombs, dynamite, et al. Boom.
    10. Ammo
      • Because throwing your gun at enemies is surprisingly ineffective.
    11. Magic Weapons
      • Wizard.
    12. Summoning Weapons
      • Minions of all magnitudes.
    13. Pets
      • Faithful and useless companions (though some produce light).
    14. Head Armor
      • For keeping your wits about you.
    15. Body Armor
      • For seriously tough torsos.
    16. Leg Armor
      • For preventing scuffed knees.
    17. Accessories
      • For feeling fabulous.
    18. Vanity Items
      • For looking glamorous.
    19. Potions
      • All things quaffable.
    20. Consumables
      • One time use stuff that you don't drink (includes food).
    21. Bait
      • Worms, fireflies, Master Bait, enough said.
    22. Dyes
      • Color is the spice of life. Or something like that.
    23. Paint
      • For when you're tired of brown and grey.
    24. Ores
      • Those rocks with "Ore" in their name. Also obsidian, hellstone, meteorite.
    25. Metal Bars
      • The above rocks made useful.
    26. Gems
      • All the shiny stones you can dig up. Also amber.
    27. Seeds
      • Herb, grass, and pumpkin seeds; acorns.
    28. Light Sources
      • Torches, candles, lamps, etc. (not glowsticks)
    29. Crafting Stations
      • From workbenches to kegs to the AutoHammer.
    30. Furniture
      • All household objects and containers (chests) not used for crafting.
    31. Statues
      • Statues (obviously); also gravestones & (you guessed it) the bubble machine.
    32. Wall Decorations
      • Paintings, trophies, a few other things.
    33. Banners
      • Both found and dropped by NPCs.
    34. Decorative Clutter
      • Bowls, books, bottles, etc
    35. Wood
      • Raw dead trees, all varieties.
    36. Blocks
      • e.g. dirt, stone, sand, etc.
    37. Bricks
      • Fancy blocks.
    38. Tiles
      • All other placeable items that do not fall into one of the above categories
    39. Walls
      • Universally reviled by hammers.
    40. Miscellaneous Materials
      • If you can't eat it, wear it, throw it, shoot it, or build your house out of it--but you can make it into something else--it'll end up here. Think herbs, goblin cloth, rotten chunks, etc.
    41. Special Items
      • Boss summoning items, heart and mana crystals. This category may be unnecessary and/or annoying. Or it may be great, I haven't decided.
    42. Other
      • If, somehow, something doesn't fit ANY of the above categories, you'll find it here. Umbrellas are a Vanilla example; unique mod items may land here for now. Further revisions to categories could move these items up the list at any item.
    If it's a bit unclear, this means that items that fall within a given category will be grouped together when the inventory is sorted. They're basically "clumps" of related items, and the items within each "clump" will then be sorted relative to each other. The clumps themselves will appear in the order given above.

    Screenshots
    For now, check out the update post up top to see shots of some of the mod's features in action. Though if you really want to see the total (and somewhat outdated) non-action of how the Consolidate Stacks function works, feel free to click the spoiler below.

    Here we have an inventory full of stuff and things. We'll illustrate the Consolidate Stacks function by focusing on the four stacks of torches--conveniently circled in red by yours truly--none of which is at its maximum stack size of 99.
    screen1.png
    When we hit the Consolidate Stacks key (default "X")....
    screen2.png
    We end up with just two stacks of torches. One has been filled to max of 99, and the remaining 62 torches ended up in the second stacks. You'll notice that the other item stacks in the inventory were similarly merged.

    That's it, you can now leave the edge of your seat. Please place empty popcorn containers in the proper receptacles.

    Disclaimer
    I've tested the mod in singleplayer with new characters on new worlds, and while I believe that most of the major bugs have been worked out, still note that this is still an early release and there are bound to be some hiccups. As when installing any new mod, back up your characters and worlds before activating "The Invisible Hand." I am not responsible for lost items or money, corrupted players or worlds, missing or injured pets, holes in the ozone, or targeting by shadow government agencies that may result from use of this mod.​

    Additionally, I only ever play LAN-multiplayer, but have not done so recently. As such, I did not tested the mod on any form of multiplayer, and I cannot guarantee it to work under such circumstances, nor can I guarantee that it won't be considered cheating for some reason by certain server admins. I welcome feedback from anyone who tries it in multiplayer and will endeavour to fix any bugs related thereto.

    As far as compatibility with other mods, there really shouldn't be any issues (doesn't mean there won't be, mind) unless the mod in question implements a feature identical to one found in TIH. During my testing, my active mods were all from Shockah's Suite: Inventory Tweaks, Fancy Cheat Menu Base and FCM Standard (mainly to spawn in all the items I needed to test the sorting, so I didn't have to go dig up the whole world first), Insight, and Enhanced Tooltip.

    Mod-added items shouldn't present a problem, and so long as the mod author gave them all the correct properties, they should be sorted together with other items of the same category. If they don't match any of the defined categories, they'll fall through to the "Other" category and be sorted at the end of player and chest inventories.

    Credits

    • First off, thank you to Re-Logic for creating and continuing to support this incredible game!
    • Secondly, many thanks to all the developers of tAPI for their hard work in creating the tool that makes mod-development accessible to the unwashed masses like myself!
    • I'd like to specifically give credit to Shockah, Grox The Great, Arkhalis, and PoroCYon, whose well-written mods and tools gave me invaluable guidance while creating my own project. Though I considered both Shockah.Base and BaseMod as required API mods at various times during the development, I eventually decided that the pieces I would actually be using from them were too few to add the additional dependency to this relatively small project and those pieces could be more easily reimplemented and tweaked to better fit within my own code.
    • Additional thanks to Arkhalis for his insight on my question in the tAPI forum thread before I posted this thread, and to GrtAndPwrflTrtl for advice offered on the same question.
    • HUGE thanks to Krageon for patching in proper multiplayer support to the mod.
    • And, though he said it was unnecessary, I'm still giving credit to Gubzs for the sprites posted in his "free resources" thread on the WIP board, some of which I used to throw together my icon, and others of which may prove useful in the future.

    Finally
    Enjoy! Not everyone will see a need for this mod, and I appreciate that. But if you're one of the number of folks out there like me who do, then I hope you find it useful! Please give me feedback, bug reports, and suggestions. I'll soon be dusting off my old GitHub and uploading the source there, so anyone who wants to fork or expand on the mod is welcome to.

    UPDATE: July 1, 2015 - TIH version 1.1.5+tr16
    All the glory for this update should go to @krageon , who, in my long absence, took upon himself the burden of redressing a bit of my dumbs and added proper multiplayer support to the mod. This is monumentous,* and likely something I would never have been able to do myself. I honestly can't express my thanks enough. All I've done here is recompile the mod for tAPI version r16. I tested by starting a fresh world (with an old character) and everything seemed to work fine; obviously this was singleplayer, but I didn't change krageon's code for this recompile, so I'd expect multiplayer to work just fine as well (fingers crossed). I should also note that this was on a 1.2.4.1 binary of the game, not 1.3 (on which tAPI may theoretically still run but without the features of 1.3?). Let me know if there are any issues.

    So...yeah! About 6 months since I've shown my face around here. It brings a tear to my eye to see that people have really taken to this mod, including liking it enough to fix it up when I was off-world! I always said I'd keep working on the mod unless "Life Stuff" got in the way, and that was true--I just didn't expect it to happen so...suddenly. But things are looking up! Doc tells me they can do wonders with prosthetics these days, and when you get right down to it, Turkish prisons aren't really as bad as they're made out to be. Maybe, like, 95% as bad as they're made out to be.

    Well anyway, the good news is, before things got crazy, I had mostly finished an upgraded version of The Invisible Hand with a lot of new features, optimizations, and bug fixes. Nothing crazy-out-there, just expansions on the theme and functionalities of the mod, hopefully making it easier to use and the game more fun to play. All the Internet hubbub about 1.3 being released drew me back here, and reading that tAPI may be discontinued motivated me to at least get this upgraded version working on the last version for 1.2.4.1. I'll need to integrate the multiplayer patches and put some final polish on it, but hopefully it won't take too long to get it ready to post.


    EDIT: A bug has been reported with this version where it seems that the shift-click to move items may not sync with the server on multiplayer. I'm not sure if this happens occasionally or consistently, nor whether it results in duplicated items or lost items. Just be aware of this issue so you can watch out for it, and let me know if you have any information on it beyond what has already been given.

    *Also monumentous is the fact that I just learned that apparently "monumentous" isn't really a word and now I feel like my whole life is a lie.



    Update III: Knurg's Revenge! 1/5/15 - TIH version 1.1.2b+tr14a
    After muscle-memory led me to very nearly trash several irreplaceable items during a reforging-session, I enabled the ability to shift-move items in and out of the Reforge slot as well. Download v1.1.2b if you've got the same itchy trigger finger.

    Update #2! 1/4/15 - TIH version 1.1.2a+tr14a
    Weeeeeeellllll... maybe I lied a little bit when I said there weren't any new features this time. But wait! Put away the pitchforks and let me explain.

    You see, I had been testing with some of the other fine mods on here to make sure everything worked with what other people were likely to be running, but there came a time when I began to wonder if some of the mysterious crashes I occasionally experienced were actually due to an issue with my mod, a problem with my (unorthodox) setup, a bug in TAPI itself, or some elusive conflict with a different mod that I couldn't pin down. Thus, I decided to reduce the number of variables in the equation and disabled most of the mods I had been running.

    Unfortunately, my prime suspects were Shockah's various Tweak Mods and GRealm/Basemod, those having the most complex and lowest-level modifications. But as I soldiered on in my testing, I realized that the ONE, the IRREPLACEABLE feature that I COULD NOT LIVE WITHOUT . . . was the ability to shift-click-move items between chests and inventories, from Shockah's Inventory Tweaks mod. Yes, I admit it, I have become a shift-click-aholic! My new prison . . . is SHAME. Anyway, not wishing to nullify the accuracy of my new test results to feed my habit, I just went ahead and implemented my own version of the feature--yes, in spite of my declaration below that I was intentionally not going to implement this feature, and I guess I need to delete that now, and I know you'll never be able to trust a word I say type again and I'm so sorry--along with a few personalizations and fixes (and hopefully no bugs) along the way.

    And since I know you're waiting with bated breath for me to tell you what I discovered about the source of the crashes . . . umm, I never did figure it out. They did stop happening as frequently with the other mods disabled, and I did eventually re-enable GRealm and Miraimai's MainSlotZero without any noticeable ill-effects, but I still get some sort of dictionary error on rare occasions of loading worlds, and I once got an index-out-of-bounds error while peacefully picking at some sand underground. So no firm answers as yet, but also nothing has corrupted my characters or worlds and I can still get some hours-long play sessions in without incident. When I get the chance, I'll collect my logs and ask in the tAPI thread. Overall, I suspect much of it has to do with some instability introduced by the fact that I'm not actually playing on Windows, but rather running Terraria and tAPI on Arch Linux through the WINE translation layer. In general, WINE is close to miraculous in its ability to run most any Window app I throw at it, often causing me to forget I'm not using a native application; but when it comes to games, I've enabled a few tweaks (specifically in how WINE deals with GPU threads) which greatly increase performance, but probably at the cost of a few hiccups every now and then. Rare enough that I'm perfectly happy, though! So long as I continue to make regular backups of my Terraria files (as everyone should!) I'm not going to worry too much about it.
    • If you're wondering which version to download, here's some suggestion:
      • If you don't use Shockah's mods and you'd like this feature, download 1.1.2a. Note that none of the other features of Inventory Tweaks are implemented here.
      • If you don't use Shockah's mods and you don't care about this feature at all, download either version; TIH 1.1.2a with the feature disabled (as it is by default) should be exactly the same as 1.1.2.
      • If you use Shockah's Inventory Tweaks and you've never noticed a conflict with TIH, you can just get 1.1.2 and be on your merry way--unless of course you like the changes I made, in which case feel free to download 1.1.2a, disable the option in Shockah's mod and enable it in TIH.
      • With that said, I'll add that I don't believe there would be a problem if you use 1.1.2a with InvTweaks and keep the shift-move function of TIH disabled, but I haven't tested that scenario yet.
    • TL;DR: NEW FEATURE in 1.1.2a -- Hold shift & left click an item in a chest or your inventory to move it between the two.
      • One of those fixes I mentioned: Available recipes should update correctly after a shift-move.
      • And an addition: you can now shift-click-move items between the Guide's crafting-info slot and the player inventory.
      • This feature is disabled by default; if you'd like to use it, be sure to head to the mod options screen before you load up a world.
    If you're not sure which version to download, check the suggestions at the end of the spoiler above.

    Update 1/4/15 - TIH version 1.1.2+tr14a
    Hullo everyone, I've been away for a little bit, but I'm back in the new year to bring you a shiny new update! No big new features this time, I'm afraid, but a number of bug fixes (everybody loves bug fixes) and (what I hope are) improvements. Let's get to it:
    • Highlights
      • Fixed bugs in the Shift+Right-click and Reverse-Stack code.
      • Increased specificity and total number of categories.
    • Bugs Fixed:
      • Fixed issue when shift-right-clicking to lock/unlock a slot; previously--if that slot contained a stackable item--this would unintentionally pick up an item from the stack. Now it's all just lock-toggledy-goodness. (Just for full disclosure, I never really did figure exactly what it was that caused this issue in the first place, but I changed it and now it's fixed therefore I win.)
      • Fixed a bug where Reverse-Stack would fill the player's ammo slots with ANY ammo found in the current chest, even if they had no ammo in their inventory at all. Ammo now just attempts to fill any existing stacks, same as everything else.
      • I finally noticed that many of the functions of this mod were not properly updating the available recipes upon their completion. This could lead to a number of issues and unintended behaviour. I believe I managed to take care of each situation in which this should happen; let me know if I missed any.
      • Tried to make the mod's coin-handling a bit less wonky. It's still wonky, trust me, but I think I cleaned up every edge case that might have led to ending up with more or fewer coins than you should have.
    • Changes and Adjustments:
      • The number of categories is up to, by my count, 42 . . . from about 25, I believe? See the spoiler further down this post labeled "Category Details" for the full list.
        • So . . . is this excessive? This might be excessive. BUT, I have reasons! I really wanted to make the Smart-Deposit feature actually smart! And clumping a bunch of pretty much unrelated things together as if trying to breed some horrific Grappling-Umbrella-Paintbrush hybrid isn't too smart if you ask me. And maybe you didn't ask me, but I programmed the thing so I asked me and now there's 42 categories and you're welcome.
        • On a serious note, if you do feel this hampers your organization efforts, please let me know. But I'm not removing categories. Nope nope nope not gonna do it well I might if you ask nicely but really I think my preferred solution to any problems that arise is to implement some sort of capability to allow users to mark certain categories as combined. I'm not quite sure the best way to go about this, and suggestions from other modders are welcome on this, though I fear it may involve implementing some sort of new interface, in which case . . . sigh . . . it might be a little while.
      • In addition to the fix listed above about the recipes updating properly, I reworked the stacking/depositing/looting-type functions to--for better or worse--more accurately imitate the functionality of their vanilla counterparts. Ideally, you won't notice much difference, except that maybe using the hotkeys seems even more like you had just clicked the corresponding button next to a chest. (Technical note: unfortunately, I wasn't able to just call an existing Vanilla method to perform these actions, as one might have expected. This means I had to largely reimplement them, and, as my understanding of Terraria's code improves, so does the accuracy of my implementations.)
      • Changed the wording of some of the mod options to reduce the need of a magnifying glass to read them on the menu page. I'm not sure, but this may require you to go and reset your preferences in the mod option page.

    Update 12/27/14
    A couple of new features in this update, features that I've been excited about for some time now! I won't put them behind a spoiler because they're pretty easy to explain and I'm too excited about them to hide them away. :D See the full description further down the post to see all the current features.
    1. Smart Deposit -- A simple, convenient tool for well-organized storage!
      • Hold Shift and press the Deposit All hot-key with a chest/bank/safe open to deposit all items from your inventory that match the category of an item already in that container. Nothing more, nothing less! Have a chest where you collect all your ores and bars? One for that collection of vanity items that you're totally planning on putting on [wo]mannequins someday? With this, just open the chest and throw them in without the need for an existing stack and without tossing in unrelated items.
      • Items in locked inventory slots will not be deposited by this action, so your essentials are safe.
      • The utility of this function will only increase as I make improvements to the categorization system.
    2. Reverse Stack -- For a quick top-off.
      • Press Shift + your designated Quickstack hotkey to refill stacks in your inventory from those in the currently open chest.
      • Any stack of items in your inventory that is not already at its maximum will pull matching items from the open chest to refill its stack (either to maximum or as much as it can).
      • Good for a fast refill of materials when building and crafting or for replenishing your waning reserves of potions and ammo.
      • I'm not 100% sold on the name for this one; I originally called it "Smart Loot," but that didn't really feel like an accurate description since it's not so much a selective loot-all as it a backwards quickstack. Well, actually, that's pretty much exactly what it is.
    In related news, I've also separated Ores, Bars, Gems, and Seeds into their own categories since the "Tiles" category is just too big. Still is, honestly, but hopefully this will make the Smart Deposit feature even handier. Let me know if this was the worst idea I've ever had.

    • Now this is the update you're really looking for. I'm marking it as a release candidate because, while I don't think it has any major bugs, it really needs more testing to fully justify that claim. Additionally, there's a couple more features I'd like to add before I finally consider this update complete.
    • Here's all the new stuff you're getting (added since v1.0.0):
      • All the features from the 1.1.0 release, namely:
        1. Shift+Right-click to toggle a player inventory slot as locked and prevent items in that slot from being sorted.
        2. New mod option to completely disable the slot-locking system if you don't care for it.
        3. New Mod option to sort items to the end of your inventory (like Vanilla Terraria); can set this for the player, chests, both, or neither (the default).
        4. Pressing Shift+Sort-key will sort the items in reverse.
      • And some NEW new features:
        1. I did a major overhaul of the sorting system, and a major refactor of the code base in general. This is mostly back-end stuff and may not be too visible on the player side of things, but it did allow me to really improve and tighten up the category and sorting parameters, and the more logical placement of items should help in organizing all your treasures more effectively (which is, after all, the point of this mod!)
          • Perhaps more importantly, these changes made it a lot easier for me to tweak the way things are sorted, which I'm sure I'll do as more testing is done. I welcome feedback from you on how everything feels and improvements you think could be made to the category- and sorting-systems.
          • This also opened the door to possible future player-configurable categories and sorting, something which would have been difficult--if not impossible--with the previous system. All in all, an exciting change, and one which has yet to display its full potential!
        2. New Mod option to set your inventory or chests (or both) to do a reverse-sort by default. Shift+Sort would then sort the items in regular order if this is set.
          • I felt that some may find this useful when using the sort-to-end setting if they found that they still prefer the ordering (i.e. left-to-right, top-to-bottom placement) of the original sort, but still want the items sorted from the end of the inventory. Or maybe some people just like the reverse order. Or maybe no one will use this feature, ever. Oh well. Choice is freedom!

    • This is the official release of version 1.1.0! It's received a fair amount of testing and has yet to blow up any computers or delete any characters or worlds, so you have my totally-conditional non-binding-guarantee that this release is safe.
    • Features added since v1.0.0 (previously seen in 1.1.0-rc1 & rc2):
      • Ability to lock individual player inventory slots by holding Shift and right-clicking on them (do the same to unlock). An item in a locked slot will not be moved around during a sort operation. See the original update notice under the "Version History" spoiler at the bottom of this post to find out more and see some screenshots.

    • Features added since 1.1.0-rc2 (never before seen!):
      • There is now a mod-option that allows you to entirely disable the slot-locking function if you so desire.
      • Also added a mod-option that allows you to chose whether to have your items sorted to end of your inventory (like vanilla Terraria does when you pick up items or use the loot all button) or to the front as this mod originally did.
        • You can choose to do this for the Player Inventory, for Chests, for both, or neither.
      • And a feature that was added quite literally because I thought, "Hey, why not," you can now hold Shift and press the Sort key to reverse the order in which the items of the current player/chest inventory are sorted. While it may be a bit of a novelty here, I feel it comes into its own in the other update I posted today. Check it out!
      • Slightly improved sorting parameters. They're still not great. Once again, check out the other update to see how I'm tackling that.
    • Bugs fixed:
      • Uh...bugs? Fixed? I'm not sure I follow...
    • v1.1.0-rc2 - 12-22-14
      • First implementation of a slot-locking mechanism!
        Update to the update: I've changed the locked-slot indicator to something less horrible to look at (not sure I'm totally sold on it, but it's definitely better), and made it so it only appears when you've locked a slot (rather than having an "unlocked" state, there will just be no indicator on unlocked slots). Also: pictures!
        Despite my initial bemusement at the idea, I came around to see the usefulness of such a thing. :p At first, I thought I'd just try a mod-option to just allow locking certain rows from being sorted, but that ended up feeling clunky and inelegant. So I went all out and implemented the in-game ability to lock slots individually from the inventory itself.​

        How it works
        • When you open up your inventory in-game, you won't notice anything different as, initially, all slots will be unlocked.
        • Simply hold shift and right-click on a slot to toggle its lock-state.
        • Items placed in locked slots will not be moved around when sorting your inventory, allowing you to manually arrange any important tools, potions, etc. exactly as you want them for quick access!
        Screenshots:
        In this example, we've locked a couple potions and some rope into the three slots on the upper left and a stack of torches in the top-rightmost slot right below the last hotbar item (with red arrows expertly added to draw attention to the lock indicator in the corner of each slot). Shockah's Inventory Tweaks is in effect with the color-by-rarity option enabled so you can see that the indicator won't be covered up by the larger border if you have this mod enabled.
        View attachment 16344
        As you can see, this inventory is a mess. Let's hit the "sort" key...
        View attachment 16345
        ...and now things are a bit better (still working on tightening up the sorting algorithms). But, more importantly, the items in the 4 locked slots were entirely unaffected by the sort operation! All the other items were sorted around them.​
        Known Issues (i.e. why this is a RC and not a true update)​

        • Deposit All and Quick Stack don't give a single flip about the locked slots. I'll have to teach them a lesson. And possibly make some mod-options to adjust just how "absolute" the lock is for the various operations.
        • Shift-right-clicking to toggle the lock will also pick up a single item if the slot currently contains a stackable item. I haven't quite figured out how to disable the default right-click action yet. But for now, just left-click to place the item back on the stack and you're good to go (but be sure to release the shift key first, though, or you'll send the entire stack to trash instead!).
        • Though the items in the locked slots will not be moved by the sort operation, stackable items can still be moved around by a stack-consolidation if they are not the first such stack in the inventory. I will lock them down from this, as well.
        • The mod is not quite so "invisible" as it used to be :p
    • Version 1.0.0_tr14a, 12/20/2014
      • Initial release. Hooray!
      • Compiled against tAPI r14a
      • Features added: all of them.
      • Bugs added: all of them.
      • Bugs fixed: Sort button no longer hands out infinite amounts of gold coins (sorry). That was kind of it, but confusing.



    While I will do my best to fix any bugs that people find and improve upon the existing functionality, I cannot guarantee that I'll have the time or will to add new features. That said, here are a few ideas or enhancements (from myself or suggested by others) that I may like to add if I can.
    • User-configurable categories, sort order, etc. This idea could encompass a myriad of subjects, some of which would add far more complexity to the mod than I'd like, but others would be nice additions.
    • An option for "auto-sort items on pickup." Not terribly complicated, just places items at their sorted location in the player's inventory when they are picked up. Would be disabled by default.
    • A "item pickup filter" ? I don't know, that may be beyond the scope of this tool, though admittedly I can see how some of the code might be adaptable to this function without too much effort. May function as an "auto-trash" option for select items.
    • Having the Smart Deposit function (optionally) key on Chest names; e.g. a chest labeled Ore will only accept ore during a smart-deposit...as one might expect.
     

    Attached Files:

    Last edited: Aug 1, 2015
  2. Flor3nce2456

    Flor3nce2456 Pixel Pirate

    Perhaps a little video for some folks? :)
     
  3. wuli1986

    wuli1986 Terrarian

    Ah, yes, a very good idea...I'll have to see if I can figure out how to do that. :eek:
     
  4. Flor3nce2456

    Flor3nce2456 Pixel Pirate

  5. wuli1986

    wuli1986 Terrarian

    Thanks! I'll look into it and see if I can get it working sometime soonish. Not sure how often I'll be able to spend time working on this for the next couple weeks or so now that the holidays are in full loom, but that'll be top priority when I do!
     
  6. aceper

    aceper Terrarian

    I must say, this mod is absolutely splendid! I love the idea, and will be using this on my next play through. The future enhancements section really excited me.. An option to auto-trash things? I've often thought about that needing to be in the vanilla game. Nobody likes getting those items that aren't valuable enough to be kept in their inventory.. A huge reason why I do get frustrated at the game is because of the inventory management. So to wrap this up; brilliant idea, thank you sir.
     
    wuli1986 likes this.
  7. darthmorf

    darthmorf Party Girl

    Would it be possible to make it so you can select which inventory bars get sorted? I store health pots and rope and things on the top bar, and wouldn't want them getting mixed up.
     
    Sir BBP and aceper like this.
  8. wuli1986

    wuli1986 Terrarian

    Are you talking about the hot bar or the first row of the inventory directly underneath the hot bar? The hot bar itself is never included in the sort (though stack consolidation will still refill any stacks you've got there if there are more stacks of that item in your inventory). If you mean the second row, it might not be too difficult for me to add an option to exclude rows from the sort. I can look into it.
     
    darthmorf likes this.
  9. Omen267901

    Omen267901 Terrarian

    Oh my god thank you so much I have wanted this forever. I hate inventory management in this game because it takes forever, so this will help a lot.
     
    wuli1986 likes this.
  10. Me3sa

    Me3sa Terrarian

    Idea feels awesome, though in my case i have a hard time putting items in chests - it is mundane task and takes a lot of time in late game. Function that quick stacks items to nearby chests from inventory without actually opening them would be just perfect.
     
  11. Jofairden

    Jofairden Retinazer

    Really cool idea!
     
    wuli1986 likes this.
  12. darthmorf

    darthmorf Party Girl

    Yeah, I meant the second row.
     
  13. MiraiMai

    MiraiMai Terrarian

    You know, I'm really surprised this has never been done before. Good job :dryadsmile:

    I agree with the option to choose which rows to sort, though I think the better idea would be to choose how many slots, its easier with the ModOptions and more flexible. Just sort the last X amount of slots. I tend to keep torches and tools at the top left of my inventory.

    A few other ideas:

    1) An option to choose whether to sort from the beginning or end would be nice, maybe separate for chests/inventory. I personally like how vanilla keeps items at the end of my inventory.

    2) A "Smart Deposit" / "Smart Loot" would be nice, maybe by holding shift before using Loot All / Deposit All. For Looting it would just fill any stacks you already have, for deposit it would only deposit items that match the category of one of the items already in the chest. I tend to sort based on similar categories to the ones you set up :dryadtongue:


    Feel free to ask for help in PM or the #tapi IRC channel :dryadsmile: (I'm RawringNymNym in the channel)
     
    wuli1986 and aceper like this.
  14. wuli1986

    wuli1986 Terrarian

    Greetings, all! So, I had some very nice real-life plans this past weekend, but...things don't always work out, I guess. Anyway, I found myself with more free time than I had expected, so I took my frustration out on my keyboard.:p The result of all that was a functioning beta of a slot-locking mechanism! I'll be updating the OP with the info and download soon.

    After playing a bit more with this mod active, I have to say I agree. :DI'll try to whip one up.

    I love this idea! Definitely going on the TODO list. :happy:

    This is an interesting idea . . . I'm not entirely sure how it would be implemented, though (also not sure this mod is the right place for it). Any ideas off the top of my head about how to code this seem like they'd be infeasibly taxing on system resources. I don't have any links to send your way, but I feel like I've seen discussion of similar ideas in some of the tAPI development threads, with most of the modders saying that such a thing would be impractical--if not impossible--with current tools. I'll keep it rolling around in the back of my head, though!
     
  15. wuli1986

    wuli1986 Terrarian

    By the way, I've not had any luck on the video-recording front. Technical difficulties and all that. I'll keep trying, but I'll try to get some screenshots up in the meantime.
     
  16. wuli1986

    wuli1986 Terrarian

    Haha! Pictures! In color and everything! Next, I'll look into these new-fangled "moving pictures" everyone is talking about.
     
  17. wuli1986

    wuli1986 Terrarian

    New update! Two, actually. One is the "official" release of v1.1.0, and the other is a new release candidate for a major overhaul of the sorting-system back-end I did.

    See the OP for the full details and downloads, but here's the highlights for version 1.1.1-rc1+tr14a:
    • Slot locking feature implemented, now with a mod-option to completely disable this feature if you wish.
    • New mod-option to keep items at the end of your inventory when sorting, like Vanilla does when picking up an item or doing loot-all on a chest. Can set for player inventory, chests, or both.
    • Can now press Shift+Sort-key to sort your items in reverse order. Why? Because I can, mainly. ;)
    • New mod-option to reverse the default sort order of player inventory, chests, or both. Combine this option with the sort-to-end option (which kind of reverses the sort order by itself), and play around until you find a set-up you really like.
    • The afore-mentioned overhaul of the sorting and categorization code. Players will most likely notice a tighter and more logical arrangement of items after a sort operation, but the best effects of this change are yet to be seen. Basically, it's made it infinitely easier for me to tweak the sorting parameters if need be, and paved the way to more player-control of the sorting and categories system in the future.
    As always, enjoy, and I gladly welcome feedback and bug reports!

    EDIT: yes, my changes to the sorting system did send the size of the mod sky-rocketing...it's now a whole 70 kb. Why, that's nearly 1/6 of your total RAM. Download at your own risk!
     
    Last edited: Dec 26, 2014
  18. kentanggoreng92

    kentanggoreng92 Terrarian

    I like this mod. :joy:
     
    wuli1986 likes this.
  19. wuli1986

    wuli1986 Terrarian

    Thanks! I just posted an updated version, and I hope you like it even more! :cool:

    I wanted to make sure to poke @MiraiMai on this update, since it was her comment that inspired these two new features! Did I add them just for you, you ask? Why, as a matter of fact...no. No I didn't. I added them because they sounded like the best thing since mouse-clicking was invented and I wanted them. I hope they live up to my everyone's expectations. So I want to say thank you for the great idea, fellow modder! May your code be ever free of segmentation faults.

    Please everyone send any comments and suggestions (and...bug reports, too, I guess...if you have to...) my way!
     
    kentanggoreng92 likes this.
  20. TheSlothstronaut

    TheSlothstronaut Skeletron

    Looks neat :joy:
     
    wuli1986 likes this.