Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-01-2001, 07:16 AM
everandom everandom is offline
Registered User
Join Date: Apr 2001
Posts: 286
everandom is on a distinguished road
Question 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 ?
__________________
RaNdoM InSaNiTy
!!??!!??!!??!!??!!
I'm always been unwanted!!!
MY english kwap
Reply With Quote
  #2  
Old 08-01-2001, 07:21 AM
SkooL SkooL is offline
somebody to love
Join Date: Jun 2001
Location: bat country.
Posts: 3,446
SkooL is on a distinguished road
Send a message via AIM to SkooL
NPC Code:
if (playerchats&&strequals(#c,belt red) {setplayerprop #C4,red;}

__________________
the sky is falling
Reply With Quote
  #3  
Old 08-01-2001, 07:37 PM
konidias konidias is offline
Old Bee
konidias's Avatar
Join Date: Jul 2001
Location: Orlando, FL
Posts: 7,222
konidias will become famous soon enough
Send a message via AIM to 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
__________________

Put this image in your sig if you support Bomy Island! (g2k1 revision)
play bomberman while you wait!


Reply With Quote
  #4  
Old 08-02-2001, 03:11 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
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.
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #5  
Old 08-02-2001, 03:36 AM
Shard_IceFire Shard_IceFire is offline
Registered User
Shard_IceFire's Avatar
Join Date: Jun 2001
Location: Eastern Harkoonia
Posts: 861
Shard_IceFire is on a distinguished road
I know, really!
__________________

-=Shard IceFire=-
Reply With Quote
  #6  
Old 08-02-2001, 07:12 AM
everandom everandom is offline
Registered User
Join Date: Apr 2001
Posts: 286
everandom is on a distinguished road
thanx
__________________
RaNdoM InSaNiTy
!!??!!??!!??!!??!!
I'm always been unwanted!!!
MY english kwap
Reply With Quote
  #7  
Old 08-02-2001, 11:17 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
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.
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #8  
Old 08-15-2001, 04:11 AM
Xaviar Xaviar is offline
Registered User
Join Date: Aug 2001
Location: Fairyland
Posts: 463
Xaviar is on a distinguished road
Send a message via ICQ to Xaviar Send a message via AIM to Xaviar
Wow, old thread...
__________________
One by one, the penguins steal my sanity.

*cookie for Xaviar* --Originally posted by Tyhm

--Xaviar

A m e r i c a
Reply With Quote
  #9  
Old 08-15-2001, 06:03 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
Quote:
Originally posted by Xaviar
Wow, old thread...
ur sig is l33t
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #10  
Old 08-15-2001, 11:20 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
The hell? Tokenize is basic to pretty much every string parsing language. If Scheme has it, it's gotta be pretty lame!
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #11  
Old 08-17-2001, 05:45 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
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!
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #12  
Old 08-17-2001, 07:27 AM
Solareon Solareon is offline
Registered User
Solareon's Avatar
Join Date: Jun 2001
Location: In a corn field
Posts: 548
Solareon is on a distinguished road
Send a message via AIM to Solareon
Lightbulb 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
__________________
-Solareon Doll, thanks to BirdBird_0 for making it
-
First person to choke on a gummi bear and cough it up =)

AIM: SolareonX
flame me 24/7 roffel
-- l33t
JubieSaotomeX < Me
Reply With Quote
Reply


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


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