From Old School RuneScape Wiki
Jump to: navigation, search
Module documentation
This documentation is transcluded from Template:Module sandbox/doc. [edit] [purge]

This module is a sandbox for Towelcat. It can be used to test changes to existing modules, prototype new modules, or just experimenting with lua features.

Invocations of this sandbox should be kept in userspace; if the module is intended for use in other namespaces, it should be moved out of the sandbox into a normal module and template.

This default documentation can be overridden by creating the /doc subpage of this module, as normal.

local p = {}

local params = require('Module:Paramtest')
local yesno = require('Module:Yesno')
local var = mw.ext.VariablesLua

function p.main(frame)
	local args = frame:getParent().args
	local buymultiplier,sellmultiplier,currency,namenotes,delta,nosmw,hidege,hidebuy,hidestock,hidecaption = params.defaults{
	var.vardefine('BuyMultiplier', buymultiplier)
	var.vardefine('SellMultiplier', sellmultiplier)
	var.vardefine('Currency', currency)
	var.vardefine('NameNotes', namenotes)
	var.vardefine('Delta', delta)
	var.vardefine('nosmw', nosmw)
	var.vardefine('hideGE', hidege)
	var.vardefine('hideBuy', hidebuy)
	var.vardefine('hideStock', hidestock)
	local ret = mw.html.create('tr')
	ret:tag('th'):attr('colspan', 2):wikitext('Item'):done()
	if not(yesno(hidestock)) then
		ret:tag('th'):wikitext('Number<br>in stock'):done()
	ret:tag('th'):wikitext('Price<br>sold at'):done()
	if not(yesno(hidebuy)) then
		ret:tag('th'):wikitext('Price<br>bought at'):done()
	if not(yesno(hidege)) then
		ret:tag('th'):wikitext('[[Grand Exchange|GE <br>price]]'):done()
    local i = 1
    while args['column' .. i] do
		ret:tag('th'):attr('data-sort-type', 'number'):wikitext(args['column' .. i]):done()
		i = i+1
	local caption = ''
	if not(yesno(hidecaption)) then
		caption = '<caption style="white-space:nowrap;">Sells at: ' .. string.format("%.1f", (sellmultiplier/10)) .. 
		'% • Buys at: ' .. string.format("%.1f", (buymultiplier/10)) .. 
		'% • Change per: ' .. string.format("%.1f", (delta/10)) .. '%</caption>'
	return '<table class="wikitable sortable" style="text-align:center; margin:0;" cellpadding="2" cellspacing="0">' .. caption .. tostring(ret)
return p