obj
gold
icon = 'gold.dmi'
var
amount
verb
get() //obj/gold/verb/get()
set category=null
set src in view(1) //src must be close
usr << "You pick up [amount] gold."
usr.wealth += amount //add to usr.wealth
del(src) //delete the gold
obj/var/strincrease=0
obj
icon = 'Sword.dmi'
icon_state = "sword"
strincrease=5 //this is the item we'll be adding to our inventory
obj
verb
Get()
set category=null //this makes sure it will be a hidden verb. Just right click to use the verb
set src in oview(1) //when you get close the Get verb shows up
icon = 'Sword.dmi'
src.Move(usr) //puts it in the inventory
usr << "<b>You picked up a [src]!<b>" //shows the user in text his action
Drop()
set category=null
set src in usr //tells the verb where the item is
src.Move(usr.loc) //takes it out of the inventory and drops it where you are standing
usr << "<b>You dropped your [src]!<b>"
verb
Equip()
set category=null
set src in usr
if(usr.equip >= 1)
usr << "[src.name] is already equiped" //instead of typing the name just copy and paste this into where is needed.src.name will show Sword is already equiped!
else
usr.equip += 1
usr.overlays+=src.icon
usr.str+=src.strincrease
suffix += "{-Equiped-}" //Makes the suffix appear beside it in the inventory tab
usr << "<b>You equip your [src.name].<b>"
Un_Equip()
set category=null
if(usr.equip == 0)
usr << "You don't have anything equiped"
else
suffix = "" //Note*This only works if you have 1 suffix
usr.equip -= 1
usr.overlays-=src.icon
usr << "<b>You place your [src.name] back into your inventory.<b>"
Okay, I created this for my sword, and all worked well until I found a little bug. When you right click the gold that my mobs drop, it shows two get() verbs, Get() and get(). Due to this when you use either, it add the gold to your inventory and then you must right click it AGAIN to add it to your overall wealth. Any ideas on how to make them separate?
A few things of note:
You should have a general type for things that can be picked up and dropped, instead of giving such functions to every single /obj, such as:
As you can see, all things of type /obj/item can be gotten and dropped. This includes equipment. /obj/item/equipment then has its own procedures for equipping and unequipping.
Speaking of your equipping methods, the way you're handling it is completely wrong. You should be holding a reference to what the player is equipping so you can call upon that, instead of incrementing a variable that holds no real information, nor can be checked against to see if something is equipped or not.