Module:NPCPriceSpread

local getArgs = require('Module:Arguments').getArgs

local p = {} local table = require('Module:Table') local string = require('Module:String')

function p.main(frame) args = getArgs(frame) return mw.getCurrentFrame:preprocess(p.writeText(args)) end

function p.writeText(args) local text = {} local values = {args[1] * 0.97,args[1] * 0.98,args[1] * 0.99,args[1],args[1] * 1.07,args[1] * 1.08,args[1] * 1.09,args[1] * 1.1} if args[3] == nil then ending = 'possible' else ending = args[3] end if args[4] == nil or args[4] == 0 then if args[2] == nil then table.push(text, table.concat{				'(,, , , , , , and  ', ending })		else			return values[args[2]+1]		end	else		table.push(text, table.concat({			convertValues(values[1]),			convertValues(values[2]),			convertValues(values[3]),			convertValues(values[4]),			convertValues(values[5]),			convertValues(values[6]),			convertValues(values[7]),			convertValues(values[8]),		}, ','))	end	return table.concat(text) end

function insertString(string1,pos) local split = {} split = string.sub(string1,pos) local newString = split[1]..','..split[2] return newString end

function convertValues(value) if string.len(value) > 3 then for i=1,math.floor(string.len(value) / 3) do			local newValue = insertString(value,math.mod(string.len(value),3) + ((i - 1) * 3)) end end return newValue end

return p