Jump to content

Recommended Posts

Hi metin2dev today i wanna release a little function to convert in the easyest way number in pointed number string.

 

Ex:

 

From :150000000

 

In : 150.000.000

 

 

 

It's very usefull if you need to create a  new coins manage interface like that:

 

https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

 

Here the full commented code:

def splittedvalue(value):
	x = value
	x_list = list(x) #convert string in list
	
	x_list.reverse() #reverse list for the right point 

	if len(x)%3 == 0:   #checking how many point must insert.If there is not rest,  point -1 to avoid .100.500
	   count_point = len(x)/3-1
	else:
		count_point = len(x)/3 
		
	for point in range(0,count_point):  #insert the points in the right place
		x_list.insert((3*int(point+1)+point),".")

	x_list.reverse()  #reverse again the list as begining
	x_list = "".join(x_list) #reconvert list in string
	return x_list  #finally return string value with point

Reguards Luzzo

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
https://metin2.dev/topic/1355-python-little-convertion-function/
Share on other sites

Which limit do you mean? And how is there any difference in usage?

 

a ) NumberToMoneyString(1234567)

b ) splittedvalue(1234567)

 

Moreover, due to the operations your function perform, it's most likely slower. And it only accepts strings, not ints or floats (can be quickly ammended though).

  • 1 year later...

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.