Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Tokens... (https://forums.graalonline.com/forums/showthread.php?t=48644)

Idrox0 10-16-2003 12:10 AM

Tokens...
 
Does anyone know how to make a code that will show as many tokens as made? An example...

NPC Code:

if (playerchats) {
tokenize #c;
message #t(0) #t(1) ...;
}



How would I make the npc show just as many words as said? I have tried this next code to show the text you say up to a limit of five:

NPC Code:

if (playerchats) {
tokenize #c;
message #t(0) #t(1) #t(2) #t(3) #t(4);
}



But it wont say anything. I once saw the code, but it was on Doomsday, and that's gone. Anyone know it?

Python523 10-16-2003 12:17 AM

use tokenscount to get the number of tokens and work from there

Nappa 10-16-2003 01:26 AM

Wouldn't it be easier to use #e ?

Riot-Starter 10-16-2003 01:27 AM

Why use tokenize when you are displaying what the player said?
message #c; would make more sense to me.

osrs 10-16-2003 01:36 AM

Quote:

Originally posted by Riot-Starter
Why use tokenize when you are displaying what the player said?
message #c; would make more sense to me.

I think he wants to know how much words are displayed.

Idrox0 10-17-2003 05:26 AM

Ok, I would use #c, but i want something a bit more, like, everything except the first word. Anyone get this? I already know what tokenscount is and all. Like, if i said "/moo Hello, my name is bob." the npc would say, "Hello, My name is Bob". Or if i said, "/moo It's a fine day out, isn't it?" it would say, "It's a fine day out, isn't it?" Something that would put as many tokens as words you say. What is the syntax/formula for that?

DustyPorViva 10-17-2003 05:39 AM

NPC Code:

if (playerchats) {
setplayerprop #c,#e(strlen(#I(#c,0)),strlen(#c)-strlen(#I(#c,0)),#c);
}



Didn't test it, but is that what your looking for?

Lance 10-17-2003 05:43 AM

Re: Tokens...
 
Quote:

Originally posted by Idrox0
Does anyone know how to make a code that will show as many tokens as made? An example...

NPC Code:

if (playerchats) {
tokenize #c;
message #t(0) #t(1) ...;
}



How would I make the npc show just as many words as said? I have tried this next code to show the text you say up to a limit of five:

NPC Code:

if (playerchats) {
tokenize #c;
message #t(0) #t(1) #t(2) #t(3) #t(4);
}



But it wont say anything. I once saw the code, but it was on Doomsday, and that's gone. Anyone know it?

This may be reaching, but...could you be possibly trying this in a weapon NPC instead of a level NPC?

If it's a level NPC, then that code you said should just work fine. If it's a weapon, then it will not, as the NPC does not physically exist in the level for the message command to work, and you will want to use setplayerprop #c,(stuff); to change the player's chat.

Idrox0 10-17-2003 09:12 AM

Well dusty, the code didn't work, but the syntax i saw on DoomsDay was very similar... and no, it's not in a weapon, just an NPC.

Lance 10-17-2003 09:42 AM

Quote:

Originally posted by Idrox0
Well dusty, the code didn't work, but the syntax i saw on DoomsDay was very similar... and no, it's not in a weapon, just an NPC.
Oh, I see what it's doing. With your (not Dusty's) code, it will only message if you have n-1 words in your chat text, where n is the amount of tokens you were trying to display with that message. So, if you're trying to display #t(0) through #t(4), that's 5 tokens, so you would have to say 4 or more words for it to work.

As for Dusty's code:
Dusty, when exactly is the string containing your chat text a string list?

osrs 10-17-2003 06:36 PM

I think #e() is your problem.

Idrox0 10-17-2003 09:48 PM

Did Doomsday have a website? If so, I can get the script there. And Lance, you're wrong, it can't be 4 or more... just 4:o.

Kaimetsu 10-17-2003 10:08 PM

If you were a pretty good scripter, you'd figure it out yourself :-p

The simplest way would be to use #e, using the first token's length to deduce the second token's start index.

Dach 10-17-2003 10:25 PM

Quote:

Originally posted by Idrox0
Did Doomsday have a website? If so, I can get the script there. And Lance, you're wrong, it can't be 4 or more... just 4:o.
did you even check it? Or did you just assume that because you want it to work a certain way means that it only works that way even if you didn't script it that way?

whats up with that n-1 thing anyhow? I would've figured that if it were to not work in any circumstances it just wouldn't work if the tokenscount was any less than the highest index of tokens being looked at...

Lance 10-18-2003 02:25 AM

Quote:

Originally posted by Idrox0
And Lance, you're wrong, it can't be 4 or more... just 4:o.
Um, no I'm not. You can say more words than you call the tokens of - it's just when you say fewer words than tokens called minus one that there's a problem. Test it for yourself.

Quote:

Originally posted by Dach


whats up with that n-1 thing anyhow? I would've figured that if it were to not work in any circumstances it just wouldn't work if the tokenscount was any less than the highest index of tokens being looked at...

No idea. The engine apparently tolerates one variable that doesn't exist, but having any more than that will cause it to misbehave.

