Question: Moving Items In Inventory

bjcasey

ISX Specialist
Steps:

1. Create a level 1 Ranger. I made mine with the starting city of New Halas.
2. Move a stack of arrows from your ammo bag to any of the other bags except bag 1.
3. Run the script below.

It should move the stack of arrows Bag 1, Slot 1. It does not and I don't understand why. When testing, I was able to have it move the arrows to a random available slot by using the :Move[NextFreeNonBank,200] method. Any assistance would be greatly appreciated.

Code:
variable int FirstSlotContainerID

function main()
{
	echo ${Time}: Starting Inventory Move Test...
	
	call InitializeInventory
	call MoveItem
}

function InitializeInventory()
{	
	variable int i = 1
	variable int Timer = 0

	echo ${Time}: Initializing Inventory Contents...
	
	Me:CreateCustomInventoryArray[nonbankonly]
	wait 5

	do
	{
		if (!${Me.CustomInventory[${i}].IsInitialized})
		{
			Me.CustomInventory[${i}]:Initialize
			Timer:Set[0]
			do
			{ 				
				wait 1
				Timer:Inc
			}
			while (!${Me.CustomInventory[${i}].IsInitialized} && ${Timer} < 30)
		}	
		
		if ${Me.CustomInventory[${i}].IsInventoryContainer} && ${Me.CustomInventory[${i}].Slot} == 0
		{
			FirstSlotContainerID:Set[${Me.CustomInventory[${i}].ID}]
			echo \at${Time}: ${i} of ${Me.CustomInventoryArraySize}: [${Me.CustomInventory[${i}].Name}] is the first bag in inventory. ID: ${Me.CustomInventory[${i}].ID}\aw			
		}			
	}
	while ${i:Inc} <= ${Me.CustomInventoryArraySize}	
}	

function MoveItem()
{
	variable int i = 1
	variable int Timer = 0
	
	echo ${Time}: Searching for items to move...
	
	i:Set[0]
	
	do
	{
		echo ${Time}: ${i} of ${Me.CustomInventoryArraySize} -- ID: ${Me.CustomInventory[${i}].ID} -- Name: ${Me.CustomInventory[${i}].Name}
		
		if ${Me.CustomInventory[${i}].InInventory} == TRUE
		{			
			if  ${Me.CustomInventory[${i}].Name.Find[Arrow]}
			{	
				echo ${Time}: Moving ${Me.CustomInventory[${i}].Name} -- Me.CustomInventory[${i}]:Move[0,${FirstSlotContainerID},200]
				Me.CustomInventory[${i}]:Move[0,${FirstSlotContainerID},200]
				wait 40				
			}
		}			
	}
	while ${i:Inc} <= ${Me.CustomInventoryArraySize}
	
}

function atexit()
{
	echo ${Time}: Ending Inventory Move Test...
}
 

bjcasey

ISX Specialist
On a character with bags that are not the same name, Me.CustomInventory[${i}]:Move[NextFreeNonBank,200] correctly moves the arrows to the first available nonbank slot.

On a character with bags that are all the same name, Me.CustomInventory[${i}]:Move[NextFreeNonBank,200] seems to randomly place the arrows into an available slot. Each time it was a different slot, but not the first container.
 

CyberTech

Second-in-Command
Staff member
Item.ID (CustomInventory.ID) returns unsigned int (lstype uint), but you're using int for FirstSlotContainerID. Not sure it'll make a difference, i'd think it would usually silently cast back and forth, but give it a try.
 
Top Bottom