Testing contents of leveled lists

Post » Sun Aug 08, 2010 2:50 pm

I am trying to upgrade ammo lists using a script. Using AddItemToLeveledList works just fine and the ammo lists are updated as expected.

What I would like to do next is create a test condition to prevent that code section from running a second time should the script be run again. And that is where I am running into a wall. I cannot find a method to check if a leveled lists contains a entry for another leveled list.

Here is my current code running in a gamemode block of a quest script. It compiles but does not function. Any ideas?

Set rListAmmo to LootAmmoBullets100 IF (ListGetFormIndex rListAmmo xCalxLootAmmo) == -1	AddItemToLeveledList LootAmmoBullets100 xCalxLootAmmo 0 10 1EndIF

User avatar
TIhIsmc L Griot
 
Posts: 3405
Joined: Fri Aug 03, 2007 6:59 pm

Post » Sun Aug 08, 2010 1:07 pm

I am trying to upgrade ammo lists using a script. Using AddItemToLeveledList works just fine and the ammo lists are updated as expected.

What I would like to do next is create a test condition to prevent that code section from running a second time should the script be run again. And that is where I am running into a wall. I cannot find a method to check if a leveled lists contains a entry for another leveled list.

Here is my current code running in a gamemode block of a quest script. It compiles but does not function. Any ideas?

Set rListAmmo to LootAmmoBullets100 IF (ListGetFormIndex rListAmmo xCalxLootAmmo) == -1	AddItemToLeveledList LootAmmoBullets100 xCalxLootAmmo 0 10 1EndIF



And what's the problem with a standard DoOnce var?
User avatar
luis ortiz
 
Posts: 3355
Joined: Sun Oct 07, 2007 8:21 pm

Post » Sun Aug 08, 2010 10:03 pm

Users have an uncanny ability to find new and creative ways to screw things up in ways modders can never anticipate. I am trying to create a self-repair script that goes through the various environmental changes the mod makes, and repairs any that are not set up properly for one reason or another.
User avatar
Phillip Brunyee
 
Posts: 3510
Joined: Tue Jul 31, 2007 7:43 pm

Post » Sun Aug 08, 2010 8:17 pm

If xCalXLootAmmo is a formlist, I think you'd need to step through it one entry at a time via listgetnthform and the LABEL/GOTO commands rather than trying to check for the whole thing at once.
User avatar
Miguel
 
Posts: 3364
Joined: Sat Jul 14, 2007 9:32 am

Post » Sun Aug 08, 2010 11:26 am

xCalXLootAmmo is a compound leveled list containing other leveled lists. Leveled lists are handled differently from form lists which is my problem.

Do the FOSE list commands read a leveled list entry or do they specify the calculated results of leveled lists?
User avatar
Jynx Anthropic
 
Posts: 3352
Joined: Fri Sep 08, 2006 9:36 pm

Post » Sun Aug 08, 2010 10:14 pm

I think the FOSE List* commands are for formlists and not for leveled lists.

You could try if the following stage function works
; (Index 1) Is element  in list?; Local Varsshort ishort sizeref inputListref elementref currentElement; Read & Clear Inputset inputList to ListUtil.inputListset element to ListUtil.elementset ListUtil.inputList to 0set ListUtil.element to 0set ListUtil.found to 0set i to 0set size to (listGetCount inputList)label 1if i < size	set currentElement to listGetNthForm inputList i	if currentElement == element		set ListUtil.found to 1		return	endif		set i to i + 1	goto 1endif


Called via

set ListUtil.inputList to LootAmmoBullets100 set ListUtil.element to xCalxLootAmmosetStage ListUtil 1set found to ListUtil.foundif found == 0	AddItemToLeveledList LootAmmoBullets100 xCalxLootAmmo 0 10 1endif


But i dont think this will work.

Anyway, have you tried whether its even possible to add the same item twice? I think for formlists it isnt.
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Sun Aug 08, 2010 12:09 pm

Formlists are one dimensional so they only retain a single instance of an object. I don't bother testing when updating to repair lists, but leveled lists have quantity so sequential adds seem to stack.

I guess I'll admit defeat and use a global variable as an indicator.
User avatar
Lisha Boo
 
Posts: 3378
Joined: Fri Aug 18, 2006 2:56 pm

Post » Sun Aug 08, 2010 8:40 pm

Formlists are one dimensional so they only retain a single instance of an object.


Thanks, not knowing that could really have screwed me up while making the compatibility patch for the FWE and the next release of Powered Power Armor - I was going to have fitted power armors break down into unfitted components to reduce the total number of broken sets of power armor I'd need to create, but that would have required having some broken sets show up more than once in the formlists I'm using to keep track of it all (I'm treating 3 formlists of equal length and specific order as a 2 dimensional array).
User avatar
Tracy Byworth
 
Posts: 3403
Joined: Sun Jul 02, 2006 10:09 pm


Return to Fallout 3