ID:1849416
 
(See the best response by Pirion.)
Code:
mob
verb
InventoryWindow()
if(!Inventory_Window)
Inventory_Window=1
winset(usr,"Inventory","is-visible=true")
for(var/obj/Items/O in usr.client.screen)
client.screen-=O
var/Position = winget(src, "Main", "pos")
winset(src,"Inventory","pos='[Position]'")
for(var/Column = 1 to 3) for(var/Row = 1 to 7)
var/Grid/G = new
G.screen_loc = "Inv:[Row],[Column]"
src.client.screen += G
for(var/obj/Items/I in src.contents)
src.AddItems(I)
Update(src)
else
Inventory_Window=0


mob/proc/AddItems(obj/Items/I)
for(var/Grid/G in src.client.screen)
if(G.used) continue
I.screen_loc = G.screen_loc ; src.client.screen+=I
I.maptext="[I.Amount]"
G.used =1 ; return

Grid
parent_type = /obj
icon = 'Inv.png'
var/used = 0





obj/Items
MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params)
if(!(src in usr.contents)) return
var/icon/I = new(src.icon,src.icon_state)
mouse_drag_pointer = I

MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params)
if(over_control =="Inventory.Inv") .
var/obj/O = over_object
src.screen_loc = O.screen_loc




Problem description:
1. Every-time the inv is open the items move to the next cell until it hits the end and restarts.

2. if you move the items manually that works, BUT if you close and reopen after moving the items it will put all items back to where they were then move them 1 cell over.



You have the row and column switched in your output.
thanks didn't see that

but the two problems still exist
Are you removing the Grid ever?
To save moves, you would need to swap them in the contents list, but swap/insert doesn't work with contents.
The point of this

is to grab every item that is in your contents list

like eggs berries etc etc and place them on the grid

which it does.





But if i close and reopen the window





it will move the item or items over to the next cell and every time i reopen it Will Keep moving over the items until the item/items hit the final spot




then it will restart in the first spot again.
In response to DistantWorld101
Best response
I've seen the point already. Please re-read your code and address the items I've listed. You're not removing the grid and you're not setting the permanent location of the items anywhere.
Thank you it's working now and sorry for the the extra post wasn't sure you did under stand being your last post you were talking about saving moves. But all is good now. Thanks for all the help.