User talk:Poke

From Guild Wars 2 Wiki
Jump to navigationJump to search

Wiki question: Is there a way for the wiki to do basic arithmetic?[edit]

I am trying to get the wiki to take the current TP value (summoned by the TP template), and multiply it by 20, or add it to itself 20 times. Do you know of any code in the wiki capable of doing this? Kenji_03 13:22, 10 November 2022 (UTC)

Hey, you can do arithmetic in wiki text using the #expr parser function. However, this only during the evaluation of wiki text. The trading post templates however utilize widgets in order to execute custom JavaScript when the page is displayed. This is also the reason why it might take a little bit of time until the trading post prices are displayed. So at the time the prices have been retrieved, all wiki text has already been executed and of course no parser function will be able to run anymore.
So your only option really is to include these calculations into the widget that is responsible for loading and displaying the data in the first place. For security reasons, widget code is not editable by everyone, so you can’t just do this yourself. If you do have a good use case though that makes sense to be embedded on main articles, I am sure that the community would be open to include this in a widget. poke | talk 19:00, 10 November 2022 (UTC)
Template:Tp total placeholder. --Tolkyria (talk) 19:12, 10 November 2022 (UTC)