Well I have now rewritten the above section of code so that it now uses a pseudo list. However, I still have the same problem - one of the placeables is not being updated. There is some weird bug in the following code.
void ChangeAllWindows(string sNewLetter)
{
int iIndex = 1;
int iMatchedCount = 0;
string sLastChar;
object oPC = GetFirstPC();
object oWindow = GetNearestObjectByTag("ES_SG_Win", oPC, iIndex);
while(oWindow != OBJECT_INVALID)
{
sLastChar = GetStringRight(GetResRef(oWindow), 1);
debug("Index = " + IntToString(iIndex) + " - " + GetResRef(oWindow) + " - " + GetName(oWindow));
if(sLastChar != sNewLetter)
{
PushDetails(oWindow, sNewLetter, iMatchedCount);
iMatchedCount++;
}
iIndex++;
oWindow = GetNearestObjectByTag("ES_SG_Win", oPC, iIndex);
}
2 things to note. iIndex is initialised to 1 in preparation for it to be used as parameter nNth as per the lexicon. I have a very small debug function that sends messages to both the pc and the log file. The call to it in the above code snippet produced the following output (with 1 instance of each of the 27 placeables in the area).
Index = 1 - es_sg_window05l - ES SG Window 05 (Kynareth) Light
Index = 2 - es_sg_window06l - ES SG Window 06 (Mara) Light
Index = 3 - es_sg_window04l - ES SG Window 04 (Julianos) Light
Index = 4 - es_sg_window05e - ES SG Window 05 (Kynareth) Dusk
Index = 5 - es_sg_window06e - ES SG Window 06 (Mara) Dusk
Index = 6 - es_sg_window07l - ES SG Window 07 (Stendarr) Light
Index = 7 - es_sg_window04e - ES SG Window 04 (Julianos) Dusk
Index = 8 - es_sg_window03l - ES SG Window 03 (Dibella) Light
Index = 9 - es_sg_window07e - ES SG Window 07 (Stendarr) Dusk
Index = 10 - es_sg_window05d - ES SG Window 05 (Kynareth) Dark
Index = 11 - es_sg_window06d - ES SG Window 06 (Mara) Dark
Index = 12 - es_sg_window06d - ES SG Window 06 (Mara) Dark
Index = 13 - es_sg_window04d - ES SG Window 04 (Julianos) Dark
Index = 14 - es_sg_window08l - ES SG Window 08 (Talos) Light
Index = 15 - es_sg_window07d - ES SG Window 07 (Stendarr) Dark
Index = 16 - es_sg_window02l - ES SG Window 02 (Arkay) Light
Index = 17 - es_sg_window08e - ES SG Window 08 (Talos) Dusk
Index = 18 - es_sg_window03d - ES SG Window 03 (Dibella) Dark
Index = 19 - es_sg_window02e - ES SG Window 02 (Arkay) Dusk
Index = 20 - es_sg_window08d - ES SG Window 08 (Talos) Dark
Index = 21 - es_sg_window09l - ES SG Window 09 (Zenithar) Light
Index = 22 - es_sg_window09e - ES SG Window 09 (Zenithar) Dusk
Index = 23 - es_sg_window02d - ES SG Window 02 (Arkay) Dark
Index = 24 - es_sg_window01l - ES SG Window 01 (Akatosh) Light
Index = 25 - es_sg_window01e - ES SG Window 01 (Akatosh) Dusk
Index = 26 - es_sg_window09d - ES SG Window 09 (Zenithar) Dark
Index = 27 - es_sg_window01d - ES SG Window 01 (Akatosh) Dark
The question is "What is causing the duplication on the 11th and 12th passes and why is the object with the resref of es_sg_window03e being missed? I cannot see any errors in the blueprints either. TBH I am stumped. Ideas anyone?
TR