Difference between revisions of "Module:Subpixel list"
From ALttP Speedrunning Wiki
Line 21: | Line 21: | ||
end | end | ||
table.insert(ret, v1) | table.insert(ret, v1) | ||
− | until | + | until sub==0 |
return table.concat(ret, ',') | return table.concat(ret, ',') |
Revision as of 09:16, 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 sub==0 return table.concat(ret, ',') end return p