I want to identify pre-defined patterns as well as check afterwards if i have multiple patterns in my bags.
The identifying process works quite well so far, but i was trying to put the pattern which appear more than once in a table.
i created three tables.
fPattern where i store my "fixed" defined patterns in the file
vPattern where is store alle appearing patterns in vPattern[1] to compare this with the rest in my bag. As i am proceeding all Fusion patterns pass through vPattern[1] as the comparison pattern...i know, i have to check for doubles, but thats for later
tPattern finally is where i store all the patterns which i found appear multiple times (at least 2 times)
My problem is, when printing tPattern ALL patterns are the same and are the LAST vPattern i found and moved into the table. So i may certainly mess up with the table.
Perhaps i make something completely stupid, but i don't know other syntax for the move^^
Code: Select all
fPattern = {}
fPattern[1] = { Count = 0,
Stat1 = "Ausdauer I",
Stat2 = "Intellekt I"}
fPattern[2] = { Count = 0,
Stat1 = "Ausdauer I",
Stat2 = "Intellekt I",
Stat3 = "Fähigkeit"}
vPattern = {}
vPattern[1] = { Count = 0,
Stat1 = "Dummy",
Stat2 = "Dummy",
Stat3 = "Dummy"}
tPattern = {}
Code: Select all
-- item is actual Fusion stone in bag to be verified
-- vPattern is actual pattern to search for
-- check_Fusion returns true if the item / Fusion Stone Stats correspond to the vPattern
if check_Fusion(item,vPattern) then
tPatternC = tPatternC +1
tPattern[tPatternC] = vPattern[1]
printf(item.Name.." in Slot: "..i.."\n")
end
printPattern(tPattern)
tPattern[tPatternC] = vPattern[1]
After that all entries of tPattern are the same and are same as LAST vPattern[1]
tPattern[1]
tPattern[2]
tPattern[3]
tPattern[4]
tPattern[5]
tPattern[6]
...
Where is my fault ?
edit:
I tried to assign different values directly...in the end all tPattern.Count have the value 22....
Code: Select all
vPattern[1].Count = 7
tPattern[1] = vPattern[1]
vPattern[1].Count = 9
tPattern[2] = vPattern[1]
vPattern[1].Count = 22
tPattern[14] = vPattern[1]
I also tried
Code: Select all
table.insert(tPattern,vPattern[1])
edit 3:
Well i am not really good in lua...but is it possible, that with moving vPattern[1] into the table will be stored the adress/pointer to that vPattern[1] only and NOT the actual values ?
That would explain, why all entries change value once changing vPattern. But if so, how to move it by value and not by address ?