What's new

Skrypty & Kody Przecinek w liczbach LUA

Status
Not open for further replies.

Baczqo

User
Joined
Jun 9, 2015
Messages
26
Reaction score
1
Age
30
Jak zrobi? np wy?wietlanie liczby 100000 z przecinkami?
Chodzi mi o efekt np

local x = 1000000
print(x) - wy?wietla 1.000.000

local x = 1000
print(x) - wy?wietla 1.000

local x = 10000
print(x) - wy?wietla 10.000
 

Dantez

Moim sekretem jest ciasto
Joined
May 22, 2008
Messages
1,206
Reaction score
202
Odp: Przecinek w liczbach LUA

[LUA]function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then break end
end
return formatted
end[/LUA]

Znalezienie tego zaj??o mi jakie? 20 sekund.

Wybieraj:
 
Last edited:
Status
Not open for further replies.
Top