Witcher Wiki

Code snippets[ | ]

PS: #arraymap requires Page Forms.

{{#vardefineecho: carryingcapacity | {{#if: {{{basebodysize|}}} | {{#expr: 75 * {{{basebodysize|}}} round0}} }} }}

{{#vardefineecho: train_obedience | {{#ifeq: {{{trainability|}}}|none|no|yes}} }}

{{formatnum:{{{marketvalue}}} }} [[File:silver_c.png|20px]] }}

{{#expr:{{{wildness}}}*100}}% }}

{{ucfirst:{{lc:{{{trainability}}} }} }}

{{#if:{{#pos: {{{tradetags}}} |,}} | {{#arraymap:{{{tradetags|}}}|,|x|* x|\n}} | {{{tradetags}}} }}

Xmlstarlet[ | ]

Write this down quickly before I forget or ruin the code, which actually works:

xmlstarlet sel -t -m "//redxml/definitions/items/item/tags[text()[contains(.,'Edibles')]]/parent::item" -s A:T:- "@name" -v "concat('* ',@name)" -nl ALL_ITEMS.xml > alledibles.txt

This appears to do the same, so both variants can be used, depending on the need:

xmlstarlet sel -t -m "//redxml/definitions/items/item/tags[text()[contains(.,'Edibles')]]" -s A:T:- "../@name" -v "concat('* ',../@name)" -nl ALL_ITEMS.xml > alledibles.txt

Code for getting data from XML-file categories (categories have one value):

xmlstarlet sel -t -m "//redxml/definitions/items/item[@category='edibles']" -s A:T:- "@name" -v "concat('* ',@name)" -nl ALL_ITEMS.xml > alledibles.txt

Sometimes that isn't enough, or it is better to use tags for more precise selection.


This selects the XML of the whole node (<ability> to </ability>)

xmlstarlet sel -t -m '//redxml/definitions/abilities/ability[@name="'"Boots 02 _Stats"'"]' -c .  ALL_ITEMS.xml

This could come in handy:


Used to generate item list (damn it's many!):

  category:
alchemy_ingredient
crafting_ingredient
crossbow
bolt
potion
petard
oil
upgrade
dye
junk

  tags:
PlayerSilverWeapon
PlayerSteelWeapon
Armor

Skip recipes and such for now...