I want to play a different sound when a certain type-character is at a certain position in a string
First I tried this:
if (text.Chars[trunc] == I) {
aI.PlayQueued();}
- which does not work
Then I tried this
if (text.Chars[trunc] == 78) {
aI.PlayQueued();}
- which works BUT now I have to manually find out which char number corresponds to which letter. Is there an easier way to do this or at least a table somewhere, where I can identify char numbers?
Thanks in advance!
The simplest way for displayable characters is to use what is referred to as a character-literal. You had basically the right idea, but for AGS to understand that it's a character-literal and not, for example, a script variable or something, you have to enclose it in single quotes, i.e.:
if (text.Chars[trunc] == 'I') {
aI.PlayQueued();
}
If the character is non-displayable (for example, the escape key) you can use the proper enumerated value:
if (text.Chars[trunc] == eKeyEscape) {
aEscape.PlayQueued();
}
I knew I was very close to the solution ;) thanks man
Glad you got it sorted out. So are you turning the keyboard (http://en.wikipedia.org/wiki/Alphanumeric_keyboard) into some sort of keyboard (http://en.wikipedia.org/wiki/Musical_keyboard)? :=
No, wanted to play certain sounds depending on what text the player entered, of course your idea would be very possible - I wonder why there isn't such a thing yet.