ID:1791015
 
(See the best response by Ter13.)
Code:
mob/verb/Inventory()
src.client.screen = null //Clear the inventory before generating everything inside.
for(var/Column = 1 to 13) for(var/Row = 1 to 5)
var/Grid/G = new
G.screen_loc = "Inv:[Row],[Column]"
src.client.screen += G
for(var/obj/item/I in src.contents) src.AddItems(I) //Generate the items on slots.
src.InvVisible = 1

mob/proc/AddItems(obj/item/I)
for(var/Grid/G in src.client.screen)
if(G.used) continue
I.screen_loc = G.screen_loc ; src.client.screen+=I
if(I.amount >= 1)
if(I.stackable == 1)
I.maptext = "<div align=right><font color=white><b>x[I.amount]</div>"
G.used =1 ; return


Problem description:

How would I go about clearing only the inventory grids instead of the entire screen? Seems like a winset fix, but I can't figure it.
I just want to be able to reset the inventory window without it also removing things from the screen like items in equipment slots
Best response
Just want to point something out:

You shouldn't be using one object per grid for an inventory background. Use a single object like this:

var/obj/o = new()
o.screen_loc = "1,1 to [rows],[cols]"


It will repeat the background for the on-screen grid for each tile in the list.