PDA

View Full Version : Surely there is something to covert "cr" (challenge rating) from text to number?



SilentRuin
July 14th, 2020, 20:11
I can't seem to find anything in LUA (maybe I'm stupid) or Fantasy grounds code to convert a challenge rating to a number. The text fractions of 1/8, 1/4, and 1/2 will simply not convert with tonumber() and I can't believe I'm going to have to do direct comparisons to the text values. Surely there is a basic, real, true, conversion from text fractions to decimal numbers?

Yes, I know how I could write my own - but surely I don't have to, right?

superteddy57
July 14th, 2020, 20:36
5e does have sortNPCCRValues in the data_library_5E.lua that converts the fraction text to numbers. Might need to be tweaked for your use. And there is also calcBattleCR in manager_combat2.lua which again might need some tweaking for your use.

SilentRuin
July 14th, 2020, 20:53
5e does have sortNPCCRValues in the data_library_5E.lua that converts the fraction text to numbers. Might need to be tweaked for your use. And there is also calcBattleCR in manager_combat2.lua which again might need some tweaking for your use.

Yeah, had seen the manger_combat2.lua one - it was doing some kind of proficiency thing and also does not handle fractions.

Well, I've done it brute force - turn it to number but if 1/8, 1/4, or 1/2 I override that number (0) to be 0.125, 0.25, or 0.5. Life goes on I suppose :)

superteddy57
July 15th, 2020, 05:00
Yup sometimes have to make the tool we need. Good luck with your project.