Difference between revisions of "Module:Subpixel list"

From ALttP Speedrunning Wiki
Jump to: navigation, search
(Created page with "local p = {} local HEX = require('Module:Base convert') function p.main(frame) local args = frame:getParent().args local v = args[1] or '$16' v = v.gsub('%$','') -- remo...")
(No difference)

Revision as of 09:15, 15 May 2019

Documentation for this module may be created at list/doc&action=edit&redlink=1 Module:Subpixel list/doc

local p = {}

local HEX = require('Module:Base convert')

function p.main(frame)
	local args = frame:getParent().args
	local v = args[1] or '$16'

	v = v.gsub('%$','') -- remove hex indicator

	local ret = { }
	local sub = 0

	repeat
		local v1, v2 = v/16, v%16
		v1 = math.floor(v1)
		sub = sub + v2
		if sub>=16 then
			v1 = v1 + math.floor(sub/16)
			sub = sub%16
		end
		table.insert(ret, v1)
	until s==0

	return table.concat(ret, ',')
end

return p