DtlTraders/patterns: Difference between revisions

From Citizens Wiki
No edit summary
Line 17: Line 17:
- ''random patterns''  
- ''random patterns''  
Those will allow to set maximum items a trader can have showd in stock (like 10 of 20), also set timeouts, "spawn chance", amount and price chances that will be used on each item when it's timeout passed.
Those will allow to set maximum items a trader can have showd in stock (like 10 of 20), also set timeouts, "spawn chance", amount and price chances that will be used on each item when it's timeout passed.
All patterns are based on one syntax that is used to build item scripts. Those scripts are used by each pattern type, just each pattern type uses it in another way.
== Item syntax ==
This sound horrible, I know, but it's best way to explain it in two words :D
Every item within a pattern is build up by some keywords and flags you may use, many options you can't achieve with a basic trader setup are here allowed, but you need to be careful.
=== Keywords ===
<div style="width:100%;vertical-align:top">
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;border-right:solid 1px black"><p style="margin:0px;padding:2px 10px;"><b>Item setting</b></p>
</div>
<div style="display:table-cell;width:110px;border-right:solid 1px"><p style="margin:0px;padding:2px 10px;"><b>Keyword</b></p>
</div>
<div style="display:table-cell;width:220px;border-right:solid 1px"><p style="margin:0px;padding:2px 10px;"><b>Price pattern</b></p>
</div>
<div style="display:table-cell;width:280px;border-right:solid 1px black"><p style="margin:0px;padding:2px 10px;"><b>Item pattern</b></p>
</div>
<div style="display:table-cell;width:120px;"><p style="margin:0px;padding:2px 10px;"><b>Example</b></p>
</div>
</div><!-- base -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">ID and data</code></p>
</div>
<div style="display:table-cell;width:110px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">id[:data]</code></p>
</div>
<div style="display:table-cell;width:220px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block;">Looks for items with the given id and/or data, <b>priority: 130</b></code></p>
</div>
<div style="display:table-cell;width:280px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block;">Sets the item id, and when set also the data <b>default: required!</b></code></p>
</div>
<div style="display:table-cell;width:120px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">wool:14</code></p>
</div>
</div><!-- amount -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">Item amount</code></p>
</div>
<div style="display:table-cell;width:110px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">a</code></p>
</div>
<div style="display:table-cell;width:220px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block;">Looks for items with the given amount, <b>priority: 5</b></code></p>
</div>
<div style="display:table-cell;width:280px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block;">Sets one or more amounts for an item, <b>default: 1</b></code></p>
</div>
<div style="display:table-cell;width:120px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">a:1,2,4</code></p>
</div>
</div><!-- durability -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Durability</code></p>
</div>
<div style="display:table-cell;width:110px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">d</code></p>
</div>
<div style="display:table-cell;width:220px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Looks for items with the given or higher durability, <b>priority: 45</b></code></p>
</div>
<div style="display:table-cell;width:280px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the items durability, <b>default: 0</b></code></p>
</div>
<div style="display:table-cell;width:120px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">d:22</code></p>
</div>
</div><!-- price -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Price</code></p>
</div>
<div style="display:table-cell;width:110px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">p</code></p>
</div>
<div style="display:table-cell;width:220px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the price for each matching item, overriding lower priority matches</code></p>
</div>
<div style="display:table-cell;width:280px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the price for the given item, <b>default: pattern price</b></code></p>
</div>
<div style="display:table-cell;width:120px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">p:12.22</code></p>
</div>
</div><!-- Slot -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Slot</code></p>
</div>
<div style="display:table-cell;width:110px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">s</code></p>
</div>
<div style="display:table-cell;width:220px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Not used</code></p>
</div>
<div style="display:table-cell;width:280px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the slot for the item, <b>default: first empty</b></code></p>
</div>
<div style="display:table-cell;width:120px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">s:22</code></p>
</div>
</div>
</div>


== Pricing patterns ==
== Pricing patterns ==
Line 97: Line 211:
Item patterns are used to set up really fast and easily traders, they might be mixed with pricing patterns allowing to create a really nice system, also working now on setting multiple patterns to one trader, so you can set prices within one pattern and items for many traders within another :)  
Item patterns are used to set up really fast and easily traders, they might be mixed with pricing patterns allowing to create a really nice system, also working now on setting multiple patterns to one trader, so you can set prices within one pattern and items for many traders within another :)  


