Displaying NPCs and Item trades has always been a challenge on TibiaWiki. This has already been the target of two big projects in the past (TibiaWiki:Item Trade Project and TibiaWiki:NPC Trade Project). However, over the years this system also started to present some issues, at the same time better and more modern resources have become available.
Current Problems
The following are the main reasons to change the current system:
- Data is currently spread and repeated on several different pages. To list a trader properly at the moment, several pages need to be changed:
- The NPC page
- The Item page
- The templates Price to Buy or Price to Sell with the corresponding values
- Template GetClass with the item class
- Template NPC_Trades/City with the NPC location
Failing to update any of these pages will result in incomplete data or errors on the Trades tables.
- The current trade system is very expensive because of the amount of templates. Calling all these templates to fetch data makes the Trade System very expensive and over the past years it had to be expanded several times, specially because of Yasir's long trade list (but it could also affect other NPCs or Items eventually).
- Updating this system is often cause of confusion, even for administrators, because it's not always clear where an error is coming from.
New System
The proposed system takes advatange of the ability to use Lua modules in MediaWiki through the extension Scribunto. Scribunto's manual can be found in the Dev Wiki.
This system will work based on the following pages:
- Module:ItemPrices/data, the only place where data about Trades is stored.
- Module:ItemPrices with the Lua code used to fetch ItemPrices/data and output the requested information.
- Helper templates to make Invoke calls simpler: Template:Selling, Template:Buying, Template:Sellers and Template:Buyers.
Data
In order to make the process faster, but also to avoid repeating existing mistakes, the initial Data in the Module was created based on the Client's Appearances.dat file. This initial data had all the trade information that can be seen in game in the Cyclopedia which are items traded via the NPC trade window. After that, the Data has been manually edited to include other information, such as:
- Trades not present in the dat file (e.g. trades by dialog).
- Notes about specifics of trades.
- Trades with non-gold currencies.
- Trades of deprecated items or NPCs.
Output
To get trade table of a given Item or NPC, all that is required is to use the template with the corresponding name:
{{Selling|Benjamin}}
Differences
The output of the new system was created to be almost identical to the old system, with some differences:
- Item sprites are displayed on NPC tables.
- An icon representing the currency is shown after the value when applicable.
- The icon representing the 'best price' has been removed.
- This can be restored, however, it may not be as useful as initially thought.
- The column with the "Item Class" has been removed.
- This information is considered even less meaningful.
Progress
The following are the proposed steps for the final migration and their status
| Step | Status | Comment |
|---|---|---|
| Generate the Data | ✓ | Missing information on the original data has been added and it has been matched against current data to look for mistakes. |
| Generate Lua code | ✓ | The code has functions that will output trade tables for NPCs and Items, add notes and take into account special cases. |
| Update Infoboxes | ✓ | Infoboxes have been migrated. |
| Remove old data | ✗ | Once the Infoboxes are updated and after some period of testing, the old data can be removed by a Bot. Parameters to be removed are:
|