Countitems

Main.Countitems History

Hide minor edits - Show changes to markup

December 31, 2008, at 01:27 AM EST by admin
Added lines 1-19:
     countitems - syntax: countitems(CH,"object key",[option]) 

Like carries() but returns how many instances of the item the player is carrying. The only option is LP_ALLOBJS which will include worn items, otherwise only items in inventory are counted.

Usually we only care if a character carries an item at all and carries() is still preferable in those cases as it runs faster.

    --- Character must have at least 10 iron ores to continue
    if countitems(ch,"dsr-2") < 10 then
       say("You need at least 10 iron ores for my services!")
       return
    end

    --- do whatever in the prog.

    --- Now we need to remove them. Can't just use destroy with obj key and all
    --- as they might be carrying more than 10.
    for onum = 1,10,1 do destroy(ch,"dsr-2",LP_SEEALL+LP_ONEONLY) end