=== Item syntax ===
This sound horrible, I know, but it's best way to explain it in two words :D
Every item within a pattern is build up by some keywords and flags you may use, many options you can't achieve with a basic trader setup are here allowed, but you need to be carefully.
==== Keywords ====
<div style="width:100%;vertical-align:top">
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;border-right:solid 1px black"><p style="margin:0px;padding:2px 10px;"><b>Item setting</b></p>
</div>
<div style="display:table-cell;width:210px;border-right:solid 1px"><p style="margin:0px;padding:2px 10px;"><b>Keyword</b></p>
</div>
<div style="display:table-cell;width:380px;border-right:solid 1px black"><p style="margin:0px;padding:2px 10px;"><b>Description</b></p>
</div>
<div style="display:table-cell;width:160px;"><p style="margin:0px;padding:2px 10px;"><b>Example</b></p>
</div>
</div><!-- amount -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">Item amounts</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">a</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block;">Sets the amounts for that item, if specified more than one it will use the multiple items window, <b>default: 1</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:solid 1px"><!-- Cell -->
<p style="margin:0px;padding:2px 10px"><code style="margin:0px;display:block">a:1,2,4</code></p>
</div>
</div><!-- durability -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Durability</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">d</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the items durability, <b>default: 0</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">d:22</code></p>
</div>
</div><!-- price -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Price</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">p</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the price for the item, <b>default: pattern price</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">p:12.22</code></p>
</div>
</div><!-- Slot -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Slot</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">s</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the slot for the item, <b>default: first empty</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">s:22</code></p>
</div>
</div><!-- enchants -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Enchants</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">e</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets enchantments for an item, <b>default: none</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">e:16/3,17/30</code></p>
</div>
</div><!-- Global limit -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Global limits</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">gl</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets a global limit for that item, <b>default: no limit</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">gl:0/30/3600</code></p>
</div>
</div><!-- Player limit -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Player limits</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">pl</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets a per player limit for that item, <b>default: no limit</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">pl:0/30/3600</code></p>
</div>
</div><!-- Stored enchants -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Stored enchants</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">se</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets one one enchant for a enchanted book item, <b>default: none</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">se:16/7</code></p>
</div>
</div><!-- name -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Name</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">n</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets the name for an item, (white space char is replaced with <i>[&]</i>), <b>default: none</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">n:Item[&]Name</code></p>
</div>
</div><!-- Stack price -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Stack price flag</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">sp</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets a flag if the price should be set for the whole stack, when set, amounts will use only the first amount, <b>default: disabled</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">sp</code></p>
</div>
</div><!-- Check enchantments -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Check enchantments flag I</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">ce</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets a flag if the an item should be checked by its enchantments, returns true if all enchantments are equal (without level) <b>default: disabled</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">ce</code></p>
</div>
</div><!-- Check enchantments -->
<div style="display:table;width:100%">
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Check enchantments flag II</code></p>
</div>
<div style="display:table-cell;width:210px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">cel</code></p>
</div>
<div style="display:table-cell;width:380px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">Sets a flag if the an item should be checked by its enchantments, returns true if all enchantments are equal (with level) <b>default: disabled</b></code></p>
</div>
<div style="display:table-cell;width:160px;background-color: #F9F9F9;border-top:dashed 1px red"><!-- Cell -->
<p style="margin:0px"><code style="padding: 5px 10px;display:block">cel</code></p>
</div>
</div>
</div>


=== Simple pattern example ===
=== Simple pattern example ===
Line 375: Line 301:


