Re: Bazaar.mac Maintained by ~Chat
it was just a thought, its not needed thing by any means
with regards to
I was saying to have it set all "selling_at_#=" cells for an item to zero before comparing price to minSellPrice that way they get reset every time it runs so's you get the current average.
like I said it was just a thought, and I do see your point of "intended objective for the trader side of this has macro has been reached" and your right its probably a lot more effort than I thought it would be, but I am still going to try to figure it out, doing so will be a learning experience, though I expect to have a lot of failures along the way, and don't know when I will succeed, or if I will for that matter.
PS. you work on this (& other mac)'s is appreciated by not just me but the masses here
Basically you would have to declare an array that is 100x3, That's 100 entries with 3 entries per slot. Then make it a string. /declare StartingItems[100,3] string outer -1
Then in a for loop that cycles through the items in the trader window you would need to use varset's to set each component to the desired value.
/varset StartingItem[${i},1] ${Window[BazaarWnd].Child[BZR_BazaarSlot${slot}].Tooltip}
/varset StartingItem[${i},2] ${FindItemCount[=${Window[BazaarWnd].Child[BZR_BazaarSlot${slot}].Tooltip}]}
/varset StartingItem[${i},3] ${Window[BazaarWnd].Child[BZW_Money0].Text}
Where the first item is the name, the second one is the quantity, and the third is the price assigned to it per item.
Then on every update you would need to create ANOTHER array /declare CurrentItem[100,3] string outer -1
then populate it with the new existing values for all the items.
Then you would have to compare the two arrays to each other.
/if (${StartingItem[${i},1].NotEqual[${CurrentItem[${j},1]}]}) {
/echo ${StartingItem[${i},1]} Sold!
/varcalc platThisSession ${platThisSession} + ${StartingItem[${i},3]}
/echo I've now made ${platThisSession} so far.
} else /if (${StartingItem[${i},2].NotEqual[${CurrentItem[${j},2]}]}) {
/echo The quantity of ${StartingItem[${i},1]} has changed. I had ${StartingItem[${i},2]}, but now I have ${CurrentItem[${j},2]}
/varcalc platThisSession ${platThisSession} + ${Math.Calc[${Math.Calc[${Int[${StartingItem[${i},2]}]}-${Int[${CurrentItem[${j},2]}]}]}*${Int[CurrentItem[${i},3]}]}
}
I'm not even sure that's all accurate, but that's basically the gist of what would need to happen. Obviously you'd have to declare platThisSession.
That also doesn't cover all conditions, IE: If the item is missing you would have to varcalc j ${j}+1, the comparison would have to be in a goto loop as opposed to a for loop. that way i and j could iterate at the same time, and then iterate j up one if there is an item missing. after calculating the differences and adding platThisSession you would then need to overwrite the both arrays -1 to cancel out any existing entries, then repopulate the StartingItem array to ready it for the next update comparison.
Also for items that stack I didn't try and calculate the value if all items were missing so that currentitem array had the quantity multiplied etc.
It's going to be quite a bit of work and testing.
To populate the arrays I recommend a sub where you pass the array name as a parameter
the same to clear the arrays.
Sub ClearArray(Array)
/declare i int local 0
/for i 0 to 100
/varset Array[${i},1] -1
/varset Array[${i},2] -1
/varset Array[${i},3] -1
/next i
/return
/call ClearArray ${StartingItem}
Then of course once you see that you've sold something you would have to make the ini entry.
/ini "Bazaar.ini" "${StartingItem[${i},1]}" "
selling_at_#" "${StartingItem[${i},3]}"
Calculating the # to use prior to the INI entry elsewhere in the program and use that in place of # in the INI string...calculating that number per item would require reading the INI.
/for k 0 to 100
/if (!${Ini[Bazaar.ini,${StartingItem[${i},1]},selling_at_${k}].Length}) {
/ini "Bazaar.ini" "${StartingItem[${i},1]}" "
selling_at_${k}" "${StartingItem[${i},3]}"
/break
}
/next k
Which would create a new entry at ${k} and then exit the loop
Then another to calculate the average
/for l 0 to 100
/if (${Ini[Bazaar.ini,${StartingItem[${i},1]},selling_at${l}].Length}) {
/varCalc thisTotal ${thisTotal}+${Ini[Bazaar.ini,${StartingItem[${i},1]},selling_at${l}]}
} else {
/varcalc Average ${Math.Calc[${thisTotal}/${l}]}
/ini "Bazaar.ini" "${StartingItem[${i},1]}" "Average" "${Average}
}
/next l
Keep in mind at this point we've nested i, j, k, and l loops. Which is like saying
/for i 0 to 100
/for j 0 to 100
/for k 0 to 100
/for l 0 to 100
/next l
/next k
/next j
/next i
The i and j loops are comparing 3 different entries, up to 100 each, that's up to 600 comparisons.
k is doing another 100 comparisons, and l another 100 comparisons.
Potentially up to 800 comparisons.
If every loop ran all 100 iterations nested inside of one another that would be 100 million iterations.
While it is true that programmatically these will calculate faster than any of us could do on paper. It's also going to use resources that could potentially cause significant delays in response.
So that's basically the theoretical application of such a thing. It's quite in depth and not even all the code that would be required.