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.


All times are GMT +2. The time now is 07:52 AM.

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