Module:FetchItemStats/doc: Difference between revisions

From RuneRealm Wiki
Jump to navigation Jump to search
Content added Content deleted
(Created page with "{{documentation}} This module provides three functions that make obtaining an item's information easier. {{Helper module |name = FetchItemStats |fname1 = defaultVersion(pagename) |ftype1 = String, String |fuse1 = Returns a string of the default version (format: <code>Pagename#Versionname</code>) that can be used for further SMW searches. Also returns a wikilink to the matched page name (following redirects from the given <code>pagename</code>, as the second return valu...")
 
No edit summary
Tag: Reverted
Line 15: Line 15:
|fuse3 = Fetches all item stats for a list of given SMW names. If an ambiguous item name is given anywhere in this list (i.e. one that has different versions), this function will ''not'' automatically pick the one that would otherwise be chosen by <code>defaultVersion</code>. A specific SMW name needs to be entered for this function.
|fuse3 = Fetches all item stats for a list of given SMW names. If an ambiguous item name is given anywhere in this list (i.e. one that has different versions), this function will ''not'' automatically pick the one that would otherwise be chosen by <code>defaultVersion</code>. A specific SMW name needs to be entered for this function.


Sort keys and sort orders may be provided as optional second and third arguments. No custom sorting will be applied if these arrays are empty or <code>nil</code>. Note that Semantic MediaWiki queries automatically sort the output pages based on alphabetical pagename order. If no sorting should be applied whatsoever, set <code>sort_key1</code> to something [[Module:Yesno|recognised as being falsy]] (e.g. <code>{'no'}</code>).
Sort keys and sort orders may be provided as optional second and third arguments. No custom sorting will be applied if these arrays are empty or <code>nil</code>. Note that Semantic MediaWiki queries automatically sort the output mw.pages based on alphabetical pagename order. If no sorting should be applied whatsoever, set <code>sort_key1</code> to something [[Module:Yesno|recognised as being falsy]] (e.g. <code>{'no'}</code>).


Possible sorting orders are: 'ascending', 'asc', 'descending', 'desc', 'reverse', 'random' and 'rand'.
Possible sorting orders are: 'ascending', 'asc', 'descending', 'desc', 'reverse', 'random' and 'rand'.

Revision as of 00:12, 17 October 2024

This is a documentation subpage for Module:FetchItemStats.
It contains usage information, categories, and other content that is not part of the original module page.
Module:FetchItemStats requires Module:Exchange.
Module:FetchItemStats requires Module:Yesno.
Module:FetchItemStats is required by Module:Equipment.

This module provides three functions that make obtaining an item's information easier.

This module is a helper module to be used by other modules; it may not designed to be invoked directly. See RuneScape:Lua/Helper modules for a full list and more information.

FunctionTypeUse
defaultVersion(pagename)String, StringReturns a string of the default version (format: Pagename#Versionname) that can be used for further SMW searches. Also returns a wikilink to the matched page name (following redirects from the given pagename, as the second return value.
value(item_smwname)NumberReturns the item value for either the specified SMW version (if the given name links to a specific item), or the version that is shown on the page by default (the same version as returned by defaultVersion.
equipmentStats(
{item1_smwname, ...},
{sort_key1, ...},
{sort_order1, ...}
)
{ Table1, Table2, ... }Fetches all item stats for a list of given SMW names. If an ambiguous item name is given anywhere in this list (i.e. one that has different versions), this function will not automatically pick the one that would otherwise be chosen by defaultVersion. A specific SMW name needs to be entered for this function.

Sort keys and sort orders may be provided as optional second and third arguments. No custom sorting will be applied if these arrays are empty or nil. Note that Semantic MediaWiki queries automatically sort the output mw.pages based on alphabetical pagename order. If no sorting should be applied whatsoever, set sort_key1 to something recognised as being falsy (e.g. {'no'}).

Possible sorting orders are: 'ascending', 'asc', 'descending', 'desc', 'reverse', 'random' and 'rand'.

The returned stats are formatted as a Table containing a single Table for each of the items, in the order given by the sort keys, or the default SMW sorting. The stats that are returned in each of these Tables are:

{
    astab  = 'Stab attack bonus',
    aslash = 'Slash attack bonus',
    acrush = 'Crush attack bonus',
    amagic = 'Magic attack bonus',
    arange = 'Range attack bonus',
    dstab  = 'Stab defence bonus',
    dslash = 'Slash defence bonus',
    dcrush = 'Crush defence bonus',
    dmagic = 'Magic defence bonus',
    drange = 'Range defence bonus',
    str    = 'Strength bonus',
    mdmg   = 'Magic Damage bonus',
    rstr   = 'Ranged Strength bonus',
    prayer = 'Prayer bonus',
    weight = 'Weight',
    image  = 'Image',
    subobj = 'Has subobject'
}