Need a bit of help setting up a loop

Post » Tue Jun 19, 2012 10:34 am

I'm trying to clean up a script by converting it from an ultra-long If statement into a While loop, but am unsure how to cast the arrays I have set up in this context.

The ultimate goal: each time the loop is run, it checks if the player has any items that are defined in the Imports array (each value in the array has been set to an item reference, which is why the arrays are defined as properties). If he does, they are replaced with the equivalent item defined in the Base array.

Ingredient[] Property Imports autoIngredient[] Property Base autoInt property ItemCountInt autoFunction ReplaceObject(Ingredient[] Imports, Ingredient[] Base)	int CurrentElement = 0While (currentElement < Imports.Length)		if Imports.length == base.length			Int ReplaceElement = base.Length			ItemCountInt = (game.getPlayer().getItemCount(currentElement))				game.getPlayer().RemoveItem (currentElement, true)		game.getPlayer().addItem (ReplaceElement, true)				currentElement += 1				endIf	endWhile	endFunction
User avatar
:)Colleenn
 
Posts: 3461
Joined: Thu Aug 31, 2006 9:03 am

Post » Tue Jun 19, 2012 1:50 pm

Check your thread over at TESAlliance :wink:
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm


Return to V - Skyrim