Ordinal Suffix Function File Name: Ordinal Suffix File Submitter: Myriad File Submitted: 5 June 2017 File Category: Quests, Shops, Functions & Algorithms Releases
Ever been constructing a string and wanted to turn 1 into 1st? Or 2 -> 2nd? Well, there is now an answer!
I call it 'Ordinal Suffix'. It adds a suffix to the end of your number using the callfunc() script command. Example below:
.@first = 1;
.@second = 2;
mes("That's the " + callfunc("Ordinal_Suffix", .@first) + " time you told me that!"); // Will return "That's the 1st time you told me that!"
mes("That's the " + callfunc("Ordinal_Suffix", .@second) + " time you told me that!"); // Will return "That's the 2nd time you told me that!"
mes("That's the " + callfunc("Ordinal_Suffix", 11) + " time you told me that!"); // Will return "That's the 11th time you told me that!"
→ Special cases such as '11th', '12th' and '13th' are accounted for.
→ Can only be used with integers.
→ Works for all possible numbers (except 0 will return 0th, not sure what that is supposed to be).
Script can be 'downloaded' at this pastebin link: https://pastebin.com/6Z5k1S70