ID:1653257
 
Keywords: grids, inventory, refresh
(See the best response by Nadrew.)
Code:
mob/verb/CloseInventory()
set hidden=1
winset(usr,"Inventory","is-visible=false")
var/height = 1
var/width = 0
for(var/obj/items/O in usr.contents)
if(width>=3)
width=0
height+=1
usr << output(null,"InventoryGrid:[++width],[height]")
mob/proc
InventoryTest()
winset(usr,"Inventory","is-visible=true")
var/height = 1
var/width = 0
for(var/obj/items/O in usr.contents)
if(width>=3)
width=0
height+=1
usr << output(O, "InventoryGrid:[++width],[height]")


Problem description:



I imagine what I'm overlooking is something stupidly simple and easy, but basically my primary issue is with the image. The inventory only possesses one Katana, but after dropping the pants I had in the inventory, closing out,and reopening, it simply duplicated the katana in the display. If I drop either katana, I can not interact with the second, so it's only a visual remnant of the item. Somehow, I'm not getting it to properly clear out the interface.

Any advice is appreciated.
Best response
The problem is you're only clearing slots that are occupied, so when a slot is no longer occupied it's not going to be cleared on the next refresh, you can simply clear the entire grid before rebuilding it.

src << output(null,"InventoryGrid")
That did it! Thank you very much sir! I knew it'd be something simple like that :).