How you set prices for items he buys, it's your thing, you just need to remember about those two things.
How you set prices for items he buys, it's your thing, you just need to remember about those two things.
==== Example ====
<div style="border: solid 1px black;padding:10px;padding-top:0px"><span style="white-space: pre;color:darkgreen;">
default:
<span>  inherits: </span>
<span>  - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">global_prices</tt></span>
<span>  items: </span>
<span>    buy: </span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">17 a:2 sp</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">5 a:2 sp</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">3 a:2 sp</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35 a:2 sp</tt></span>
</span></div>
Such a pattern will cause to sell to the trader always 2 items.
So those 2 items will appear in the sell section after they are sold :)
<!--
[the author isn't sure what will happen. this bit will be updated soon]
-->
<!--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:<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 ===
'''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 ===
'''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.
=== Enchants ===
'''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 ===
'''s:'''<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:0</tt><br />
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:'''<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 />
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 />
<br />
To set the price use the following format:<br />
<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'ItemID:DataValue': price'</tt><br />
<br />
When data value is not provided the price will apply to any items sharing the ID. For example:<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35:15': 2.22</tt> - will set the price of Black Wool to 2.22.<br />
<tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">'35': 2.22</tt> - will set the price of any Wool block to 2.22.<br />
<br />
Using the '''[sp]''' flag will cause the price to be applied to the whole stack.<br />
== Example pattern file ==
<div style="border: solid 1px black;padding:10px;padding-top:0px"><span style="white-space: pre;color:darkgreen;">
default:
<span>  prices: </span>
<span>    all: </span>
<span>      35: <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">1.5</tt></span>
<span>      '35:2': <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">2.0</tt></span>
<span>    sell: </span>
<span>      1: <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">0.33</tt></span>
<span>      2: <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">0.66</tt></span>
<span>      3: <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">0.99</tt></span>
<span>  items: </span>
<span>    all: </span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:1 a:1,2,4 s:-1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:2 a:1,2,4 s:-1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:3 a:1 s:-1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:4 a:2 s:-1 p:11</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">1 a:32 s:8</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">2 a:32,54 s:17</tt></span>
<span>    buy: </span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">5 p:5 s:-1 a:18</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:0 s:-1 a:8,4,2,1</tt></span>
</span></div>
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 />
<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 />
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 />
<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><br />
<br />
Slot numbers are assigned in a such a way that they do not overlap.<br />
<br />
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:<br />
<span style="white-space: pre;color:darkgreen;">
<span>  items:</span>
<span>    buy:</span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:0 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:15 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:14 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:13 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:12 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:11 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:10 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:9 s:0 a:1</tt></span>
<span>    - <tt style="cospan>      multiplier: /p>
lor:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:8 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:7 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:6 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:5 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:4 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:3 s:0 a:1</tt></span>
<span>    - <tt style="color:black;background-color: #F8F8E0;border: solid 1px black;padding:0px 1px">35:2 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>
<br />
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.
-->


== Navigation ==
== Navigation ==

Revision as of 18:11, 29 March 2013

Overview

Every pattern is saved in the patterns.yml file located in the plugin's main folder. (plugins/DtlCitizensTrader)
You can change the directory in the configuration file.


There are 2 types of patterns:

- Pricing patterns
Sets item prices and pricing tiers.

- Item patterns
Will add certain items to the trader's stock, also has item tiers.


Incoming a third pattern type with 2.6 (long way to it):

- random patterns Those will allow to set maximum items a trader can have showd in stock (like 10 of 20), also set timeouts, "spawn chance", amount and price chances that will be used on each item when it's timeout passed.


All patterns are based on one syntax that is used to build item scripts. Those scripts are used by each pattern type, just each pattern type uses it in another way.


Item syntax

This sound horrible, I know, but it's best way to explain it in two words :D

Every item within a pattern is build up by some keywords and flags you may use, many options you can't achieve with a basic trader setup are here allowed, but you need to be careful.

Keywords

Item setting

Keyword

Price pattern

Item pattern

Example

ID and data

id[:data]

Looks for items with the given id and/or data, priority: 130

Sets the item id, and when set also the data default: required!

wool:14

Item amount

a

Looks for items with the given amount, priority: 5

Sets one or more amounts for an item, default: 1

a:1,2,4

Durability

d

Looks for items with the given or higher durability, priority: 45

Sets the items durability, default: 0

d:22

Price

p

Sets the price for each matching item, overriding lower priority matches

Sets the price for the given item, default: pattern price

p:12.22

Slot

s

Not used

Sets the slot for the item, default: first empty

s:22


Pricing patterns

Basics

An example of a basic pricing pattern:

default:

prices: all: multiplier: 1.0 35: 1.5 '35:2': 2.0 sell: 1: 0.33 2: 0.66 3: 0.99 buy: multiplier: 0.9 1: 0.33 2: 0.66 3: 0.99

An price for an item is set by the follow syntax 'id[:data]: {price}
so typing 35: 3.0 sets the price for any wool collor, to 3.0$, where '35:0': 4.0 sets the price only for the white wool to 4.0$.

In the all section you can set item price for both buying and selling. To change the item's value depending on the transaction type you can use the sell and buy sections.

The multiplier is used to quickly change prices. By using this setting you can adjust prices on the server scale just by setting a single number. You could for example lower the value of any offered item by setting multiplier to 0.9 - every price would then be reduced by 10%. When no multiplier is set the value defaults to 1.0.

Multipliers set in the sell or buy sections have higher priority than those set in the all section. In the above example 0.9 set in the buy block overrides 1.0 set in the all section.

When dealing with blocks that use additional data value such as colored wool keep in mind that you can, for example, set the price of any wool by using 35: <price>. Changing that line to '35:0': <price> would only apply to white wool. Moreover if you set the general price for wool (35: <price1>) and then assign a different price to the white wool ('35:0': <price2>) then the more specific assignment has priority. In this case every wool block would cost <price1> with the exception of white wool which would be set to <price2>.

Tiers

Tiers allow you to define multiple patterns and apply them automatically depending on the user's permissions. Each tier can have a different multiplier and/or item prices. Tiers cannot be set for item patterns!

For example creating two tiers - tier1 with sell multiplier set to 0.9, and tier2 with sell multiplier set to 0.8 will have the following effect:


  • players without any permission would see all prices by default with default multipliers
  • players with the permission dtl.trader.tiers.tier1 will have overridden only those prices you got in tier 1
  • players with the permission dtl.trader.tiers.tier2 will have overridden only those prices you got in tier 2
  • players with both permissions will have overridden first all prices from tier 1 and the from tier 2
  • multipliers are always overridden, so when the default multiplier is set to 1.2 and non is set for a tier the multiplier will be set to 1.0 because it's default always for each tier/pattern


Tiers are defined after the pattern and have exactly the same structure.

default: prices: all: multiplier: 1.0 35: 1.5 '35:2': 2.0 sell: 1: 0.33 2: 0.66 3: 0.99 buy: multiplier: 0.9 1: 0.33 2: 0.66 3: 0.99 tier1: all: multiplier: 0.9 sell: 2: 0.11 buy: multiplier: 1.1

Item patterns

Item patterns are used to set up really fast and easily traders, they might be mixed with pricing patterns allowing to create a really nice system, also working now on setting multiple patterns to one trader, so you can set prices within one pattern and items for many traders within another :)


