|
-
DOT-INVADER
counting how many letters...
i'm just wondering: is it possible to show via AS the exact numbers of letters found in a variable?
here's an example:
Code:
text="what are you doing?"
here, we have 16 letters + 3 spaces.
> what piece of script can i use to show how many letters+spaces (here16+3=19) i have?
...or maybe it's impossible...?
> i'm asking because maybe i can add something like that for my current project: the longer texts are, bigger the text window is...
i already have something like that working, but manually. so, if it can be automatic, it would be great ^^
thanks
-
ism
Code:
text="what are you doing?"
space=0;
nonspace=0;
for (i=1;i<length(text);i++) {
c = substring(text,i,1);
if (c == " ")
space++;
else
nonspace++;
}
trace(space+","+nonspace);
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Senior Member
i would use the charAt() function in a similar way to blinks... if you are developing a pa system in your rpg system i added one to my zelda demo at... http://anony.co.uk/chef/zelda4.html ... use
X to hack with sword
SHIFT to read a sign
SPACE to scroll the text
this is the version i showed in my university interview but i havent worked on it since then.
you cannot launch the stuff from the house as it works with fscommand local to the machine. i also have a browser based function written but its not uploaded and i havent changed the maps yet
SO...what im trying to say is!... if you want some help with your PA system i will show you the code!
[m]
-
DOT-INVADER
wow, as i can see you arranged the code to look for letters and spaces separately ^^... i'll apply it to my game and see how i can work with it...
thanks blinkOk.
-
DOT-INVADER
your link is 404, mbenney.
about it's implementation, i'm not sure of how to do it...
what i wanted was more:
1) calculate how many letters/spaces... well, the total lenght in fact
2) depending on the results, launch the small, medium, big text window...
too bad i cannot look at your example right now, i was very curious...
-
Senior Member
whoopsy daisys, i referenced the wrong hosting 
http://homepage.ntlworld.com/benney.1/zelda4.html
maybe the correct link will be better!
-
Senior Member
dont want to insult your intelligence but you have considered...
text="what are you doing?"
trace(text.length);
//trace gives 19
-
DOT-INVADER
Code:
trace(text.length);
damn, where was my head? i haven't thought doing it that way.
[quote]if you want some help with your PA system i will show you the code![quote]
yes, thank you ^^
i don't know how it will look like when included in my game... maybe the effect will be very cool. i already had an old file which "emulated" the typewriter effect, but your example seems better...
-
Senior Member
ok bust me an e-mail if you want the source
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|