Page 1 of 1

[mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sat Jan 12, 2019 12:55
by taikedz
Simple mod to cycle through inventory rows, to bring different rows into the "active" row without going into the inventory !

Whilst standing still, hold "Shift" and "E" *, and the your inventory rows will be switched up row by row, allowing you to access non-active rows without having to open the inventory!

Image

There is also a tool , Inventory Cycler, which allows you to cycle forwards (click) and back (right click/drop).


* (sprinting and sneaking whilst standing still makes no sense right? And in case this is a combo already used by another mod, you can always change the key combinations using the 'inventory_cycler.required_controls' and 'inventory_cycler.forbidden_controls' settings)

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sat Jan 12, 2019 15:06
by DS-minetest
Nice idea!
However, in multiplayer this might be pretty laggy. And I don't like the key combination, eg. if you want to fly down fast (without always_fly_fast) you hold sneak and aux1.
I suggest that you can only move one row at time (hold it → it moves one row → release the keys → wait → hold again for second row swap).
Also a chatcommand would probably be useful if the server dowsn't react.
And it would be useful to be able to move into two directions.
I suggest some key combination like hold left, right and forward to swap the rows from down to up, backward instead of forward for the other direction.

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sat Jan 12, 2019 15:20
by taikedz
Yeah, the key combo is a bit of a kludge.... I could check for flying at the same time, but it also feels pretty bad.... still, you have to be moving to enable it, so would only kick in when flying straight down....

It's meant to help when running away from hostile mobs and your good sword is in another row.... maybe a heuristic of (running + LMB + moving) would work better ?

I'm going to give it a try on my own server Not So Simple Server - nobody has fly there so shouldn't be a problem for regular players.

There's also a tool for doing both backwards and forwards cycling, it's also a bit of a kludge - on_use makes it cycle forward, but on_place (cycle back) only works if pointing at a node... I got aruond that by defining on_drop but that means any time you try to chuck it from inventory it cycles your inventory instead....

Honestly, I'm open to extra input on what sane heuristics I could employ for it....

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sat Jan 12, 2019 16:16
by texmex

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sat Jan 12, 2019 16:24
by Napiophelios
Been waiting a long time for this :)
viewtopic.php?f=47&t=2434&p=154245#p154234

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Sun Jan 13, 2019 03:15
by TalkLounge
Neat idea!

Just shorten and changed a bit for my server
Code: Select all
local invtimer = 0
local invplayers = {}

local function invcycle(name)
   local inv = minetest.get_inventory({type = "player", name = name})
   local list = inv:get_list("main")
   for i = 1, 8 do
      list[i + 32] = list[i]
   end
   for i = 9, 40 do
      list[i - 8] = list[i]
   end
   for i = 33, 40 do
      list[i] = nil
   end
   inv:set_list("main", list)
end

minetest.register_globalstep(function(dtime)
      invtimer = invtimer + dtime
      if invtimer < 0.2 then
         return
      end
      invtimer = 0
      
      for _, player in ipairs(minetest.get_connected_players()) do
         local name = player:get_player_name()
         local keys = player:get_player_control_bits()--32 is key aux1
         if keys == 32 and not invplayers[name] then
            invplayers[name] = true
            invcycle(name)
         elseif keys ~= 32 and invplayers[name] then
            invplayers[name] = nil
         end
      end
end)

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Thu Jan 17, 2019 07:58
by orwell
taikedz wrote:* (sprinting and sneaking whilst standing still makes no sense right? Should not interfere with any other mods this way. server can change setting to not require this)

It interferes with the key combination that is used in advtrains used to directly get off a train without using the menu. However, it is only in effect while riding a train.
This code can check whether a player is currently riding a train:
Code: Select all
local pname = player:get_player_name()
if minetest.global_exists("advtrains") and advtrains.player_to_train_mapping
                and advtrains.player_to_train_mapping[pname] then
    -- the player is riding a train
else
    -- the player is not riding a train
    -- or advtrains is not enabled
    -- or some update changed internal workings of advtrains, in which case I'll try to notify you.
end

Re: [mod] Cycle through inventory rows [inventory_cycler]

PostPosted: Fri Jan 18, 2019 14:40
by taikedz
orwell wrote:It interferes with the key combination that is used in advtrains

...

This code can check whether a player is currently riding a train:

...


That's a bit of an anti-dependency without being a conflict.... Adding per-mod exception code feels wrong...

Instead, I've made it so that you can configure the controls via settings. I'm open to a PR/patchfile allowing the player to configure the control themselves via, say, some GUI design, but I don;t want to sink time into that myself yet...