[mod] Cycle through inventory rows [inventory_cycler]

User avatar
taikedz
Member
 
Posts: 692
Joined: Sun May 15, 2016 11:11
Location: Scotland, UK
GitHub: taikedz
IRC: DuCake
In-game: DuCake

[mod] Cycle through inventory rows [inventory_cycler]

by taikedz » Sat Jan 12, 2019 12:55

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)
Last edited by taikedz on Fri Jan 18, 2019 14:42, edited 3 times in total.
 

User avatar
DS-minetest
Member
 
Posts: 1109
Joined: Thu Jun 19, 2014 19:49
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
GitHub: DS-Minetest
In-game: DS

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

by DS-minetest » Sat Jan 12, 2019 15:06

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.
Do not call me -minetest.
Call me DS or DS-minetest.
I am German, so you don't have to pm me English if you are also German.
The background is a lie.
 

User avatar
taikedz
Member
 
Posts: 692
Joined: Sun May 15, 2016 11:11
Location: Scotland, UK
GitHub: taikedz
IRC: DuCake
In-game: DuCake

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

by taikedz » Sat Jan 12, 2019 15:20

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....
 

User avatar
texmex
Member
 
Posts: 1535
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
Napiophelios
Member
 
Posts: 981
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi
 

User avatar
TalkLounge
Member
 
Posts: 302
Joined: Sun Mar 26, 2017 12:42
Location: Germany
GitHub: TalkLounge
In-game: TalkLounge

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

by TalkLounge » Sun Jan 13, 2019 03:15

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)
Last edited by TalkLounge on Sat Feb 02, 2019 20:39, edited 1 time in total.
Subgames Server: Sky World Subgames German Survival Server: Wildes Land 2 E-Mail: talklounge@yahoo.de
 

User avatar
orwell
Member
 
Posts: 779
Joined: Wed Jun 24, 2015 18:45
Location: Raxacoricofallapatorius
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell

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

by orwell » Thu Jan 17, 2019 07:58

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
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
taikedz
Member
 
Posts: 692
Joined: Sun May 15, 2016 11:11
Location: Scotland, UK
GitHub: taikedz
IRC: DuCake
In-game: DuCake

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

by taikedz » Fri Jan 18, 2019 14:40

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...
 


Return to WIP Mods



Who is online

Users browsing this forum: Lefty and 11 guests