i have an equip code but i get a runtime error everytime here it is:runtime error: type mismatch
proc name: equip (/mob/verb/equip)
usr: Vegetto5748 (/mob)
src: Vegetto5748 (/mob)
call stack:
Vegetto5748 (/mob): equip()
can anyone tell me whats wrong with this code? mob
verb
equip()
if(usr.contents<=1)
usr<<"You equip the item"
else
usr<<"You dont have any itmes"
return
ID:179747
Nov 14 2001, 2:31 pm
|
|
Vegetto5748 wrote:
verb There are actually a couple of problems here. For one thing, as Nadrew mentioned, usr.contents isn't a number; it's a list, so comparing it to 1 is giving you that error. The other problem is that your code doesn't really do anything; it just prints out a message. I suggest this instead: var/obj/weapon Each obj should have var/isweapon set, with weapons setting this to 1 and other items set to 0. There are lots of other ways to do this, though, and this is a pretty simple example. (Notice you also need an unequip verb that sets weapon=null. This code will automatically unequip your current weapon and replace it with a different one.) My preferred method would be to create a lot of objects like this: obj/item/equipment/weapon obj/item/equipment/armor obj/item/equipment/shield ... A more sophisticated system would then declare equip(obj/item/equipment/O), which would limit the list to only equippable items. Fancier equipment systems are also possible. Lummox JR |
contents isn't a number, try downloading my weapon system in the demos section it will help you.