Making list of inventory

Discussion in 'General Modification' started by marc1967, Mar 4, 2015.

Remove all ads!
  1. marc1967

    marc1967 Established Member

    Joined:
    Jan 19, 2014
    Messages:
    706
    Likes Received:
    112
    That's very nice to know, I'll be careful when doing that.


    I'll definitely do some math before making any kind of mass transfer like that.

    To help with that, here's another handy function that makes use of the new and improved item_worn_at() dll hack. It returns how many inventory slots are open. It only handles pc's and npc's at the moment because I'm still not sure about the slot limit in chests. (still exploring)

    Code:
    def inv_slots_open (npc):
    	open = 0
    	if npc.type in [obj_t_npc,obj_t_pc]:
    		for s in range(100,124):
    			item = npc.item_worn_at(s)
    			if item == OBJ_HANDLE_NULL:
    				open += 1
    	return open
    This could be useful when giving players items. This example dialog checks for four open slots before allowing the dialog option to make the transfer.

    Code:
    {10}{Here's your reward for completing the quest, it's four potions}{Here's your reward for completing the quest, it's four potions}{}{}{}{}
    {11}{Thank you kind sir!}{}{1}{inv_slots_open(pc) >= 4}{0}{give_reward(pc)}
    {12}{I will return for my reward, I need to make room for four items in my pack.{}{1}{inv_slots_open(pc) < 4}{0}{}
    
     
Our Host!