Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-29-2001, 03:00 AM
entravial entravial is offline
Registered User
entravial's Avatar
Join Date: Mar 2001
Posts: 825
entravial is on a distinguished road
Send a message via ICQ to entravial Send a message via AIM to entravial Send a message via Yahoo to entravial
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
__________________


If the post says ~AlphaFlame~, that's who's posting. If not, it's Entravial (owner)
Reply With Quote
  #2  
Old 09-29-2001, 03:28 AM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
A - Z is ascii 65 - 90
a - z is ascii 97 - 122

hopefully that helps you on what your asking
__________________
Thanks,
-KJL
Reply With Quote
  #3  
Old 09-29-2001, 03:36 AM
entravial entravial is offline
Registered User
entravial's Avatar
Join Date: Mar 2001
Posts: 825
entravial is on a distinguished road
Send a message via ICQ to entravial Send a message via AIM to entravial Send a message via Yahoo to entravial
~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.
__________________


If the post says ~AlphaFlame~, that's who's posting. If not, it's Entravial (owner)
Reply With Quote
  #4  
Old 09-29-2001, 03:39 AM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
Quote:
Originally posted by entravial
~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.
NPC Code:

if(ascii(this.lookfor))
setstring letters,ascii(this.lookfor+32);



it would be something like that
__________________
Thanks,
-KJL
Reply With Quote
  #5  
Old 09-29-2001, 04:16 AM
entravial entravial is offline
Registered User
entravial's Avatar
Join Date: Mar 2001
Posts: 825
entravial is on a distinguished road
Send a message via ICQ to entravial Send a message via AIM to entravial Send a message via Yahoo to entravial
~AlphaFlame~

I know that would work, but then how would you assign the letters to this.lookfor?
__________________


If the post says ~AlphaFlame~, that's who's posting. If not, it's Entravial (owner)
Reply With Quote
  #6  
Old 09-29-2001, 04:19 AM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
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)
__________________
Thanks,
-KJL
Reply With Quote
  #7  
Old 09-29-2001, 04:23 AM
entravial entravial is offline
Registered User
entravial's Avatar
Join Date: Mar 2001
Posts: 825
entravial is on a distinguished road
Send a message via ICQ to entravial Send a message via AIM to entravial Send a message via Yahoo to entravial
~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.
__________________


If the post says ~AlphaFlame~, that's who's posting. If not, it's Entravial (owner)
Reply With Quote
  #8  
Old 09-29-2001, 04:26 AM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
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
__________________
Thanks,
-KJL
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.