mob/verb/bagopen()
winshow(src,"inventory",1) //Show the inventory window!
mob
Entered(Armor/A) // If an item or anything else sucessfully enters the mob's contents
..() // Checks to see if there's anything else to be called (in case).
if(istype(A))
var/Armor/X=locate(A.type) in usr.contents-A //Checks if there's an item with the same type already.
if(X) // If there's an item that exists with the same path
A.amount+=X.amount // Adds the amount of the item found
del X // Deletes that item found.
Inventory() // Calls the Inventory() prcoedure.
Exited()
..()
Inventory()
proc/Inventory()
var/i=1 // Current position (#) of contents
winset(src,"inventory.invent",{"cells="2x[contents.len+1]""}) // Sets column = 2, row = contents.len+1
src<<output("<b>Items</b>","grid:1,1") // Displays "Items" in the current cell, which is column 1, row 1
src<<output("<b>Amount</b>","grid:2,1") // Displays "Amount" in column 2, row 2
for(var/Armor/I in contents) // Searches through the contents list
src<<output(I,"grid:1,[++i]") // Outputs to the cell: column=1, row = ++i (++i means (i+1) returned immediately. i++ means (i+1) but first returns the value of i).; this Sets the item (I) in to the current cell
src<<output(I.amount,"grid:2,[i]") // Displays the amount the item (I) has in to the cell: column=2, row = i (i is already now i+1 from the previous output())
atom/proc/Bumped(atom/A) return 1 // And here is where we define the default for Bumped().. Note it is under /atom not /atom/movable. /atom children are /area, /turf and /movable [hence atom/movable]. The bumped() object does not necessarily have to be just an /obj or /mob right?
Armor // A datum named Item for items (obviously).
parent_type = /obj // /Item's parent (which can be checked via atom.parent_type) is now set to /obj, meaning that /Item contains all traits of /obj which contains it from /atom/movable which contains it from /atom (modified along the way of course).
density = 1 // Makes the item dense (unable to walk through)
var/amount = 1 // Stacking system!
Bumped(mob/M) // If something Bump()s into it, this is called.
if(!ismob(M)) return 0 // If M (the argument sent) is not a mob, the rest is stopped from happening
if(!M.client) return 0 // If M is not a client (human player), the rest of the procedure does not happen.
Pickup_proc(M) // Calls the procedure Pickup_proc.
verb/Pickup()
set src in oview(1) // Makes the verb available if the user if within 1 tile from the source.
Pickup_proc(usr) // You know what this does.
verb/Drop() // All /Item have this verb as well.
set src in usr // Verb is available if the item is in the contents.
set category = "Items" // The verb's category is set as Items
var/amt=max(0,min(99,input("How many [name] do you wish to drop? Maximum amount: [min(99,amount)]","Armor drop",1) as num|null))
if(!(src in usr)||!amt) return 0 // Safety checking if the item is actually in the usr's contents.
var/turf/XX = get_step(usr,turn(usr.dir,180))
if(!XX)XX=usr.loc
if(amt>=amount).=Move(XX) // Tries to moves the item to one step behind the user.
else
var/Armor/X = type
X = new X(XX)
X.amount = amt
amount-=amt
.=1
usr.Inventory()
usr << "[(.)?"\green":"\red"] You[(.)?"":" did not"] drop [amt] [src.name]\s." // Checks if the item was dropped sucessfully. (x)?y:z is a mini-if() statement: if(x){ y } else { z }
proc/Pickup_proc(mob/M) // Reason why I defined this instead of just having the verb is so I can pick up /Item's by bumping into them. Sure I could call the verb through Bumped() but than the usr would be someone else.
if(!(M in oview(1,src))) return // Checks if M is within 1 tile. If it isn't, the procedure stops.
.=Move(M) // Tries to moves the item to one step behind the user.
M << "[(.)?"\green":"\red"] You[(.)?"":" did not"] pick up [src.name]." // Checks if the item was picked up sucessfully. (x)?y:z is a mini-if() statement: if(x){ y } else { z }
KasablancRobeMale
icon = 'Kasablanc Robe Male.dmi'
icon_state = "base"
Problem description:
What it's supposed to do: Pickup an item on the ground, place it in the grid in the inventory window (which is closed but opens when you click a different button as stated at the top) with the number of said item on the right and the item itself on the left, and the columns titled "Items" and "Amount". Also outputs a little message to confirm said item was picked up.
What it does: Picks up the item. The item disappears and doesn't appear in the inventory. Still confirms through the outputted text it was picked up. (See image link below)
What I've tried: Running Inventory() everytime the window is opened, setting the grid to default, setting it to default only when the window is open, yelling at the code, praying.
Please help.
A screenshot: http://puu.sh/hFxQn/35e2d7e62b.jpg
Another problem is that you're outputting to a control named grid, not to inventory.invent. This is likely the cause of what you're seeing.