PtokaX forum

PtokaX => Feature Proposals => Topic started by: 6Marilyn6Manson6 on 21 May, 2006, 13:52:54

Title: iShareSize
Post by: 6Marilyn6Manson6 on 21 May, 2006, 13:52:54
user.iShareSize = return iShareSize in byte.
Is it possible change iShareSize in other? For example: iShareSize change in: iShareSizeBYTE - iShareSizeKBYTE - iShareSizeMBYTE - iShareSizeGBYTE - iShareSizeTBYTE. Thanks :P
Title: Re: iShareSize
Post by: PPK on 21 May, 2006, 22:50:25
No is not possible  :o
Title: Re: iShareSize
Post by: 6Marilyn6Manson6 on 21 May, 2006, 22:52:04
Quote from: PPK on 21 May, 2006, 22:50:25
No is not possible? :o

Why PPK? Explain to me please :)
Title: Re: iShareSize
Post by: GeceBekcisi on 21 May, 2006, 23:54:49
6Marilyn6Manson6 why don't you simply use a code like the one below?
BYTEtoSHARE = function(iBytes)
if iBytes then
if iBytes > 1024^5 then
return string.format( "%.2f",iBytes/1024^5).." PiB"
elseif (1024^5 > iBytes) and (iBytes > 1024^4) then
return string.format( "%.2f",iBytes/1024^4).." TiB"
elseif (1024^4 > iBytes) and (iBytes > 1024^3) then
return string.format( "%.2f",iBytes/1024^3).." GiB"
elseif (1024^3 > iBytes) and (iBytes > 1024^2) then
return string.format( "%.2f",iBytes/1024^2).." MiB"
elseif (1024^2 > iBytes) and (iBytes > 1024) then
return string.format( "%.2f",iBytes/1024).." KiB"
elseif (1024 > iBytes) then
return (iBytes).." B"
end
else
return "0 B"
end
end
Title: Re: iShareSize
Post by: PPK on 22 May, 2006, 00:02:11
Yes as say GeceBekcisi, why you dont use script... because is not possible want from PtokaX to create all share types on any user object creating ::)
Title: Re: iShareSize
Post by: bastya_elvtars on 22 May, 2006, 00:02:28
The soulution is easier for you to script than to code into pxlua and use up more RAM.
Title: Re: iShareSize
Post by: 6Marilyn6Manson6 on 22 May, 2006, 03:36:12
Yes, I know. For example I can use this part:

DoShareUnits = function(intSize)
if intSize ~= 0 then
local tUnits = { "Bytes", "KiB", "MiB", "GiB", "TiB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then sUnits = tUnits[index]; break; else intSize = intSize / 1024; end
end
return string.format("%0.3f %s",intSize, sUnits);
else
return "0 Bytes"
end
end


but if PPK added this: iShareSizeBYTE - iShareSizeKBYTE - iShareSizeMBYTE - iShareSizeGBYTE - iShareSizeTBYTE, script is most easy and short :P
Title: Re: iShareSize
Post by: PPK on 22 May, 2006, 03:56:34
Quote from: bastya_elvtars on 22 May, 2006, 00:02:28
than to code into pxlua and use up more RAM.
Not ram, but cpu...  ::)
Quote from: 6Marilyn6Manson6 on 22 May, 2006, 03:36:12
script is most easy and short :P
Sorry but here will not be support for lazy scripters  :P
Title: Re: iShareSize
Post by: 6Marilyn6Manson6 on 22 May, 2006, 08:16:17
Ok ok PPK, thanks a lot to all :)