Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   how to make... (https://forums.graalonline.com/forums/showthread.php?t=8579)

everandom 08-01-2001 07:16 AM

how to make...
 
if player says belt red
it will make the belt red, so...
how to make the npc read chat message of the players which are separated by space ?

SkooL 08-01-2001 07:21 AM

NPC Code:
if (playerchats&&strequals(#c,belt red) {setplayerprop #C4,red;}


konidias 08-01-2001 07:37 PM

I think he means without having to write out every single color... you use string parsing.. its pretty easy:

NPC Code:

// NPC made by Konidias
if (playerchats && !strequals(#c,)){
tokenize #c;
setstring this.temp1,#t(0);
setstring this.temp2,#t(1);
if (strequals(#s(this.temp1),belt)){
setplayerprop #C4,#s(this.temp2);
}}



Make an npc and put that in it, and then run the level and say "belt red" or any other color in place of red

The npc check to see if the player chats, and then it tokenizes the words the player says, it sets two temporary strings
temp 1 is "belt" and temp 2 is the color

Then it checks if temp 1 = belt, if it does, then set the players belt to temp 2 (color)

There you go.. if you wanted to add different parts do something like this

NPC Code:

if (strequals(#s(this.temp1),coat)){
setplayerprop #C1,#s(this.temp2);
}



Place that before the last } and that will add changing the players coat color as well ;)

LiquidIce00 08-02-2001 03:11 AM

Quote:

Originally posted by konidias
I think he means without having to write out every single color... you use string parsing.. its pretty easy:

NPC Code:

// NPC made by Konidias
if (playerchats && !strequals(#c,)){
tokenize #c;
setstring this.temp1,#t(0);
setstring this.temp2,#t(1);
if (strequals(#s(this.temp1),belt)){
setplayerprop #C4,#s(this.temp2);
}}



Make an npc and put that in it, and then run the level and say "belt red" or any other color in place of red

The npc check to see if the player chats, and then it tokenizes the words the player says, it sets two temporary strings
temp 1 is "belt" and temp 2 is the color

Then it checks if temp 1 = belt, if it does, then set the players belt to temp 2 (color)

There you go.. if you wanted to add different parts do something like this

NPC Code:

if (strequals(#s(this.temp1),coat)){
setplayerprop #C1,#s(this.temp2);
}



Place that before the last } and that will add changing the players coat color as well ;)

u can just do
NPC Code:

if (playerchats&&startswith(belt ,#c)) {
tokenize #c;
setbeltcolor #s(#t(1));
}



not sure if #s() is needed tho.

Shard_IceFire 08-02-2001 03:36 AM

I know, really!

everandom 08-02-2001 07:12 AM

thanx :)

Tyhm 08-02-2001 11:17 AM

Let's try this one, mixing together the Clothes Chest and some of WhoopA's excellent scripting techniques...
NPC Code:

if(playerchats){
tokenize skin coat sleeve shoe belt;
for(this.i=0;this.i<5;this.i++){
if(startswith(#t(this.i),#c)){
tokenize #c;
setplayerprop #C(#v(this.i)),#t(1); /**
or setplayerprop #C(this.i),#t(1);
or if(this.i=0) setplayerprop #C0,#t(1);
else if(this.i=1) setplayerprop #C1,#t(1);
else if(this.i=2) setplayerprop #C2,#t(1);
else if(this.i=3) setplayerprop #C3,#t(1);
else if(this.i=4) setplayerprop #C4,#t(1);
**/
}
}
}



One of those variations should do the trick.

Xaviar 08-15-2001 04:11 AM

Wow, old thread...

LiquidIce00 08-15-2001 06:03 AM

Quote:

Originally posted by Xaviar
Wow, old thread...
ur sig is l33t

Tyhm 08-15-2001 11:20 AM

The hell? Tokenize is basic to pretty much every string parsing language. If Scheme has it, it's gotta be pretty lame!

Tyhm 08-17-2001 05:45 AM

Yeah. The more common it is, the earlier it appeared, so consequently the simpler it is and the more it's been optimized over the years. I mean, take the * operator verses the for-next loop. You COULD compute x * y as
result=0;
for(i=0;i<x;i++) result+=y;
return result;
but it'd be less efficient because for-next loops are another step removed from the core language. In fact, the computer has to translate THAT into basically a multiplication operator just to cope!

Solareon 08-17-2001 07:27 AM

Ummmmmm
 
Quote:

Originally posted by Tyhm
Yeah. The more common it is, the earlier it appeared, so consequently the simpler it is and the more it's been optimized over the years. I mean, take the * operator verses the for-next loop. You COULD compute x * y as
result=0;
for(i=0;i<x;i++) result+=y;
return result;
but it'd be less efficient because for-next loops are another step removed from the core language. In fact, the computer has to translate THAT into basically a multiplication operator just to cope!

I think Tyhm works for Intel


All times are GMT +2. The time now is 03:32 PM.

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