MrDave
Member
GM Version: ALL
Target Platform: ALL
Download: N/A
Links: http://www.davetech.co.uk/gamemakerordinalindicator
Ordinal Indicators are the letters in 1st, 2nd, 3rd, 4th etc.
I’ve written a quick script for people wanting to add the correct letters to the end of an integer.
This isn’t going to be helpful for most people, but it can be tricky for people that haven’t done it before.
How to use it:
Target Platform: ALL
Download: N/A
Links: http://www.davetech.co.uk/gamemakerordinalindicator
Ordinal Indicators are the letters in 1st, 2nd, 3rd, 4th etc.
I’ve written a quick script for people wanting to add the correct letters to the end of an integer.
This isn’t going to be helpful for most people, but it can be tricky for people that haven’t done it before.
Code:
/// ordinalindicator(int) returns the int as a str with st, nd, rd or th at the end
if( argument0 <= 0 ) return argument0; //technically ordinals don't exist for <= 0
if ((argument0 mod 100) >= 11 and (argument0 mod 100) <= 13) {
return string(argument0) + "th";
}
switch(argument0 mod 10)
{
case 1:
return string(argument0) + "st";
case 2:
return string(argument0) + "nd";
case 3:
return string(argument0) + "rd";
default:
return string(argument0) + "th";
}
Code:
ordinalindicator(1); // outputs: "1st"
ordinalindicator(2); // outputs: "2nd"
ordinalindicator(3); // outputs: "3rd"