TSM4 Guide part 13: Advanced pricing strings using logic functions

Following on my introduction to custom prices last week we will now take a deeper look at how powerful the pricing string functionality in TSM is. We will look at how you can combine value sources and the logic functions to make very powerful pricing sources.

Pricing string functionality rundown

Firsst we will take a quick rundown of the functionality you can use. Pricing strings support refering to the value source for a specific item, simple mathematical functions and logic functions like ifgte() and round(). We will go through all of this in a bit of detail and then show some cool examples of useful and well known strings and go through why they are the way they are.

Basic mathematics

All of your pricing operations can use simple arithmetic like addition, subtraction, multiplication and division. Obviously you will be familiar with percentages as most of my operations use various percentages such as 120% crafting which evaluates to 1.2*crafting.

You can use arithmetic to combine various price sources or to modify a value source with another value source. The most frequent way you want to use this is of course to simply add the cost of two different pricing sources together. You will also usually want to use this to get different multiples of the same price string for your minimum, normal and maximum prices. For instance 120% crafting as minimum, 200% crafting as normal and 500% crafting as maximum.

Referring to the cost of a specific item

I showed this one a bit earlier in my last post in this guide. I use this in my Expulsom price source. To do this you just add a parenthesis after the name of the value source and then write “i:” followed by the itemID of the item you want to refer to. ItemIDs can be found by looking up the item on wowhead, and it will be the number in the web address.

This is very useful, particularly for making pricing strings for BoE materials, as well as making strings that evaluate the expected value of processes with random outcomes such as disenchanting and prospecting. 

To use it for this you would simply make an easy formula for expected value by multiplying the chance of one of the outcomes with the yields. So for prospecting we would multiply the chance of each gem per ore for each of the gems and then add them all together.

Using logic functions

TSM also has a nice number of logic functions. These can be used to find the minimum of two values, the maximum, to round a number or to compare numbers to see which is higher, just to list a few.

Below is a list of all the logic functions that are documented on the TSM website.

  • min()
  • max()
  • first()
  • check()
  • convert()
  • ifgt()
  • ifgte()
  • iflt()
  • iflte()
  • ifeq()
  • round()
  • roundup()
  • rounddown()

As you can see the list is quite long, but luckily we can group them up as a lot of them have similar functionality.

Min() and max()

Min and max will return either the minimum or maximum value. To use it you simply type min(crafting,dbmarket) for instance. This will return the minimum value of crafting or dbmarket. Min and max are both useful in pricing strings where you want to compare two sources. A simple examples i 120%max(avgbuy,dbmarket). This will return the largest of the two sources and is useful in flipping operations to ensure that you never post your items for less than you bought them for.

First()

First will simply return the first valid price source. You can use this to check for dbmarket for a rare item and then revert to the regionmarketavg if it cannot find dbmarket.

Check()

Check was the old way to use if-style logic, it has essentially been turned meaningless by the addition of explicit if functions, so I won’t go into it.

Convert()

Convert will take a price source and see if the item can be converted, this is relevant for eternals from Wrath that can be converted to crystallized fire or earth.

The if varitations

TSM4 has 5 different if functions. They are all evaluated the same way. they take 3 or 4 arguments like ifgte(a,b,c,d). The function will compare a and b based on the logic implied by the function name and then return the value in C if the evaluation is true or d in any other cases. For anyone familiar with programming this will be something you are used to. The variations of if are:

  • ifgt = If Greater Than
  • ifgte = If Greater Than or Equal To
  • Iflt = If Less than
  • iflte = If less than or equal to
  • ifeq = if Equal

A simple example will perhaps help:

ifgt(dbmarket,2g,70%dbmarket,1c)

This formula will compare dbmarket to 2 gold. If dbmarket of the item is higher than 2 gold it will evaluate to 70% dbmarket otherwise it will be 1 copper. This can be used a max price for shopping materials if you want to avoid the cheapest ones for instance.

Rounding

The round functions are also very similar. The names pretty much say exactly what they do. round() will use standard rounding rules and roundup() and rounddown() will round either up or down. The function has two arguments round(a,b) where a is the value you want to round and b is the value you want too round to.

round(crafting,10s) will for instance round the crafting cost to the nearest 10 silver. Rounding can be useful to make sure your normal prices are prettier which may help you make more sales. I’m sure there are other uses as well.

Some illustrative examples

I have already showed you a couple of examples above, but here we will take a look at a couple more just to show you how this can be used.

Disenchanting value of BfA crafted bracers

I made this source to calculate the value of disenchanting a crafted uncommon bracer. It will calculate the average value of the materials you get and it includes the chance for rare procs. To make it you simply take the average dust yields of an uncommon bracer and multiply that with the chance to get an uncommon bracer. Then you multiply the value of the materials you get from a rare bracer with the chance of a rare bracer proccing. Then you add them together.

0.85*(dbmarket(i:152875)*5.64)+0.15*1.5*(dbmarket(i:152875)+dbmarket(i:152876))

BilisOnyxia’s Sniper string

This is a very popular string that I’m sure a lot of you are using for sniper.

It’s very long and has a ton of nested ifgt() functions. What it does is that each ifgt() function compares the value of the item to a set gold amount and then gives a percentage you are willing to buy the item at. The idea is that you are willing to pay more for expensive items relative to their value than you would be for cheap items.

If the value is above 250 000 gold the first ifgt will evaluate to 80% minprice and be used, if it is lower it will go to the next ifgt and continue until the end where any values below 1000g will be ignored. This allows the string to work for a lot of different items, with just one string!

I use a similar logic in my battle pet string.

ifgte(ItemQuality, 1, ifgt(minprice, 250000g, 80% minprice, ifgt(minprice, 100000g, 70% minprice, ifgt(minprice, 50000g, 60% minprice, ifgt(minprice, 10000g, 50% minprice, ifgt(minprice, 5000g, 30% minprice, ifgt(minprice, 1000g, 10% minprice, 0c)))))), 0c)

Summary

Logic functions and math can be used to make some very complex pricing strings and will help you get a leg up on the competition. They can also simplify your TSM setup as you can use a single set of strings and operations for many markets.

Part 14: Vendoring

If you want to level up your gold making consider supporting my Patreon. 

Have a question or a thought? Leave it here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.