Scripting help with inventory

Discussion in 'Fallout General Modding' started by MIB88, Mar 29, 2015.

Thread Status:
Not open for further replies.
  1. MIB88

    MIB88 So Old I'm Losing Radiation Signs
    Modder

    Feb 22, 2005
    Looking for some help with something. I am trying to come up with a way to count specific items in a critter's inventory. I am not looking for a simple =, <, or > value. I want to be able to call the exact number of instances of a certain item in inventory. For example, while talking to Sentrybot Skynet, it could tell you it has seven rockets in its arsenal, without having to write dialog and code for however many instances of ==.

    Anyone out there have an idea how I can do this? If not, I guess I could keep it simple and write code for 1-10 rockets. Then after that, Skynet can say it has more than 10 in inventory. That would kinda work in this instance. However, I have other ideas I want to try to implement where counting may prove useful.
     
    Last edited: Mar 29, 2015
  2. phobos2077

    phobos2077 Mildly Dipped
    Modder

    596
    Apr 24, 2010
    I'm not really sure what you want, because there never been any problem counting specific items in inventory by PID:
    Code:
    int obj_is_carrying_obj_pid(ObjectPtr obj, int pid)
    Example:
    Code:
    display_msg("That guy has " + obj_is_carrying_obj_pid(that_guy, PID_STIMPAK) + " stimpaks."); 
    In sfall 3.6 there is also a function to count instances of specific object in inventory (obj_is_carrying_obj), so you can get the size of specific stack when you have several different stacks with the same PID (for instance - weapons with different ammo type and count).
     
    Last edited: Mar 29, 2015
  3. MIB88

    MIB88 So Old I'm Losing Radiation Signs
    Modder

    Feb 22, 2005
    Well, that does it. I know, I know: it might seem silly that I needed help with something so basic. I kid you not, though: I use op_obj_is carrying_obj_pid all the time, and I never knew it could be used to return an exact number of an item. Thank you very much.
     
Thread Status:
Not open for further replies.