RuneScape Wiki
Advertisement

This is a table of modules and functions that were created specifically for facilitating the creation of other modules. Documentation for modules here is done in the source code with Template:Helper module.

ModuleFunctionTypeUse
Addcommas_add(arg)NumberFormats the number arg with commas
_strip(arg)NumberRemoves all commas from arg
Yesno(arg)Any valueReads arg for yes/no and returns the appropriate boolean or nil
(arg1,arg2)Any value, Any valueReads arg1 for yes/no and returns the appropriate boolean; returns arg2 if arg1 was not an applicable value
Number_round(num, dp)float, intRounds num to a precision given by dp, if dp is not specified, it defaults to zero.
_short(str)StringConvert numbers ending in k, m or b to the actual correct number. Example: 3.5k -> 3500
Paramtestis_empty(arg)StringReturns true if arg is not defined or contains only whitespace
has_content(arg)StringReturns true if arg exists and does not only contain whitespace
default_to(arg1,arg2)String, Any valueIf arg1 exists and does not only contain whitespace, the function returns arg1, otherwise returns arg2
defaults{ {arg1,arg2},...}{String, Any value}...Does the same as default_to() run over every table passed; for technical reasons, all nil are replaced with false
Exchange_price(arg)StringGets the current median price of item named arg
_value(arg)StringGets the value of item named arg
Mainonly_main(arg)Any valueIf the module is invoked in the content namespace, it will return arg, otherwise, it will return an empty string
on_main()N/AReturns true if invoked in the content namespace, otherwise false
Edit button(text)stringCreates an edit button for the current page that the module is invoked on

text defaults to "edit"
Reftag{attr}tableTable of attributes may include:
  • name - A defined name for the ref
  • group - A defined group for the ref
  • text - The text inside the ref tags
  • selfClosing - true or false; whether or not the tag will close itself
Tables_row(row, elts, header)mw.html object, table/string, booleanAdds td or th cells to the html object with the cells data specified by elts. If header = true then all cells added will have the th tag.
_table(table, data)mw.html object, tableAdds tr rows and td/th cells to the html object, the data for the rows and cells is specified by data.
ExchangeLiteload(frame)table of form {args={'item', 'dataType'} }Lightweight version of Module:Exchange. Returns the data type requested for the specified item. Any of the fields of an exchange page can be used (see Exchange:Fire rune)
price(item)stringTakes an item name; returns the Grand Exchange price
Coins image(num)string,numberCreates the correct coins image for the number
DPL scroll_main(args)tableGenerates pagination for usage in DPL headers; see Template:Extension DPL scroll for template version. Table of attributes may include:
  • total - The total number of results
  • count - The number of results per page
  • offset - The current offset
  • query - Additional URL query to add; either:
    • a table of param = value primitive pairs (both strings or numbers; don't nest tables) - the better option for when using this in another module
    • a string of form param1=value1&value2=param2...etc - can (but doesn't need to) start with & or ?
Returns boolean, html where the boolean is true if there is more than one page, false otherwise, and a mw.html object of a span containing the html of the page links (or the empty string if one/no page).
Loggerlog(table)tableLogs the contents of the table to the console (does not expand subtables).

Notes:

  • Assumes all table indices can be represented as strings - using functions or tables as indices will result in non-specific log entries
  • This is best used by adding p.logger = require('Module:Logger') to the top of the module, then calling p.logger.log(obj) in the debug console on the module page
  • This module will only print to the debug console - it has no use when used outside of the development environment and should be removed/commented out before saving
deep_log(table)tableLogs the contents of the table to the console, expanding subtables. See above notes.
Currency_amount(a, coinType)number/string, stringReturns the number a with the correct image in front of it and formatted with commas. Current supported cointypes are coins, rusty and chimes.
Currency short_amount(a, coinType, precise)number/string, string, booleanReturns the number a with the correct image in front of it and formatted with commas. Also shortens the number to k or M if needed unless precise = true. Current supported cointypes are coins, rusty and chimes.
StringTables_stringTable(inArr)tableGenerates an html table and returns it as a string. This is faster than creating an mw.htmlobject and then converting it to a string using the tostring() methode. This function is also faster then _tableToString(tbl)
_tableToString(tbl)mw.html table objectConverts the mw.html table object into a string. This function is faster than the tostring() methode.
Advertisement