ID:176745
 
how do i make it where if i get something its name or picture and name goes into a tab named Inventory? also how do i make it where i can equip it and un equip it and when its equiped it powers up ur guys Attack and when its un equiped the attack goes back to normal?
armor
icon = 'armor.dmi'
var/equipped = 0
verb
get()
set src in oview(1)
usr << "You pickup the armor"

/*this is where you'd display it in the stat panel, but since I don't have the code readily accessible to copy and paste, someone else can explain that*/

drop()
if (src.equipped == 0)
src.loc = usr.loc
usr << "You drop the [src]"
else
usr <<"You must unequip this item."
equip(mob/player/M)
if (src.equipped == 1)
usr<< "You are already wearing armor."
else
src.equipped = 1
M.endurance += 5
unequip(mob/player/M)
if (src.equipped == 0)
usr<< "You are not wearing any armor."
else
src.equipped = 0
M.endurance -= 5

This is assuming you've declared variable for your mob/player, such as endurance. Also, I have to mention, don't write this for every item the players can get. Do it more like this:
obj
items
//get and drop verbs
equipment
//equip and unequip verbs here
armor
sword
etc.
In response to Krosse
Generally speaking, the way you've set up equipment is a very poor one. It's common, but that kind of code has been seen far too much around these forums and it's time to put a stop to it.

The problem: The player has no convenient way of telling what they have equipped. The items themselves, in your version, have the equipped var, and that's a lot less useful than setting up your vars like this:
mob
var/obj/item/weapon/weapon // null or weapon wielded
var/obj/item/armor/armor // null or armor worn
The var belongs to the mob, and says which item (among the ones in their inventory) they're carrying. This is the correct way to do it.

Lummox JR
In response to Lummox JR
Thanks for the tip. In my defense however, in my game, I was using overlays so that you could see the equipped gear on the character. However, there is a flaw in my code that I know about, and that is, if you have 2 armors, you can equip them both because the second armor still has equipped = 0.
Anyway, that was code from my test platform, in which I only test snippets to see if they work. In my final project I have things a bit more organized, and will probably use your suggestion.