DtlTraders/patterns: Difference between revisions

From Citizens Wiki
No edit summary
(WIP - lethe)
Line 1: Line 1:
I will show here a simple pattern example how it works and how it reacts in the manager mode.
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.


== Item format ==
== Preparation ==
<p style="color:red">I will make a better description when I will have some more time</p>
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.


First we need to know how to add an item to the ''pattern''.
== Defining a pattern ==
The item format looks like this
 
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">id[:data] [d:durability] [a:amount,...] [e:id/lvl,...] [s:slot] [p:price] [sp]</tt>
 
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.


The format of adding an item to the pattern is as follows:<br />
<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">id[:data] [d:durability] [a:amount,...] [e:eid/lvl,...] [s:slot] [p:price] [sp]</tt><br />
<br />
Each of the arguments is explained below in detail.
=== Item ID and data value ===
'''id:data'''<br />
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 ===
=== 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 [http://www.minecraftwiki.net/wiki/Item_Durability here].  
'''d:'''<br />
 
<br />
Simply how damaged the offered item should be. You can find a durability table [http://www.minecraftwiki.net/wiki/Item_Durability here] with values for different tools and armors .  
=== Amounts ===
=== 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.  
'''a:'''<br />
 
<br />
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.
<!---
'''Note:''' It is possible to stack normally unstackable items in this way. There is an optional chceck that can be enabled in the config that prevents it.
--->
=== Enchants ===
=== 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.  
'''e:EID/lvl'''<br />
 
<br />
Assigns the specified enchant to the item. A list of available effects can be found [http://www.minecraftwiki.net/wiki/Enchant#Enchantments here]. Separating several values with a comma allows for up to four enchantments beeing assigned.<br />
<br />
'''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 ===
=== 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. <br />
'''s:'''<br />
'''Note:''' It may be that items will use the same slot. Setting items in this order <br />
<br />
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. <br />
<br />
'''Note:''' It is possible to use the same slot for multiple items. For example:<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">- 3 s:-1</tt><br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">- 3 s:-1</tt><br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">- 3 s:0</tt><br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">- 3 s:0</tt><br />
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. (Fixed in incoming version 1.9.5)
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 ===
=== 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.
'''p:'''<br />
<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 />
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 />
<br />
Using the '''[sp]''' flag will cause the price to be applied to the whole stack.


== Prices format ==
== Prices format ==
<br />
this format is very simple. It uses two conditions and they are easy to understand. So when we got <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35: 2.22</tt> 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 <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35:0': 2.22</tt> the price will only apply to the white wool.
this format is very simple. It uses two conditions and they are easy to understand. So when we got <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35: 2.22</tt> 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 <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35:0': 2.22</tt> the price will only apply to the white wool.



Revision as of 20:54, 13 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.

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

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

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.

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.