Jump to content
×
×
  • Create New...

Function - Convert Int to a Roman Number String


Syreldar

Recommended Posts

M2 Download Center

Hidden Content

    Give reaction to this post to see the hidden content.
( 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

 

Hidden Content

    Give reaction to this post to see the hidden content.

  • Metin2 Dev 1
  • Love 5

👑 Premium International Lua Developer 👑

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying whoever helps them.

Syreldar

Link to comment

Thats' a better solution without thousands loops..

Hidden Content

    Give reaction to this post to see the hidden content.

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.

Link to comment
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.

👑 Premium International Lua Developer 👑

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying whoever helps them.

Syreldar

Link to comment
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")

Link to comment
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!

👑 Premium International Lua Developer 👑

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying whoever helps them.

Syreldar

Link to comment
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!

👑 Premium International Lua Developer 👑

 My service topic: https://bit.ly/2UPly54

 

Ignorant people have the obligation to compensate their ignorance by paying whoever helps them.

Syreldar

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.