Thanks, I appreciate the kind words on my script. Makes me feel good that other people find it as helpful. It started because I was trying to mod this old Razeil one and didn't like how it worked and how hard it was to customized. If I recall right, the think even would pull a book, drop a bod, return the book over and over again instead of dropping all the bods for that book at that time. So these were the things I wanted to focus on- making it customizable for what a person wants AND to make it more efficient. I am sure there are many ways to problem solve it, but when I wrote it at this time, I was huge into looking up information security, cryptology, and hash functions. That is the core of this script. It hashes the bods (value associated) but in hind sight, I could simply concat the values into a string, and I *may* change this.
i.e.
The bod gets assigned values for
Size (Large/Small)
Quality (Exceptional/Normal)
Material (iron/dull/etc..)
Amt (10/15/20)
Item (Ring/Chain/Plate/blah)
Imagine a small, exceptional, shadow iron ingot, 20, ringmail sleeves
And a small, exceptional, shadow iron ingot, 20, chainmail sleeves
The bod values are { 1,2,3,20,1 } and { 1,2,3,20,2 }
I hash those values
Hash( 1,2,3,20, 1 )
Hash( 1,2,3,20, 2 )
Which returns two values that are different. The sorter then looks up those hash values which are keys in the index associated with a string, that string is the name of the book.
Index[ Hash( 1,2,3,20,1 ) ] = Book For this Reward
Index[ Hash( 1,2,3,20,2 ) ] = Book for another reward
However, I realize that I could simple use
Index[ "123201" ]
Index[ "123202" ]
But alas, what's done is done and the result probably isn't any different.
What's faster, appending a value to a string or hashing a few values, I'm not entirely sure.
The issue here is that I would be calling a lot of functions
tostring(1)..tostring(2)..tostring(3)..tostring(20)..tostring(1)
veruss
sum = 0
sum = sum * 41 + 1
sum = sum * 41 + 2
sum = sum * 41 + 3
sum = sum * 41 + 20
sum = sum * 41 + 1
sum = sum % 67735
Which is faster? I don't know. tostring(1) undoubedtly is a mathmatically operation to turn the number value into the ascii (or UTF/UNICODE) value associated with it, and then string concat I have absolutely no idea since I'm unfamiliar with pascal memory management. In C++ I believe a string is a contigious block of memory so it would involve memory allocation and movement. In short, would it be worth my effort to make the sorting guts easier for others to understand and an index that is intuitive to look at? Short answer, it's fast enough so I will probably never change this aspect.