RuneScape:Lua/Helper modules

From Old School RuneScape Wiki
Jump to: navigation, search

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.

Template:Helper module.defaultTemplate:Helper module.defaultTemplate:Helper module.defaultTemplate:Helper module.defaultTemplate:Helper module.defaultTemplate:Helper module.defaultTemplate:Helper module.default
ModuleFunctionTypeUse
Addcommas_add(arg)NumberFormats the number arg with commas
_strip(arg)NumberRemoves all commas from arg
Edit button(text)stringCreates an edit button for the current page that the module is invoked on

text defaults to "edit"
Exchange_price(arg)StringGets the current median price of item named arg
_value(arg)StringGets the value of item named arg
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
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
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
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
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