DtlTraders/patterns

From Citizens Wiki

< DtlTraders

Revision as of 22:06, 13 September 2012 by Dandielo (talk | contribs) (WIP - lethe)

This page shows how to use the price patterns. Below is a sample pattern along with an explanation of how it works and what changes when using it together with manager mode.

Preparation

A pattern has to be defined before it can be used. Pattern definitions are saved by default in the patterns.yml file. The name of the file can be changed in the plugin configuration.

Defining a pattern

The format of adding an item to the pattern is as follows:

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

Each of the arguments is explained below in detail.

Item ID and data value

id:data
The item ID is the only mandatory value that has to be provided. Every other argument will fall back to a default value if omitted. Data value is optional and can be specified by adding it in the following format ID:data - 35:11 would result in a Blue Wool block beeing added.

Durability

d:

Simply how damaged the offered item should be. You can find a durability table here with values for different tools and armors .

Amounts

a:

Using a value higher than 1 will result in several items of the same type sold together as a stack. Providing more than one value will create the amount selection menu.

Enchants

e:EID/lvl

Assigns the specified enchant to the item. A list of available effects can be found here. Separating several values with a comma allows for up to four enchantments beeing assigned.

IMPORTANT: Be extra careful when using this argument in it's current form. It is possible to assing invalid enchantments to items when supplying wrong EIDs (e.g. sharpness put on a helmet). This will cause serious errors. Additional checks will be implemented soon to ensure that enchantments are applied in the proper way.

Slot

s:

Sets the item's position in the trader window. Accepted values range from 0 (top left slot) to 50 (bottom right slot). The bottom row is reserved for navigation. Setting this value to -1 will place the item in the first unused slot.

Note: It is possible to use the same slot for multiple items. For example:
- 3 s:-1
- 3 s:0
will result in both items occupying the top left cell. This happens because the order of the entries is important. A fix for this will be included in a future version.

Price

p:

Sets the item's price. When adding items to the trader window, the plugin will try to find an item definition in the patterns file and apply any settings found. Any change in the patterns file will affect this item after reloading/restarting the plugin.

By supplying the p: argument you can individually set the item's price. It will also no longer be affected by the patterns file.

To set the price use the following format:

'ItemID:DataValue': price'

When data value is not provided the price will apply to any items sharing the ID. For example:
'35:15': 2.22 - will set the price of Black Wool to 2.22.
'35': 2.22 - will set the price of any Wool block to 2.22.

Using the [sp] flag will cause the price to be applied to the whole stack.

Example pattern file

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.

Saving some place

So sometimes setting all items for sale is very irritating and time eating, but even more irritating are place issues, when we don;t got enough place to put all items into the traders stock. So there will be two ways to resolve this problem (one way will be added later). The first way works only for items we want to sell to the trader (buy tab). Lets say we want buy from players all 15 different wool colors. Lets pack all colors into 1 slot. The items section will look like this.

items: buy: - 35:0 s:0 a:1 - 35:15 s:0 a:1 - 35:14 s:0 a:1 - 35:13 s:0 a:1 - 35:12 s:0 a:1 - 35:11 s:0 a:1 - 35:10 s:0 a:1 - 35:9 s:0 a:1 - 35:8 s:0 a:1 - 35:7 s:0 a:1 - 35:6 s:0 a:1 - 35:5 s:0 a:1 - 35:4 s:0 a:1 - 35:3 s:0 a:1 - 35:2 s:0 a:1 - 35:1 s:0 a:1

The first line is defining the item shown in the inventory. So here we got 15 items on the same slot, we see only one but the trader sees every item sepparate. To add easily for all items a price we just write in the prices section '35: price. Done ;>


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 1Ok.