Page 1 of 2

[Mod] Inventory Tweaks [2.0.1] [beta] [invtweak]

PostPosted: Sun Apr 21, 2013 11:57
by BlockMen
Hello everyone,

this mod adds some improvements to the players inventory.

Main feature: This mod adds 3 different buttons to player inventory. With those buttons you can sort your inventory easily.
"›•"-Button concernates all stacks to their maximum size.
"^"-Button sorts all items in an ascending order
"v"-Button sorts all items in an descending order

See demonstration video here: https://www.youtube.com/watch?v=PeOXqyP6h7o

Note: It's currently only working for the player inventory, not for chests or other formspecs.


Furthermore this mod has the ability to refill your wielded items automaticly. For example your current tool breaks and you have one more of the same type (e.g. a stone pickaxe) this mod puts it right in you hand and you can keep digging our placing nodes without opening the inventory.
You can disable this setting by adding/changing following to your minetest.conf file: "invtweak_autorefill = false"

As a small gimmick it adds also a sound when a tool breaks, just to improve the atmosphere of the gameplay. :)

Currently supported mods:
- unified_inventory
- 3d_armor

Notice:
This mod is in beta state, please report any issues you notice.

Download:
Version 2.0.1 beta: Download (tested on 0.4.12, should work on 0.4.10 or newer)
Source code: Github

Depends:
default
unified_inventory (optional)
3d_armor (optional)


License:
- source code: WTFPL
- sound by EdgardEdition (CC-BY-3.0)

PostPosted: Sun Apr 21, 2013 12:16
by Jordach
Okay. Breaking sound is a really good idea as I usually count down the uses before the tool breaks, so that's one thing I don't have todo anymore.

Secondly, I've used Tekkit before and the automatic refill in there is useful, provided you have the items to "fake" refill the stack.

In a nutshell, this mod makes life much, much easier for me, don't know about you.

PostPosted: Sun Apr 21, 2013 12:19
by Calinou
I like it. This should be in the default game. :D

PostPosted: Sun Apr 21, 2013 12:23
by Zeg9
Calinou wrote:I like it. This should be in the default game. :D

Auto-refill would fit more in the "build" game, but I agree.

By the way, nice mod.

PostPosted: Sun Apr 21, 2013 12:37
by Mito551
what part of the code does the auto-refill?

PostPosted: Sun Apr 21, 2013 12:57
by Zeg9
Mito551 wrote:what part of the code does the auto-refill?

The first 22 lines.

PostPosted: Sun Apr 21, 2013 13:08
by BlockMen
I have accidentally ziped und uploaded the wrong files. Please download again, if you want sound. Thanks

PostPosted: Sun Apr 21, 2013 15:41
by cHyper
awesome tweak tool for minetest...

PostPosted: Sun Apr 21, 2013 16:31
by jojoa1997
could you make this work for all tools like if an item has minetest.register_tool then the things happen. In minitest there are 2 tools that dont do this. Also maybe adding an optional group would be nice if you have set some node/craftitems to do something like a tool

PostPosted: Sun Apr 21, 2013 16:35
by BlockMen
jojoa1997 wrote:could you make this work for all tools like if an item has minetest.register_tool then the things happen. In minitest there are 2 tools that dont do this. Also maybe adding an optional group would be nice if you have set some node/craftitems to do something like a tool


Could you say me which tools that are? And the auto-refill should work for any stack, no matter what it contains.

PostPosted: Sun Apr 21, 2013 16:52
by Casimir
Prevent the game from crashing when there is no digger/placer/puncher:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local auto_refill = true  -- set to false if you dont want get refilled your stack automatic

function refill(player, stck_name, index)
    local inv = player:get_inventory()
    for i,stack in ipairs(inv:get_list("main")) do
        if stack:get_name() == stck_name then
            inv:set_stack("main", index, stack)
            stack:clear()
            inv:set_stack("main", i, stack)
            return
        end
    end
end

if auto_refill == true then
    minetest.register_on_placenode(function(pos, newnode, placer, oldnode)
        if not placer then return end
        local index = placer:get_wield_index()
        local cnt = placer:get_wielded_item():get_count()-1
        if cnt == 0 then minetest.after(0.01, refill, placer, newnode.name, index) end
    end)
end


local tname = ""
minetest.register_on_punchnode(function(pos, node, puncher)
    if not puncher then return end
    if puncher:get_wielded_item():get_wear() ~= 0 then
        tname = puncher:get_wielded_item():get_name()
    else
        tname = ""
    end
end)

minetest.register_on_dignode(function(pos, oldnode, digger)
        if not digger then return end
        local num = digger:get_wielded_item():get_wear()
        local index = digger:get_wield_index()
        if num == 0 and tname ~= "" then
            minetest.sound_play("intweak_tool_break", {gain = 1.5, max_hear_distance = 5})
            if auto_refill == true then minetest.after(0.01, refill, digger, tname, index) end
        end
end)

btw.: Nice mod. Tried to code the auto refill some time ago but failed. And your solution is more simple than I expected.

PostPosted: Sun Apr 21, 2013 17:24
by BlockMen
Casimir wrote:Prevent the game from crashing when there is no digger/placer/puncher:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
#code

