ID:264293
 
Code:
mob/proc/UpdateInventory()
var/items = 0
for(var/obj/O in src)
winset(src,"Inventory.Grid","current-cell=[++items]")
src<<output(O,"Inventory.Grid")
winset(src, "Inventory.Grid","cells=[items]")

obj/Items
var/slot
verb
Get()
set src in oview(1)
Move(usr)
if(Amount)
usr<<"You picked up [Amount] [src]\s"
else usr<<"You picked up \a [src]"
usr.UpdateInventory()
Drop()
var/amt = input(usr,"How many would you like to drop?\nYou have [src.Amount] [src]\s","Drop",src.Amount) as num
amt = min(amt,src.Amount)
if(amt<=0 || !amt) return
if(src.Amount<=0) del(src)
var/new_amt = max(src.Amount,src.Amount-amt)
if(new_amt<=0)
src.loc = usr.loc
usr.UpdateInventory()
return ..()
src.Amount = new_amt
var/obj/Items/B = src.type
B = new B(usr.loc)
B.Amount = amt
if(src.Amount<=1)
src.suffix = null
else
src.suffix = "([src.Amount])"
usr.UpdateInventory()
return


Problem description:
runtime error: type mismatch: cannot compare 0 to Tin Ore (/obj/Items/Ores/Tin_Ore)
proc name: Drop (/obj/Items/verb/Drop)
source file: Objects.dm,53
usr: Wolf (/mob)
src: Tin Ore (/obj/Items/Ores/Tin_Ore)
call stack:
Tin Ore (/obj/Items/Ores/Tin_Ore): Drop()


EDIT
Fixed the line that had the max() problem
var/new_amt = max(src,src.Amount-amt)

You're trying to find what's bigger numerically, the src or a number. You just can't do that, it would be like saying if the word "who" is greater than a table.
In response to Jeff8500
Doh..I should've seen that one x.x

Another problem. Any reason the item isn't getting deleted from the Grid when I drop the whole lot? The item on the ground does have the amount dropped, but the item in the Grid won't get deleted so, essentially, a player could keep doubling the item o.O
In response to Mizukouken Ketsu
You check if the amount is less than 0 before you actually changed the amount.
In response to Jeff8500
rofl Sorry. I JUST fixed my issue :) There was some unecessary coding in there originally x.x

obj/Items
var/slot
verb
Get()
set src in oview(1)
Move(usr)
if(Amount)
usr<<"You picked up [Amount] [src]\s"
else usr<<"You picked up \a [src]"
usr.UpdateInventory()
Drop()
var/amt = input(usr,"How many would you like to drop?\nYou have [src.Amount] [src]\s","Drop",src.Amount) as num
amt = min(amt,src.Amount)
if(amt<=0 || !amt) return
if(src.Amount<=0) del(src)
src.Amount -= amt
var/obj/Items/B = src.type
B = new B(usr.loc)
B.Amount = amt
if(src.Amount<=0) del(src)
if(src.Amount==1) src.suffix = null
else src.suffix = "([src.Amount])"
usr.UpdateInventory()
return
In response to Mizukouken Ketsu
You might also want to check whether the movement into the person fails, just in case the movement fails and it says they have the object.
In response to Jeff8500
Actually the Get() verb isn't working at all now that I test it on an item sitting on the ground. I'm using Entered() for item stacking and the UpdateInventory() proc for the grid, but the item never appears in the grid. :\

Here's my Enetered() proc for reference in case
obj/proc/isEqual(obj/Items/O)
var/list/checked_vars = list("type","name","icon")
for(var/X in checked_vars)
if(src.vars[X] != O.vars[X]) return 0
return 1

mob
Entered(obj/Items/O)
if(istype(O))
var/obj/Items/X = locate(O.type) in src
if(X && O.isEqual(X))
X.Amount += O.Amount
del(O)
if(O) ..()
In response to Mizukouken Ketsu
You're not calling UpdateInventory()... It won't update by itself <_<
In response to Andre-g1
He's calling it in Get() and Drop(), though Entered() and Exited() would be more appropriate and robust places.