I am having a strange problem. Whenever I attempt to use a record in a map at the end of the script the map only contains the data from the last record...
I.E:
This psuedo code (when implemented) always fills all records in the map with the contents of the last assignment.
To explain a little better, if I assign aRec.always_the_same with any three Diffrent values the last for each loop will always only print the value of the last aRec assignment. It will associate the same value with all three keys.
Here is the entire code: (Hint: Search for #****PROBLEM***# to find it easily)
Oh, and sorry bout the mess.... Thank you in advance to anyone willing to help out.
I.E:
This psuedo code (when implemented) always fills all records in the map with the contents of the last assignment.
Code:
Record aRec
{
string always_the_same;
};
aRec[string] aMap;
aRec temp_Record;
<Populate aRec>
aMap["one"] = aRec;
<Clear and repopulate aRec>
aMap["two"] = aRec;
<Clear and repopulate aRec>
aMap["three"] = aRec;
foreach key in aMap
{
<print aMap[key] contents>
}
To explain a little better, if I assign aRec.always_the_same with any three Diffrent values the last for each loop will always only print the value of the last aRec assignment. It will associate the same value with all three keys.
Here is the entire code: (Hint: Search for #****PROBLEM***# to find it easily)
Oh, and sorry bout the mess.... Thank you in advance to anyone willing to help out.
Code:
string getmodsFile = "modifiers.txt"; #Where to find the data for modifiers
string getoutfitsFile = "outfits.txt"; #Where to find the data for outfits
string equipmentDataFile = "c_equip.txt"; #Where to put new modifier map file
string outfitDataFile = "c_outfit.txt"; #Where to put new outfit map file
Record modRec
{
string item_mod;
};
Record outfitDataRec
{
item hat;
item pants;
item shirt;
item weapon;
item offhand;
item acc1;
item acc2;
item acc3;
string mod;
};
#modRec [string] tempItemModMap;
string [slot, item] itemModMap;
outfitDataRec[string] outfitModMap;
void execute()
{
}
#string lookup_effect(
void print_ODRecord(outfitDataRec i)
{
print ("__________");
print ("Hat: "+to_string(i.hat));
print ("Shirt: "+to_string(i.shirt));
print ("Pants: "+to_string(i.Pants));
print ("Weapon: "+to_string(i.weapon));
print ("OffHand: "+to_string(i.offhand));
print ("ACC1: "+to_string(i.Acc1));
print ("Acc2: "+to_string(i.acc2));
print ("Acc3: "+to_string(i.acc3));
print ("Mod: "+i.mod);
print ("__________");
}
void install()
{
slot item_slot; #Slot for mapping items
item item_item; #item for mapping items
item [int] tIE; # temp Intrinsic Effect map to replace all instances of intrinsic effects
# with their actual modifier.
string [string] tEffectMap; # map of effect modifiers keyed by effect name.
int c=0; #a counter
string sString;
modRec [string] tempItemModMap;
#string [string] tempItemModMap;
# modRec [string, string] tempOutfitMap; #used to read the outfits.txt
string [int, string] tempOutfitMap; #used to read the outfits.txt
if (!(file_to_map(getmodsFile, tempItemModMap)))
{
cli_execute("Abort Modifiers.txt could not be loaded.");
}
if (!(file_to_map(getoutfitsFile, tempOutfitMap)))
{
cli_execute("Abort outfits.txt could not be loaded.");
}
#Load outfits into the new format.
int AccCount = 0;
string [int] parts;
outfitDataRec tODRec;
slot tSlot;
item nullItem = to_item("");
foreach i in tempOutfitMap
{
string[string] ii = tempOutfitMap[i];
AccCount=0;
foreach s in ii
{
tODRec.hat=nullItem;
tODRec.pants = nullItem;
tODRec.shirt = nullItem;
tODRec.weapon = nullItem;
tODRec.offhand = nullItem;
tODRec.Acc1 = nullItem;
tODRec.Acc2 = nullItem;
tODRec.Acc3 = nullItem;
tODRec.mod="NONE";
parts = split_string(tempOutfitMap[i,s],",");
foreach p in parts
{
tSlot = to_slot(to_item(parts[p]));
if (tSlot==$slot[Hat]){tODRec.hat = to_item(parts[p]);}
if (tSlot==$slot[Pants]){tODRec.pants = to_item(parts[p]);}
if (tSlot==$slot[Shirt]){tODRec.shirt = to_item(parts[p]);}
if (tSlot==$slot[Weapon]){tODRec.weapon = to_item(parts[p]);}
if (tSlot==$slot[Off-hand]){tODRec.offhand = to_item(parts[p]);}
if (tSlot==$slot[Acc1]){
if (AccCount==0){tODRec.acc1 = to_item(parts[p]);}
if (AccCount==1){tODRec.acc2 = to_item(parts[p]);}
if (AccCount==2){tODRec.acc3 = to_item(parts[p]);}
AccCount = AccCount+1;
}
# print (parts[p]+"::"+to_string(to_slot(to_item(parts[p]))));
}
#****PROBLEM***#
#****Obviously this ISN'T where the problem originates, but it is where the problem can most
#****easily be observed.
print (s);
print_ODRecord(tODRec);
outfitModMap[s]=tODRec;
print_ODRecord(outfitModMap[s]);
}
# print (tempOutfitMap[i]);
# print (i);
}
map_to_file(outfitModMap,"DebugFile");
#load all the effects into the map.
boolean done = false;
foreach i in tempItemModMap
{
if (to_string(to_slot(to_item(i))) != "NONE") #Make sure it is an equipable item and not an outfit, skill, etc.
{
if (tempItemModMap[i].item_mod != "NONE") #Make sure it has an effect
{
item_slot = to_slot(to_item(i));
item_item = to_item(i);
itemModMap[item_slot, item_item] = tempItemModMap[i].item_mod;
if (index_of(tempItemModMap[i].item_mod, "Intrinsic") >= 0)
#This item has an intresic effect so put it on the list to be fixed later
{
tIE[c] = to_item(i);
c=c+1;
}
}
} else {
#It is not an equipable item, but it may be an intrinsic effect, or an Outfit effect
done = false;
foreach s in outfitModMap
{
#print (s);
#print (i);
if (s==i)
{
#outfitModMap[s].mod = tempItemModMap[i].item_mod;
# Print ("MATCH-----------------"+s+"::"+i);
done = true;
break;
}
}
if (!done) {tEffectMap[i]=tempItemModMap[i].item_mod;} #Store it for later use as an intrinsic effect
}
}
foreach s in outfitModMap
{
# print_ODRecord(outfitModMap[s]);
}
#Replace Intrinsic effects with their actual effect.
foreach effect in tEffectMap
{
foreach item in tIE
{
if(index_of(itemModMap[to_slot(tIE[item]), tIE[item]], effect) >=0)
{
print(itemModMap[to_slot(tIE[item]),tIE[item]] + "::" +effect+ "::" + tEffectMap[effect]);
sString = "Intrinsic Effect: \""+effect+"\"";
itemModMap[to_slot(tIE[item]),tIE[item]]=replace_string(itemModMap[to_slot(tIE[item]),tIE[item]],sString ,tEffectMap[effect]);
# print (itemModMap[to_slot(tIE[item]),tIE[item]]);
}
}
}
map_to_file(itemModMap,equipmentDataFile);
print ("Installation complete.");
}
void main()
{
# if (!(file_to_map(equipmentDataFile, itemModMap)))
# {
install();
# }
execute();
}