Idrox0 10-18-2003 11:58 PM

Quote:

Origianally posted by: Lance
Um, no I'm not. You can say more words than you call the tokens of -

I know you can say more words than tokens, but i don't think the NPC would show all of them(which is what I want).

Lance 10-19-2003 12:45 AM

Quote:

Originally posted by Idrox0

I know you can say more words than tokens, but i don't think the NPC would show all of them(which is what I want).

Well, I was still talking about your original code, not about the fiting code.

Out of curiosity, what do you need to use all of the tokens for? There are a variety of ways to get what you want, but they really depend on your application.

Idrox0 10-19-2003 10:34 AM

Alright... what I'm trying to get is an npc that when you put a certain prefix such as "/moo" that it would show all the words after it on all the players' screens. Something like the Events Team thing on Babylon where when they they say "setevent2" that everything else appears on the top-left of the players' screens. Capiche? Again, does DoomsDay have a website?

Riot-Starter 10-19-2003 11:03 AM

Quote:

Originally posted by DustyPorViva
Well try this I guess, again I haven't tested:
You know if you put -1 for the length it will go to the end?

DustyPorViva 10-19-2003 11:09 AM

I knew it, just never used it I guess.

osrs 10-19-2003 09:16 PM

Quote:

Originally posted by Idrox0
Alright... what I'm trying to get is an npc that when you put a certain prefix such as "/moo" that it would show all the words after it on all the players' screens. Something like the Events Team thing on Babylon where when they they say "setevent2" that everything else appears on the top-left of the players' screens. Capiche? Again, does DoomsDay have a website?
<code removed>

Capiche? :grin:

DustyPorViva 10-19-2003 09:19 PM

No script posting allowed, sorry, but Kai deleted mines.

osrs 10-19-2003 10:15 PM

Quote:

Originally posted by DustyPorViva
No script posting allowed, sorry, but Kai deleted mines.
I don't think that's a whole code.

DustyPorViva 10-20-2003 12:47 AM

Mines was just as short.

Lance 10-20-2003 01:26 AM

osrs: pointless to use #T if you are using 5 as the startindex, as that forces you to have a space in front of it for the #e to cut it off, and then there's nothing left for the #T to trim.

osrs 10-20-2003 02:00 AM

Quote:

Originally posted by Lance
osrs: pointless to use #T if you are using 5 as the startindex, as that forces you to have a space in front of it for the #e to cut it off, and then there's nothing left for the #T to trim.
Hm, really. >.>
I don't know why i used #T since i put -1 as length too.
My bad.

ZeLpH_MyStiK 10-23-2003 06:01 AM

ok here's an pre-alpha version lol might not work probably will tho

<removed>


as i said i think this should work so copy it and try it...if not ur welcome to contact me and i'll fix it for you

ZeLpH_MyStiK 10-23-2003 06:08 AM

o.O im sorry cant read lol you want it to display everything except the first word well here:

<removed>

this is better than using tokens because it'll let you use commas where as if u use tokenize and u say something like "hello, to myself" it'll only display "hello"
hope this helps ;)

Python523 10-23-2003 07:59 AM

Quote:

Originally posted by osrs


Hm, really. >.>
I don't know why i used #T since i put -1 as length too.
My bad.

#T has no relationship between the -1 at all

it's used so, say I say:
/testTEST
/test TEST
strequals(#T(#e(5,-1,#c)),TEST)
both instances would return true

but well... I guess it does have some sort of relation with the 01, #T is trimming all spaces at the from and end of a string
so #T( test ) = test #T ( 123) = 123, etc, most people just don't need to use it for the end part because they know to use -1, instead of say just guessing the length is going to be 100 then trimming it

Lance 10-23-2003 09:29 AM

Zelph: Stop posting full scripts to solve people's problems. -_-

osrs 10-23-2003 04:29 PM

Quote:

Originally posted by Python523

#T has no relationship between the -1 at all

it's used so, say I say:
/testTEST
/test TEST
strequals(#T(#e(5,-1,#c)),TEST)
both instances would return true

but well... I guess it does have some sort of relation with the 01, #T is trimming all spaces at the from and end of a string
so #T( test ) = test #T ( 123) = 123, etc, most people just don't need to use it for the end part because they know to use -1, instead of say just guessing the length is going to be 100 then trimming it

I know #T has no relationship between the -1.
I jus said that #T was really not needed there. x.x'

ZeLpH_MyStiK 10-24-2003 01:29 AM

Sorry Lance, as you have probably noticed, im new to posting on the forum, as i had my password changed and the forum password did not changed along with my account password. I never bothered to check the rules, which states no posting scripts that players can just copy and paste. So this is a apologize to all and hope you can all forgive me.

Lance 10-24-2003 03:54 AM

Quote:

Originally posted by ZeLpH_MyStiK
Sorry Lance, as you have probably noticed, im new to posting on the forum, as i had my password changed and the forum password did not changed along with my account password. I never bothered to check the rules, which states no posting scripts that players can just copy and paste. So this is a apologize to all and hope you can all forgive me.
S'ok; now that you know, it's all good. :)


All times are GMT +2. The time now is 10:39 AM.

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