ID:2420399
 
Code:
mob/verb/CloseInventory()
winshow(src,"Inventory",0) //Hide the inventory window!

mob/verb/Inventory()
set hidden = 1
winshow(src,"Inventory",1) //Show the inventory window!
var/Position = winget(src, "default", "pos") // Get the position of the "default" window and assign it to a var called "Position"
winset(src,"Inventory","pos='[Position]'") // Set the position of the "Inventory" window to the same position as our main window.

src.client.screen = null


for(var/Column = 1 to 5) for(var/Row = 1 to 5) //Create a grid composed of 5 columns and 5 rows.
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) //Generate the items on slots.

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
G.used =1 ; return



Grid
parent_type = /obj
icon = 'Inventory_slot.dmi'
icon_state = "Grid"
var/used = 0

mob/proc/Description(obj/items/I)
winshow(src,"Description",1) // Show the description window
var/Position = winget(src, "Inventory", "pos") // Get the position of the "Inventory" window and assign it to a var called "Position"
winset(src,"Description","pos='[Position]'") // Set the position of the "Description" window to the same position as our inventory.
winset(src,"Description.Text","text='This is a [I]'") // Add some text to describe that item...

mob/verb/CloseDescription()
set hidden = 1
winshow(src,"Description",0) // Hide the description window


//dragging items and dropping in inventory

obj/items
MouseDrag(src_object,over_object,src_location,over_location,src_control,over_control,params)// When we drag it...
if(!(src in usr.contents)) return // If its not in our inventory...just cancel ...
var/icon/I = new(src.icon,src.icon_state)//this is so the cursor icon transforms into the item itself...cool little effect.
mouse_drag_pointer = I // now lets set the mouse cursor to that.

MouseDrop(over_object=src,src_location,over_location, src_control,over_control,params) //When we drop it...
if(over_control =="Inventory.Inv") //If its inside the inventory window.
var/obj/O = over_object
src.screen_loc = O.screen_loc //Move the object on the new slot.





Problem description:


I am using Kidpaddles inventory library for my game and I'm trying to figure out how to fix the problem where even if the inventory is full, the item that you add in the inventory disappears and no longer usable. I have tried testing mouse procs but it was giving me runtime errors.

https://i.gyazo.com/b39a3ce2984a835884e6bc2bc45dfca3.mp4

You can make extra variable like maxInventory and give it value of max items in your inventory, after that in pickup proc just check is your items in inventory is the same as maxInventory var, if it isn't, add item to inventory.

mob
var
list/Inventory=list()
maxInventory = 5

proc/AddItem(var/obj/Items/thisItem)
if(src.Inventory.len>= src.maxInventory)
src<<"Sorry your inventory is full"
return 0
else
src.Inventory+=thisItem

obj/Items
Click() usr.AddItem(src)
Apple
Bannana
Peach