DtlTraders/patterns: Difference between revisions

From Citizens Wiki
(WIP - lethe)
(poprawiona strona - lethe)
Line 45: Line 45:
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.<br />
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.<br />
<br />
<br />
By supplying the '''p:''' argument you can individually set the item's price. It will also no longer be affected by the patterns file.<br />
The price is set using the prices: section of the patterns file or by supplying the '''p:''' argument in the item definition. Keep in mind that any change done in the in-game trader window will separate the item from the pattern - it will be treated independently from that point onward.<br />
<!--- wcale nie. tak dlugo jak zmiany sa tylko w patternach to zawsze beda mialy wplyw, edytowanie z reki odlacza je od patternow --->
<br />
<br />
To set the price use the following format:<br />
To set the price use the following format:<br />
Line 81: Line 80:
</span></div>
</span></div>


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''.
When applied to a trader it will buy and sell ''Grass'', ''Stone'', and four different colors of ''wool'' (orange, magneta, light blue and yellow). ''Wooden planks'' and ''white wool'' are also added but the npc will only buy them.<br />
The basic wool ''price'' is set to '''1.5''', by using the ''prices'' section. <br />
<br />
The price of wool blocks is set to '''1.5''' in the ''prices'' section. <br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35: 1.5</tt><br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35: 1.5</tt><br />
But we also got a specific price for the magneta wool found here<br />
There is an exception for magenta wool in the line below which sets a different price from the other wool blocks.<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35:2': 2.0</tt><br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35:2': 2.0</tt><br />
 
<br />
Because we didn't specified a price for ''Wooden planks'' we have specified it right within the ''item string''<br />
Although the price for ''Wooden planks'' was not specified in the '''prices:''' section it can be done right in the item definition string by using the '''p:''' argument.<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">5 <b>p:5</b> s:-1 a:18</tt>
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">5 <b>p:5</b> s:-1 a:18</tt><br />
 
<br />
Ass you see slots are specified so no item will cover another.  
Slot numbers are assigned in a such a way that they do not overlap.<br />
 
<br />
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.
The price for selling dirt blocks was set but the item was not added to the trader inventory. When you add this block in game by hand the plugin will find this definition and apply the set price for you.
 
== Saving space in the trader window ==
== Saving some place ==
A lot of space can be saved by using the patterns file when a trader is set to buy a wide assortment of items. Let's say we want the npc to buy any kind of wool. Normally you would have to put 16 different items on the buy tab, but they can all be combined in a single slot. The '''items:''' section would look like this:<br />
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.
 
<span style="white-space: pre;color:darkgreen;">
<span style="white-space: pre;color:darkgreen;">
<span>  items:</span>
<span>  items:</span>
Line 118: Line 115:
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:1 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:1 s:0 a:1</tt></span>
</span>
</span>
 
<br />
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.
The first entry will be the one shown in the trader window. But even though there are 16 different assignments packed in a single slot the plugin still treats them as separate and players will be able to sell the items as normal.
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.

Revision as of 06:36, 14 September 2012

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.

The price is set using the prices: section of the patterns file or by supplying the p: argument in the item definition. Keep in mind that any change done in the in-game trader window will separate the item from the pattern - it will be treated independently from that point onward.

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 applied to a trader it will buy and sell Grass, Stone, and four different colors of wool (orange, magneta, light blue and yellow). Wooden planks and white wool are also added but the npc will only buy them.

The price of wool blocks is set to 1.5 in the prices section.
35: 1.5
There is an exception for magenta wool in the line below which sets a different price from the other wool blocks.
'35:2': 2.0

Although the price for Wooden planks was not specified in the prices: section it can be done right in the item definition string by using the p: argument.
5 p:5 s:-1 a:18

Slot numbers are assigned in a such a way that they do not overlap.

The price for selling dirt blocks was set but the item was not added to the trader inventory. When you add this block in game by hand the plugin will find this definition and apply the set price for you.

Saving space in the trader window

A lot of space can be saved by using the patterns file when a trader is set to buy a wide assortment of items. Let's say we want the npc to buy any kind of wool. Normally you would have to put 16 different items on the buy tab, but they can all be combined in a single slot. The items: section would 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 entry will be the one shown in the trader window. But even though there are 16 different assignments packed in a single slot the plugin still treats them as separate and players will be able to sell the items as normal.