[0.4.13] Inventory movement using shift

est31
Developer
Posts: 173
Joined: Mon Dec 29, 2014 01:49

[0.4.13] Inventory movement using shift

by est31 » Post

Today, list rings were merged. This formspec feature can be used to transfer items from inventory to e.g. a chest and back, directly without drag & drop.
However, mod creators have to take action in order to make their mod support that feature.

The basic setup is as follows: with formspec declarations, you build a list ring, by either naming formspec inventory lists, one after another, or using the shorthand listring[]. In fact, in most of the cases (in all with only two inventory lists you want to shift transport between), you will only need the shorthand. That means it can be used for a chest together with an inventory, or a crafting menu.

With the shorthand, a chest would look like this:
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]" ..
"listring[]"
With the slightly more verbose method, it would look like this:
"list[current_name;main;0,0;8,4;]"..
"list[current_player;main;0,5;8,4;]" ..
"listring[current_name;main]"..
"listring[current_player;main]"
The explicit naming allows one to much tighter control the ring.

The inventory list ring is like a linked list of elements, with the last element referencing the first as child, so that it forms a ring. Inventory lists can appear multiple times, so its permitted to do:
"listring[current_name;main]"..
"listring[current_name;main]"..
"listring[current_player;main]"
This allows one to freely specify almost all mappings -- read below for the furnace example.
When you shift-click a stack inside a given inventory list, it will search for the first occurrence inside the list ring, and then put the item into its child list. As its a ring, shift-clicking inside the inventory would successfully put the stack into the chest in the example from above.
Now to a slightly more interesting example, the furnace:
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]" ..
"listring[current_name;dst]" ..
"listring[current_player;main]" ..
"listring[current_name;src]" ..
"listring[current_player;main]"
There you have a ring
furnace destination -> player inventory -> furnace source -> player inventory
This will put items from the output of the furnace into the inventory, and items from the inventory to the furnace's source. Also, you can put items from the source back to your inventory if you have decided not to smelt/cook them.
however, the last "arrow" player inventory -> furnace destination which crosses the border doesn't have any impact, because "player inventory" already appears at an earlier point.

For a compact description of the listring formspec elements, consult the documentation inside lua_api.txt.
Last edited by est31 on Thu Aug 20, 2015 23:58, edited 1 time in total.

luizrpgluiz
Member
Posts: 20
Joined: Thu Mar 19, 2015 18:11
IRC: luizrpgluiz
In-game: luizinho

Re: [0.4.12-dev] Inventory movement using shift

by luizrpgluiz » Post

I hope this function does not have the minetest, I hope one day to test it on Linux and perhaps also in windows
cdb_HTWLEyTsySH8

ThatGraemeGuy
Member
Posts: 139
Joined: Thu Jul 31, 2014 11:02
GitHub: thatgraemeguy
IRC: ThatGraemeGuy
In-game: thatgraemeguy
Location: Cape Town, South Africa

Re: [0.4.12-dev] Inventory movement using shift

by ThatGraemeGuy » Post

I might just be dumb, but I have NO idea what this is or how to use it. :-/

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by rubenwardy » Post

luizrpgluiz wrote:I hope this function does not have the minetest, I hope one day to test it on Linux and perhaps also in windows
that makes no sense at all; please rephrase.
ThatGraemeGuy wrote:I might just be dumb, but I have NO idea what this is or how to use it. :-/
It's not yet in minetest_game, but it is in this version: https://github.com/Amaz1/minetest_game/tree/listrings

By 0.4.13 or whatever it will be in minetest_game. Just shift+click an item to auto move it (eg: in a chest to move to inventory, vise versa)
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by Nathan.S » Post

Sounds good, now we just need drag support so we can drag a stack in the crafting grid and drag it in the pattern we want to to make and automatically fill those spaces.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Amaz
Member
Posts: 354
Joined: Wed May 08, 2013 08:26
GitHub: Amaz1
IRC: Amaz
In-game: Amaz

Re: [0.4.12-dev] Inventory movement using shift

by Amaz » Post

Nathan.S wrote:Sounds good, now we just need drag support so we can drag a stack in the crafting grid and drag it in the pattern we want to to make and automatically fill those spaces.
I think that we already have it. You need to double rightclick with the itemstack and drag it with the right mouse button held down, although even then, it can be a bit temperamental...

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by Wuzzy » Post

