DtlTraders/patterns

From Citizens Wiki

< DtlTraders

Revision as of 22:22, 12 September 2012 by Dandielo (talk | contribs)

I will show here a simple pattern example how it works and how it reacts in the manager mode.

Item format

I will make a better description when I will have some more time

First we need to know how to add an item to the pattern. The item format looks like this

id[:data] [d:durability] [a:amount,...] [e:id/lvl,...] [s:slot] [p:price] [sp]

With the following format we can set the items ID, Data, Durability, Enchants (by ID, I will change this), amounts, price, slot, stack price (sp)

I will explain each argument so everything should be clear.

Item id and data

As we see first we got the item id, it's the only required think in that string any other arguments got their default values We can specify also the data value of the given item bu adding :data to the id, so setting 35:2 as in the example will give us a colored wool.

Durability

Next we got the d: prefix, this prefix says how damaged should that item be. You can find a durability table here for different tools and armors here.

Amounts

The a: prefix says us what amount should have the item and if we set more amounts after a comma it will automatically jump into the multiple amounts selection.

Enchants

Using the e: prefix is very dangerous, because if you don't know a given enchants id setting any random value may be unavailable for that item and cause huge errors (going to change this). For example setting sharpness for a helmet will cause an error.

Slot

s: prefix is used to determine the items position in the traders inventory. Setting it to -1 will make if to use the first empty slot.
Note: It may be that items will use the same slot. Setting items in this order
- 3 s:-1
- 3 s:0
will cause to use the same slot. This issue is because before we set the second item we are looking for an empty slot, the result is 0, so the first item will take this slot, after that the second item is going to be initialized and it will use the [s:0] because it's set so. (I will try to find a fix for it)

Price

Price managing has been changed a bit from now. Every item added to a traders inventory has got the pattern listen flag, what causes the item to get the price from the pattern the trader is using, this flag is taken down when the price has been changed manually or when the loaded string contains the p: prefix. Using the [sp] flag will cause the price to be applied to the whole stack amount, not for each item.

Prices format

this format is very simple. It uses two conditions and they are easy to understand. So when we got 35: 2.22 it tells us that every item with the ID: 35 will get that price, so not only the while wool but also any collored wool that we have added to the stock and not edited it's price. But when we set it in that way '35:0': 2.22 the price will only apply to the white wool.


Pattern example

Here I've made a pattern example

default: prices: all: 35: 1.5 '35:2': 2.0 sell: 1: 0.33 2: 0.66 3: 0.99 items: all: - 35:1 a:1,2,4 s:-1 - 35:2 a:1,2,4 s:-1 - 35:3 a:1 s:-1 - 35:4 a:2 s:-1 p:11 - 1 a:32 s:8 - 2 a:32,54 s:17 buy: - 5 p:5 s:-1 a:18 - 35:0 s:-1 a:8,4,2,1

When we apply this pattern to a trader he will automatically buy and sell Grass, Stone, and four different wools (orange, magneta, light blue, yellow). He will also buy 2 more items than sell Wooden planks and white wool. The basic wool price is set to 1.5, by using the prices section.
35: 1.5
But we also got a specific price for the magneta wool found here
'35:2': 2.0

Because we didn't specified a price for Wooden planks we have specified it right within the item string
5 p:5 s:-1 a:18

Ass you see slots are specified so no item will cover another.

We have specified a additional price for a dirt block. Now when we will put into this trader an dirt block in the sell stock it will get automatically this price.

I hope it's not too weird to understand. Me or Lethe will change this description in the next few days, but for now I hope it's Ok.