Jump to content

Function - Convert Int to a Roman Number String


Recommended Posts

  • Honorable Member

M2 Download Center

This is the hidden content, please
( Internal )

Hi fellow metin2devs,

 

This is a function i've just written, it will convert any int value to a string representing the given int number in its Roman form, feel free to use it.

 

Example: 9 = IX, 10 = X

 

http://pastebin.com/Cf4ijJnN

  • Metin2 Dev 5
  • Good 2
  • Love 7

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
https://metin2.dev/topic/13731-function-convert-int-to-a-roman-number-string/
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

  • Honorable Member

497438f17b.jpg

 

http://pastebin.com/hBp1pRU1

Edited by Metin2 Dev
Core X - External 2 Internal

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Thats' a better solution without thousands loops..

http://pastebin.com/8NP1FfxU

According with lua syntax keep in mind is always better return same time.

According with Romans enumeration you have to check the upperbound due to the ascii chars limit

Anyway good job.

  • Honorable Member
9 hours ago, luzzo said:

According with lua syntax keep in mind is always better return same time.

What do you mean? Can you be a little more clear about that statement?

9 hours ago, luzzo said:

According with Romans enumeration you have to check the upperbound due to the ascii chars limit

True, thanks.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

3 hours ago, Syreldar said:

What do you mean? Can you be a little more clear about that statement?

True, thanks.

i see you have already corrected it..

I mean before you where returning 0 if n == 0 and that's ok but what i mean is that you should return if is not allowed number something like "" or better nil, so in this case you can check the function in an if statment before printing

like:

local numberconverted = intoroman(somenumber)
if numberconverted then

 print(numberconverted)

else

 print("i can't convert this number")

  • Honorable Member
1 minute ago, luzzo said:

i see you have already corrected it..

I mean before you where returning 0 if n == 0 and that's ok but what i mean is that you should return if is not allowed number something like "" or better nil, so in this case you can check the function in an if statment before printing

like:

local numberconverted = intoroman(somenumber)
if numberconverted then

 print(numberconverted)

else

 print("i can't convert this number")

OH! Thanks a lot!

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

  • Honorable Member
1 hour ago, Exygo said:

Awesome!

Thanks but it's really just something which popped up in my head while i was on drugs, nothing special really!

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

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.