This sounds like an incredible useful feature.

I have just one objection: Would it be possible to change the [Shift] key to something else, like [Ctrl] or whatever?
Please don't tell me you just used the Sneak key for that, that key is already very overused IMO.

I have another question: Will leftclick+shift, middleclick+shift and rightclick+shift behave differently (i.e. move all items, move 10 items, move 1 item)?

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by rubenwardy » Post

Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Nathan.S
Member
Posts: 1147
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by Nathan.S » Post

Amaz wrote:
Nathan.S wrote:Sounds good, now we just need drag support so we can drag a stack in the crafting grid and drag it in the pattern we want to to make and automatically fill those spaces.
I think that we already have it. You need to double rightclick with the itemstack and drag it with the right mouse button held down, although even then, it can be a bit temperamental...
I had no idea. Thanks a million.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Marshall_maz
Member
Posts: 249
Joined: Mon Jul 14, 2014 17:13
In-game: Mazal
Location: Cullinan, South-Africa

Re: [0.4.12-dev] Inventory movement using shift

by Marshall_maz » Post

I have tried this last night after updated to latest build. But shift-click does nothing. Doesn't shift items. Does this mean that the server is not updated ? IE must the update be done server side , client side or both server and client side ?

est31
Developer
Posts: 173
Joined: Mon Dec 29, 2014 01:49

Re: [0.4.12-dev] Inventory movement using shift

by est31 » Post

Both clientside and modside (also gameside, minetest_game doesn't have listring functionality merged yet). You can already add it to chests in your mod. The only two mods/games I know of which have the functionality are the technic chests, and the minimal game.

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [0.4.12-dev] Inventory movement using shift

by 4aiman » Post

Neat!

Say, est31, is it possible (or is it planned) to use different listrings for different items? (i.e. is it possible to register a hook on_listring_move?)

What for:
- shift+click on a fuel - it goes to the fuel slot of a furnace;
- shift+click on an item that can be cooked - it goes to to the src slot of a furnace.

Maybe that can be done reading the groups of an item and move throughout the inventories having those in mind.

est31
Developer
Posts: 173
Joined: Mon Dec 29, 2014 01:49

Re: [0.4.12-dev] Inventory movement using shift

by est31 » Post

Great idea! A hook might be not desireable due to lag considerations, but group based filtering should work -- if groups are transmitted to the client.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [0.4.12-dev] Inventory movement using shift

by Wuzzy » Post

I am not sure if the extra hook is a good idea. Why not treating it like a ordinary inventory change? I don't see why this sound have any special treatment.
I thought the listrings were supposed to be mostly client-based helpers.

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [0.4.12-dev] Inventory movement using shift

by 4aiman » Post

Well, there are a lot of hooks in minetest and it's only natural that came to my mind with "top priority" ;)
Hooks aren't good in any case, 'cause there always will be modders who will abuse those hooks (Oh, me! Pick me! Right in front of you! C'mon! Pick me! I'm waiting! Just pick me already!).


Anyway, I know very *little* about internals of minetest.
I have nothing against any way to implement features mentioned above.
In fact I'm only *for* implementing those w/o any hooks.

The only thing I'm worried is the control over the filters.
I.e. the "src" slot may well be named "source" and it may well be that we won't be dealing with a common furnace but yet another sophisticated item process unit. So, there should be a way to connect a slot with a particular group of items and transfer only if a group is found in a listring definition.

Moreover, I've items that can fuel AND cooked item. I think that the higher the group rating - the more priority that group should have.
Example:
Say, there's a definition of a listring to place"fuel" to "fuel" slot and "raw_food" to "src" slot.
Say, fuel==2 and raw_food=1.
In this case shift+click should chose fuel group over the raw_food (because of the rating of the former group exceeds the rating of the latter group) regardless of the order of declaration or alpha-numeric order of the names of the groups.

Have no idea how to implement all of that, so I just leave the above ideas here ^____^

est31
Developer
Posts: 173
Joined: Mon Dec 29, 2014 01:49

Re: [0.4.12-dev] Inventory movement using shift

by est31 » Post

There won't be hooks. I think comparing ratings is too complicated. I'll implement group matching though. I guess I'll just add conditionals to the listring -- add a new "listring" element, which gets chosen as destination only if the item in question has at least one group in common. It will never be chosen as "starting point", or if then only as a "generic" one. I'm not sure yet.

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

Re: [0.4.12-dev] Inventory movement using shift

by orwell » Post

Don't know if this is important, but if you define a listring from the player inventory to the "craftpreview"-slot, the item is put there, and only after about 10sec the item is put back. doesn't work for simple drag-n-drop. (actually, it is not useful to define a listring to the craftpreview)

listring[current_player;main]
listring[current_player;craftpreview]

another thing: could it be possible to craft whole stacks by shift-clicking the stack?
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [0.4.12-dev] Inventory movement using shift

by 4aiman » Post

orwell wrote:another thing: could it be possible to craft whole stacks by shift-clicking the stack?
Right click, please :)

