ID:173324
 
Ok in my battle system I need help on using a item when the command box comes up if you choose item how do I get it to execute the effect of the item in the inventory?
obj
Knife //a basic Knife
price = 20
Click()
//here you enter what the item will do
// eg useKnife() this would start a proc called useKnife

Here's a small demo for you:

obj
spells
proc
Cast(mob/User,mob/Attacked)//define the parent proc
fire
Cast(mob/User,mob/Attacked)//Notice, it's the same proc name, except you don't have to redefine it as, proc/Cast(), just Cast(). Define "mob/User" for the person casting the spell. And, "mob/Attacked" for the enemy.
// ..()//Optional if you wish to call the parent procedure (in this case it'd be redundant since we don't have a standard procedure)
//Do your spell here

mob
verb
Attack(mob/M in oview(6,usr))//Define an enemy to attack within 6 tiles of the user
var/obj/spells/S=switch(input(usr,"What spell do you wish to use?")) in usr.spells|null
if(S)
spawn(1)
S.Cast(usr,M)