Simple pattern example

default: inherits: - global_prices 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

Notes

The all, sell and buy sections, behaves like for price patterns.

Keywords might be set up in any order, so you may write

- 2 s:17 a:32,54

or

- 2 a:32,54 s:17

it's still the same.

If you set an item with the same id and data like in the pattern, it wont add the item from the pattern, however you may set multiple items with the same id and data in the pattern.

Also we inherit here a pricing pattern that is named global_prices, it's just a regular pattern with prices for each item in-game, I've used it here to avoid setting a price for each item, and to show how to set it, if you set more than 1 pattern, the last one is the most important one.

More examples

Durability trick

default: inherits: - global_prices items: buy: - 271 d:32 p:10 s:0 a:1 - 271 d:22 p:50 s:0 a:1 - 271 d:11 p:100 s:0 a:1

You may set different prices depending on the durability loss of an item. The trick is to set each item on the same slot, starting with the most damaged one.

Anything that is more damaged that than the first can't be sold to the trader.

Important is to set the price for each item by yourself, because there is no way to set different prices for damaged items.

Grouping items for sell

default: inherits: - global_prices prices: buy: '35':13 items: buy: - 17 s:0 a:2 sp - 17:1 s:0 a:2 sp - 17:2 s:0 a:2 sp - 17:3 s:0 a:2 sp

This setup will set all 4 Log types into one slot, and this might be considered as a "Log group", the price is determined here in the prices section.

Because we have set for those items amount 2, and the Stackprice flag, people can sell only a minimum of 2 logs to that trader, and will get for 2 logs 13$.

Without Stackprice the price would be multiplied by the amount, so 13$ * 2 = 26$ for 2 logs.

Moreover, we got here inherited global_prices pattern, but when we set up a price within this pattern it will override the inherited price.


Market patterns

Market patterns are from up now not hard to to setup, mainly there are only two requirements to make a Market trader working in the right way.

  1. Set the items up in your trader based on what you want him to buy, the items you set are what he will buy from the player and turn around to sell back to other players.
  2. Because items that was bought needs a price it's needed to always set the prices => sell section with prices for items the trader may buy.

How you set prices for items he buys, it's your thing, you just need to remember about those two things.

Navigation

DtlTraders
Configuration Commands | Permissions
Usage Patterns
Types