Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   #e uses.. (https://forums.graalonline.com/forums/showthread.php?t=12945)

LiquidIce00 09-26-2001 02:40 AM

#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]

LiquidIce00 09-26-2001 03:09 AM

Quote:

Originally posted by Kaimetsu
Wouldn't it be "mid" in VB?
mid+instr+instrrev+len
mid is #e instr is indexof and instrrev is indexof (from the back)

Falcor 09-26-2001 03:48 AM

setplayerprop #c,#e(0,3,#s(hellostring));

Hel ?

i believe hello is a 5 letter word so it would be

setplayerprop #c,#e(0,5,#s(hellostring));

Just fixing a mistake. could haev ezly pressed the wrong numba.

LiquidIce00 09-26-2001 05:49 AM

Quote:

Originally posted by Falcor
setplayerprop #c,#e(0,3,#s(hellostring));

Hel ?

i believe hello is a 5 letter word so it would be

setplayerprop #c,#e(0,5,#s(hellostring));

Just fixing a mistake. could haev ezly pressed the wrong numba.

no sir startindex starts at 0 not 1

LiquidIce00 09-26-2001 09:15 AM

Quote:

Originally posted by Kaimetsu


He didn't say otherwise. He was disputing the length parameter.

the length is 5 but he related the length to the startindex .. it is related but not the same ..

Falcor 09-26-2001 09:21 AM

I see no difference in star index . only the lenght. Or has the number system changed without me knowing?

setplayerprop #c,#e(0,3,#s(hellostring));
And
setplayerprop #c,#e(0,5,#s(hellostring));

There is onne difference.

Length

not start index. not String.

thankyou

LiquidIce00 09-27-2001 03:12 AM

Quote:

Originally posted by Falcor
I see no difference in star index . only the lenght. Or has the number system changed without me knowing?

setplayerprop #c,#e(0,3,#s(hellostring));
And
setplayerprop #c,#e(0,5,#s(hellostring));

There is onne difference.

Length

not start index. not String.

thankyou

no guy...
your startindex begins at 0 .. and your length is the length-1 ..
for example "kaka" is 4 in length . but the length in #e would be 3 because it counts from 0 not 1..
and before you said "i believe hello is a 5 letter word so it would be"
length wouldnt be 5 just because its a 5 letter word. get it ;)

ArmadeusWarlock 09-27-2001 05:36 AM

hmmmmm
 
well, im not exactly sure how to use it, but i have used it before for testing crap. anyways, i know what he did wrong, -1 uses the whole message and crap, but you said it starts at 1, so h is 1, e 2,l 3...? if not, and it starts from 0, it would still say hell. dont ask me, im already confused :o

nyghtGT 09-27-2001 06:10 AM

it starts at 0 like with tokens .... like
i say "Welcome to Graal"
the tokens set would be:
#t(0)=Welcome
#t(1)=to
#t(2)=Graal
then i use:
NPC Code:

if (playerchats) {
tokenize #c;
message #t(0);
sleep 1.25;
message #t(1);
sleep 1.25;
message #t(2);
sleep 1.25;
message ;
}


the npc would say pausing 1 1/4 seconds after each:
Welcome <pause> to <pause> Graal <pause>

Basically the index is the number of items, but the items count starts at one .... so #t(0) has a value.

And i aint a genious but i suppose its the same as setting the index of all things ....

(please correct me if wrong)

nyghtGT 09-27-2001 06:15 AM

thanx
 
also, thanx for explaining this liquid i wanted to do something that you could use different parts of the players chatfield ...
all it was was a warper for staff without RC ... and i wanted it where you could just say:

warpto 30,30 levelname.graal without having to set strings and all that ....

ArmadeusWarlock 09-27-2001 06:48 AM

heh
 
I have this same idea, and something is always screwed up after i make it. Its always perfect, but its screwed up. it works for the level and x, but not the y. i mean it doesnt work, but it always says there is an error somewhere after the y area.

Falcor 09-27-2001 07:29 AM

p2p wepons cant warp players.

ArmadeusWarlock 09-27-2001 07:42 AM

hmmmmm
 
Then how does admin warpto work on NewMain?

nyghtGT 09-27-2001 07:50 AM

RC
 
for people with RC (for that server only) they can say:
"warpto x y levelname.graal" and it will warp them ... At least it does on my Delteria RC.

ArmadeusWarlock 09-27-2001 07:52 AM

OH. I thought he meant warping through the RC itself, not through graal, you now, like changing x and y crap thru graal. Ok, i get it now

nyghtGT 09-27-2001 07:58 AM

well
 
welll i am not sure that it works for people with RC on P2P servers being as Delteria is not a pay server ....

LiquidIce00 09-28-2001 12:23 AM

Quote:

Originally posted by Falcor
p2p wepons cant warp players.
yes u can just do triggeraction on the control npc

Falcor 09-28-2001 12:31 AM

i MENT DIRECTLY. lIEK WITH SETLEVEL AND SETLEVEL2.

Sep3kP2P 09-28-2001 12:45 AM

read the warpers thread


All times are GMT +2. The time now is 09:31 PM.

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