![]() |
Changing case in strings
~AlphaFlame~
How would one go about changing the case of letters in a string? Say you have a string "this.letters" being set letter by letter... and you want certain letters to be capitalized. Script example: if (playerchats){ for (this.i=0;this.i<strlen(#c);this.i++){ if (!strequals(#e(this.i+3,1,#c),h)){ setstring letters,#s(letters) #e(this.i+3,1,#c); } else { setstring letters,#s(letters) capitlization thing here; } } Now, lets say I wanted all the H's to be capitalized. How would I go about doing that where the blue text is? My idea was to use the new ascii command, and add/subtract the correct value from lowercase to uppercase, but then I'd need to know how to check the ascii of that particular letter... Hopefully you people can understand that :o |
A - Z is ascii 65 - 90
a - z is ascii 97 - 122 hopefully that helps you on what your asking |
~AlphaFlame~
Unless you can find a way to check the letter's ascii, no it doesn't help. And I really don't feel like typing... if (ascii(57)){ setstring letters,ascii(97); } or whatever a thousand times. |
Quote:
NPC Code: it would be something like that |
~AlphaFlame~
I know that would work, but then how would you assign the letters to this.lookfor? :p |
just replace it with whatever you want it to be replaced with (if it changes then set it once they change it..
so like if you want it to capitalize h when the player says cap h then set the this.lookfor when they say that... otherwise just replace it with whatever letter you want to capitalize) |
~AlphaFlame~
So, that means I would have to do this. setstring this.lookfor,#e(the letter thingy); setstring letters,#s(letters) ascii(strtofloat(#s(this.lookfor))+30); ... Hmm... thanks KJL. Never would of thought of that myself. |
looks for would have to be the number of the letter your looking for....
like so if it was a this.looksfor would have to be 97 |
| All times are GMT +2. The time now is 11:59 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.