Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:NBlocks: Difference between revisions

From Hacks Guide Wiki
No edit summary
No edit summary
Line 11: Line 11:
end
end


function p.raw_blocks_to_kilobytes(blocks)
function p.raw_blocks_to_kib(blocks)
return blocks * 128
return blocks * 128
end
end


function p.raw_blocks_to_megabytes(blocks)
function p.raw_blocks_to_mib(blocks)
return blocks / 8
return blocks / 8
end
end
Line 23: Line 23:
end
end


function p.raw_megabytes_to_blocks(megabytes)
function p.raw_mib_to_blocks(mib)
return math.ceil(megabytes * 8)
return math.ceil(mib * 8)
end
 
function p.raw_format_bytes(bytes)
-- this needs to do bytes, kib, and gib too
return string.format("%.2f", bytes / 1024 / 1024) .. ' MiB'
end
end


Line 39: Line 44:
end
end


function p.blocks_to_kilobytes(frame)
function p.blocks_to_kib(frame)
return p.raw_blocks_to_kilobytes(frame.args[1])
return p.raw_blocks_to_kib(frame.args[1])
end
end


function p.blocks_to_megabytes(frame)
function p.blocks_to_mib(frame)
return p.raw_blocks_to_megabytes(frame.args[1])
return p.raw_blocks_to_mib(frame.args[1])
end
end


Line 51: Line 56:
end
end


function p.megabytes_to_blocks(frame)
function p.mib_to_blocks(frame)
return p.raw_megabytes_to_blocks(frame.args[1])
return p.raw_mib_to_blocks(frame.args[1])
end
 
function p.format_bytes(frame)
return p.raw_format_bytes(frame.args[1])
end
end


return p
return p