Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-26-2001, 02:40 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
#e uses..

Im bored.. so I am going to teach some ppl how to do some neat things using #e..
I learned #e+indexof when I was doing vb (indexof is InStr .. and they also have InStrRev)
Also another thing which can be used with it, is indexof()
#e is used for doing string parsing .. like tokenize and so on..
it allows you to get part of a str .. for example:
setstring hellostring,hello how are you?;
setplayerprop #c,#e(0,3,#s(hellostring));
That would return "hello"
now you might say.. thats useless .. well its not!
for example ..
the bomy script when you say
command one -> command two
you can get the first part and second part easily with #e!
how?
using indexof and strlen it can be easily done

if (playerchats) {
this.indexof=indexof(->,#c);
if (this.indexof>=1) {
setstring command1,#T(#e(0,strlen(#c)-this.indexof,#c));
setstring command2,#T(#e(this.indexof+2,strlen(#c)-this.indexof,#c));
}
}

now to explain ..
I first got the indexof to a variable because i want to make the #e's shorter and also check to see if the player said
something->something
*indexof will return the location of the partstr specified in that string*
then I check to see if this.indexof is >= 1 .. why? because if the partstr does not appear in the string (if they said something that doesnt contain ->) it will return -1.. and I did >=1 because we want to ignore indexof if it is 0 (because that means they said ->something .. and not something->something)

after that we find the first part (before ->) using #e and strlen and the indexof..
command1 of course begins in the beggining so our startindex for #e in command1 will be 0.
the length of the string will be the length of what the player said minus indexof.
for example if the player said "kaka->kaka"
indexof -> will be 4 and strlen of #c will be 10
I did #T() which is trim .. it removes any spaced from the end/beggining of a string. it is useful there because the player could have said "whatever -> whatever"
and we wouldnt want our string to be "whatever " we want it without the space.

the second command is a bit more confusing .. since the startindex is not the beggining of a string, but after the ->
so the only change will be the startindex which will be this.indexof+2
why +2 ? well because the strlen of -> is 2. and if we just did this.indexof then it would return "->whatever" as the 2nd part.. and we dont want that!
so add +2 to eliminate the ->
there you go=)

now just use your imagination ..
here is a little code of something cool that can be done with #e (on UN the chat scroller is using #e.. but a little more complicated.. this is a simple scroller)
[code]
if (playerchats) {
while (strlen(#c)>0) {
sleep .2;
setplayerprop #c,#e(0,strlen(#c)-1,#c);
}
}
[code]
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)

Last edited by LiquidIce00; 09-26-2001 at 03:13 AM..
Reply With Quote
 


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 09:33 PM.


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