Edit:

LMB click: crafts only once.
LMB click + hold it down: crafts once, then continue to craft Terraria-like (the longer you hold the button - the more you'll craft).
RMB click: crafts up to stack_max items.

Then Shift+LMB click will be free to be used to send crafted items into your inventory :)

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

Re: [0.4.12-dev] Inventory movement using shift

by orwell » Post

4aiman wrote: Right click, please :)
Does not work in stable 0.4.12 windows build from March. Currently can't try in latest dev. Did it change recently?
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [0.4.12-dev] Inventory movement using shift

by 4aiman » Post

orwell wrote:
4aiman wrote: Right click, please :)
Does not work in stable 0.4.12 windows build from March. Currently can't try in latest dev. Did it change recently?
Sorry..
Linux user here, so wasn't aware.


What's wrong with the RMB clicks?
I mean, we're using them for placing blocks, so...
The button does work but not with formspecs, did I get you right?

Is there an issue 'bout RMB clicks?

PS: I still think that RMB clicks are better for this purpose. If those are not working - it's high time to at least narrow down the cause ;)

est31
Developer
Posts: 173
Joined: Mon Dec 29, 2014 01:49

Re: [0.4.12-dev] Inventory movement using shift

by est31 » Post

About whole stack single click crafting... I don't think it should be too easy, there should still be gameplay reasons to build autocrafters and such.

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

Re: [0.4.12-dev] Inventory movement using shift

by 4aiman » Post

Honestly, I don't think that building an autocrafter is a good idea if all you have is 3-4 full stacks of items.
I can go clicking fiercely for 10 or so seconds and craft all that myself.
No autocrafter is worth building to win less than 3 seconds per stack.

But when it comes to a REAL mass production (like a wool factory) - autocrafters become essential.
This change won't affect the current system at all.

Moreover, there ain't no autocrafters in minetest_game.
If a mod adds one - it's a TODO for a mod to artificially make the game play harder.

That being said, maybe it would be nice to make shift-clicking depend on a formspec definition.
Merging this with listrings may be a good idea too. (At least it seems to be so ;)

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: [0.4.13] Inventory movement using shift

by Don » Post

Just wondering if anything has been done for groups? I would like to be able to shift click dye and have it go to the dye slot or flora to the flora slot etc.
I would also like to be able to define a certain item to a slot. Eg. a slot that only accepts cobble.
If any of this has been done then can you point me to some info on how to do it?
If not then thanks anyway. I appreciate all your work.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

Amaz
Member
Posts: 354
Joined: Wed May 08, 2013 08:26
GitHub: Amaz1
IRC: Amaz
In-game: Amaz

Re: [0.4.13] Inventory movement using shift

by Amaz » Post

Don wrote:Just wondering if anything has been done for groups? I would like to be able to shift click dye and have it go to the dye slot or flora to the flora slot etc.
I would also like to be able to define a certain item to a slot. Eg. a slot that only accepts cobble.
If any of this has been done then can you point me to some info on how to do it?
If not then thanks anyway. I appreciate all your work.
I don't know about your first question, but this might help for your second one: https://github.com/minetest/minetest_ga ... 1508-L1515

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: [0.4.13] Inventory movement using shift

by Don » Post

Thanks. That helps.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

Locked

Who is online

Users browsing this forum: No registered users and 2 guests