ID:2417337
 
(See the best response by Lummox JR.)
Code:
    Click()
if(src.equiped == 0)
usr.overlays += src.icon
usr << "You have equiped the: <u>[src]</u>."
suffix = "(Worn)"
src.equiped = 1
else
if(src.equiped == 1)
usr.overlays -= src.icon
usr << "You have unequiped the: <u>[src]</u>."
suffix = null
src.equiped = 0

else

usr << "Error: </b>You may only have one of: <u>[src.name]</u> equiped."
return


clothshirt
name = "shirt"
icon='clothshirt.dmi'
value = 500
equiped = 0


Problem description:

Good day everyone, i'm trying to make a start to making a Boku no Hero game first time :). Currently i'm having some problems with the Click Proc that let me equip stuff that is lying on the gras.. Can you guys give me some hints on how to block this?


Here is Falacy's RPG Starter in description you can download pretty easy, but powerful Equipment system, with helpful comments.
http://www.byond.com/games/Falacy/RPGStarter

In your script, have to check your item is in your inventory. If it is - do some stuff.
set src in usr


Potion
var/value = 10
verb/Use()
set src in usr
usr.HP+=src.value



Best response
I edited your post to put the code inside the <dm>...</dm> block.

So with equipment systems, there are several right ways and many wrong ways to go. Using a var that says if something is equipped or not is actually a bad idea, because if the equipment got separated from the owner for any reason, confusing things could occur. Instead, it should be up to the mob to determine what equipment it's wearing.

This is a system I favor:

mob
var/list/equipment

proc/EquipmentChanged()
// this routine can be used to loop through all the equipment to
// determine stat bonuses, overlays, etc.

proc/Equip(obj/item/equipment/I)
if(!I.slot) return
if(!equipment) equipment = new // create the list if it doesn't exist
var/obj/item/equipment/old = equipment[I.slot]
if(old)
if(!Unequip(old)) return 0 // failed
equipment[I.slot] = I
EquipmentChanged()
src << "You equip [I]."
return 1 // equip successful

proc/Unequip(obj/item/equipment/I)
if(!equipment || equipment[I.slot] != I) return 0 // not equipped
equipment -= I.slot
EquipmentChanged()
src << "You remove [I]."
return 1 // unequip successful

obj/item
verb/Get()
...
verb/Drop()
...

equipment
var/slot // equipment will always have a slot

verb/Equip()
usr.Equip(src)
verb/Unequip()
usr.Unequip(src)

In this setup, the mob has an associative list of equipment by slot. The slot is a string like "head", "body", "weapon", "offhand", etc. There are other ways of doing this kind of thing; I just like the simple slot mechanic.

Here the mob always knows what it has equipped. And how is an item to know if it's equipped? If item.loc is a mob (call it owner from here out), owner.equipment var is not null, and owner.equipment[item.slot] == item, then it's equipped.

obj/item/equipment/proc/IsEquipped()
var/mob/owner = loc
return istype(owner) && owner.equipment && owner.equipment[slot] == src