btw.: Nice mod. Tried to code the auto refill some time ago but failed. And your solution is more simple than I expected.


Thanks, but where is the change in my code? And i tried that, there was no crash. Did you had one?

PostPosted: Sun Apr 21, 2013 17:55
by Casimir
Lines 17, 27, 36. Is a rare bug caused by certain mods that use place_node without a placer, or dig_node without a digger.

PostPosted: Sun Apr 21, 2013 18:10
by BlockMen
Casimir wrote:Lines 17, 27, 36. Is a rare bug caused by certain mods that use place_node without a placer, or dig_node without a digger.


Ok, thx. I think i will add this, but im not convinced that it is neccesary. I have tested with minetest.env:dig_node(), place_node(), and punch_node() (all have no placer) and it does have no effect. No error, no crash, nothing.

PostPosted: Thu Apr 25, 2013 20:53
by BlockMen
Update: Version 1.1

Changelog:
- Added Casimir's crash prevention

- supports now also costum tools, that don't digg nodes

Notice: Inventory Tweaks works always for the default tools. The support of costum tools brings no interference for usage.

PostPosted: Sat Apr 27, 2013 09:23
by Iqualfragile
please upload this mod into a repository ( https://bitbucket.org )

PostPosted: Thu May 16, 2013 14:21
by BlockMen
Update: Version 1.2

Changelog:
- Fixed sound-bug in multiplayer
- Fixed bug in creative mode
- full Multiplayer support
- improved support for costum tools

PostPosted: Sun Jul 21, 2013 15:31
by Casimir
I noticed a bug: when you have a unused tool and use it on something it is not made for it breaks instantly. E.g. dig dirt with a brand new pickaxe.

PostPosted: Wed Jul 24, 2013 10:22
by BlockMen
Casimir wrote:I noticed a bug: when you have a unused tool and use it on something it is not made for it breaks instantly. E.g. dig dirt with a brand new pickaxe.


Thanks for feedback.

Survival or creative mode? Because i noticed that issue in creative already but had no time to update yet.

PostPosted: Thu Jul 25, 2013 19:40
by BlockMen
Version 1.2.1 released

Changelog:
- fix instant break of unused tools in creative mode

PostPosted: Thu Jul 25, 2013 23:38
by Mossmanikin
Very cool this mod. Minetest has far too less sounds and the auto-refilling is very handy.

Both features seem not to work in creative mode for me (stable 0.4.7, no other mods).
Don't know if it's a bug or a feature, but who needs anything but building blocks in creative mode anyway?

PostPosted: Fri Jul 26, 2013 12:23
by BlockMen
Mossmanikin wrote:Very cool this mod. Minetest has far too less sounds and the auto-refilling is very handy.

Both features seem not to work in creative mode for me (stable 0.4.7, no other mods).
Don't know if it's a bug or a feature, but who needs anything but building blocks in creative mode anyway?


Both. Auto-refill = feature, sound = bug :P

I will check that, thx.

EDIT: This bug (and its fix in 1.2.1) is only occuring in dev-versions of Minetest. So if you are using Minetest 0.4.7 stable, then stay at Version 1.2 of this mod.

Caused is this bug by this commit -> https://github.com/minetest/minetest/commit/90b095aa54b5a96b1100966adc0f083e9cb5409d

PostPosted: Fri Oct 04, 2013 17:23
by onpon4
I find it really annoying that this instantly breaks many tools when you use them on the wrong thing. I was annoyed when I lost a perfectly good diamond sword because I was wielding it while I picked up a torch, and I've lost a compass from another mod more than once because of it.

(It's not whatever bug you fixed in 1.2.1. This is version 0.4.7 without creative mode.)

PostPosted: Sun Oct 06, 2013 11:38
by BlockMen
onpon4 wrote:I find it really annoying that this instantly breaks many tools when you use them on the wrong thing. I was annoyed when I lost a perfectly good diamond sword because I was wielding it while I picked up a torch, and I've lost a compass from another mod more than once because of it.

(It's not whatever bug you fixed in 1.2.1. This is version 0.4.7 without creative mode.)


Thanks for reporting that bug. I will fix that as soon as possible, but it seems i have to rewrite the mod for that, so it could take a while.

PostPosted: Mon Oct 21, 2013 23:02
by BlockMen
Update: Version 1.2.2

Changelog:
- Fixed instantly break of unused tools when digging wrong block
- lowered volume of break sound a bit

Version 1.2 (for Minetest 0.4.7 stable) is also fixed

PostPosted: Sun Nov 17, 2013 23:06
by Johnyknowhow
cool, i iz gettin it,

PostPosted: Mon Nov 18, 2013 04:34
by hoodedice
BlockMen: IT IS CUSTOM, NOT COSTUM, DAMMIT XD

PostPosted: Thu Nov 21, 2013 22:00
by Johnyknowhow
i dont like the sound, it freaked me out, so i used the minecraft sound,

PostPosted: Wed Apr 09, 2014 12:12
by Linxx
does this mod work for current version?

PostPosted: Wed Apr 09, 2014 13:00
by Casimir
Yes. Using it with both 0.4.9 and the latest git works. The only bug I know of happens when using unknown items.