Xeirh
Veteran
- Messages
- 16
- Reaction score
- 2
- Points
- 793
works pretty simple:
* action: iprintln( capitalize_string( "capitalize me please" ) );
* return: Capitalize Me Please
Now the cool stuff!
item, let's say a level._effect: "grenade_samantha_steal"
* action: iprintln( capitalize_string( string_convert( "grenade_samantha_steal", "_", " " ) ) );
* return: Grenade Samantha Steal
string_convert can remove underscores and replace with space and vice versa or any target character.
*Converters Created By Boy7* <- the warrior
* action: iprintln( capitalize_string( "capitalize me please" ) );
* return: Capitalize Me Please
Now the cool stuff!
item, let's say a level._effect: "grenade_samantha_steal"
* action: iprintln( capitalize_string( string_convert( "grenade_samantha_steal", "_", " " ) ) );
* return: Grenade Samantha Steal
string_convert can remove underscores and replace with space and vice versa or any target character.
Code:
capitalize_string( string ) {
string = strtok( string, " " );
for( a = 0; a < string.size; a++ )
string[ a ] = capitalize_first_letter( string[ a ] );
capitalize_string = "";
for( a = 0; a < string.size; a++ )
if( a < string.size - 1 )
capitalize_string += string[ a ] + " ";
capitalize_string += string[ string.size - 1 ];
return capitalize_string;
}
capitalize_first_letter( string ) {
capitalize_letter = "";
capitalize_letter += toupper( string[ 0 ] );
if( string.size <= 1 )
return capitalize_letter;
for( a = 1; a < string.size; a++ )
capitalize_letter += string[ a ];
return capitalize_letter;
}
Code:
string_convert( string, target, replace ) {
convert = "";
for( a = 0; a < string.size; a++ ) {
if( string[ a ] == target )
convert += replace;
else
convert += string[ a ];
return convert;
}
}
Code:
toupper( string ) {
lower = "abcdefghijklmnopqrstuvwxyz";
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for( a = 0; a < lower.size; a++ ) {
if( illegal_character( string ) )
return string;
if( string == lower[ a ] )
return upper[ a ];
}
return string;
}
illegal_character( string ) {
illegal = "*{}!^/-_$&@#()";
for( a = 0; a < illegal.size; a++ )
if( string == illegal[ a ] )
return true;
return false;
}
*Converters Created By Boy7* <- the warrior
Attachments
Last edited: