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 09-07-2003, 08:57 PM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
Teaching: for()

for those of you who are new like me and dont know how the for command it used, its like saying:


i=0//the index is equil to zero
while(i<64)//this is like adding to the if(), saying the index must be less then 64.
and then the last section is adding or subtracting forom the index.
so all together it looks like:

for(i=0; i<64; i+=2{
in here u may put commands. i will also give one example of how this may be used.

if(created){toweapons test;
}
if(weaponfired){
for(explosionx=playerx; explosionx<64 explosionx+=1.5
putexplosion 1,explosionx,playery+1;
}
}

this script is a little messed up but does show a little how to use for.

note: props to jagen for teaching me what for's are, and also if someone can show me how to put in a scripting section to make this easier to read it would be greatly apreciated.
__________________
Im still searching...

Last edited by Mal1core; 09-07-2003 at 11:04 PM..
Reply With Quote
  #2  
Old 09-07-2003, 09:44 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Re: Teaching: for()

Quote:
Originally posted by Mal1core
for those of you who are new like me and dont know how the for command it used, its like saying:


if (i=0)//if the index is equil to zero it will perform the command
while(i<#)//this is like adding to the if(), saying the index must be less then 64.
and then the last section is adding or subtracting forom the index.
so all together it looks like:

for(i=0; i<64; i+=2{
in here u may put commands. i will also give one example of how this may be used.

if(created){toweapons test;
}
if(weaponfired){
for(explosionx=playerx; explosionx<64 explosionx+=1.5
putexplosion 1,explosionx,playery+1;
}
}

this script is a little messed up but does show a little how to use for.

note: props to jagen for teaching me what for's are, and also if someone can show me how to put in a scriting section to make this easier to read it would be greatly apreciated.
you misunderstood me x_X its
i=0;
while(i<#) i++;
not if(i=0)
Reply With Quote
  #3  
Old 09-07-2003, 09:59 PM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
oh yeah, i messed up, lol.
__________________
Im still searching...
Reply With Quote
  #4  
Old 09-08-2003, 02:48 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
>.>

format:
for (initialization-operation;test;increment-operation){
commands;
}
(don't kill me if I got the words wrong, they still make sense >:O)

initialization-operation = what happens right before the loop begins for the first time.

test = what the loop will check and make sure is true before going onto the next loop.

increment-operation = what happens after one loop completes

EXAMPLE:
for (i=0;i<10;i++){
setplayerprop #c,I CAN COUNT: #v(i)!;
}

OUTPUT:
I CAN COUNT: 0!
I CAN COUNT: 1!
I CAN COUNT: 2!
I CAN COUNT: 3!
I CAN COUNT: 4!
I CAN COUNT: 5!
I CAN COUNT: 6!
I CAN COUNT: 7!
I CAN COUNT: 8!
I CAN COUNT: 9!

WHAT IT MEANS:
for (i=0;i<10;i++){
setplayerprop #c,I CAN COUNT: #v(i)!;
}
i=0 makes it set the variable "i" to 0 before beginning the loop.

for (i=0;i<10;i++){
setplayerprop #c,I CAN COUNT: #v(i)!;
}
i<10 checks whether or not the variable "i" is less than 10 before beginning the loop

for (i=0;i<10;i++){
setplayerprop #c,I CAN COUNT: #v(i)!;
}
i++ makes the variable "i" increase by 1 after a loop completes.


ORDER OF OPERATIONS:
i is set to 0
checks whether or not i is less than 10
if i is less than 10, sets players' chat text to "I CAN COUNT: <value of i>!
increases i by 1
checks whether or not i is less than 10
if i is less than 10, sets players' chat text to "I CAN COUNT: <value of i>!
...and so on



Some people may be confused why it never outputs "I CAN COUNT: 10!".. thats because the test checks if its less than 10, meaning it will not actually include 10. If you wanted to include 10, you could make the test "i<11" or "i<=10"
__________________


Last edited by CheeToS2; 09-08-2003 at 04:20 AM..
Reply With Quote
  #5  
Old 09-08-2003, 02:52 AM
Riot-Starter Riot-Starter is offline
Registered User
Join Date: Aug 2001
Location: Central Florida, USA
Posts: 79
Riot-Starter is on a distinguished road
Send a message via AIM to Riot-Starter
Quote:
Originally posted by CheeToS2
* setplayerprop #c,I CAN COUNT: #v(i)!;

Double check syntax if not using the test button in the editer
Reply With Quote
  #6  
Old 09-08-2003, 02:55 AM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
this should get stickied along with detailed explainations of other comands when they pop up.... and cheetos, im not exactly sure some people know like, initializing opertation and such, most do but i wouldnt be surprised if they didnt, anyway, there u have it folks, 2 nice and detailed explainations of for loops

// NPC made by Malicore (Hybrid)
if (created) {toweapons BOOMY;
}
if (playertouchsme) {
}
if(weaponfired && dir=3
){
for(explosionx=playerx+5; explosionx<playerx+15; explosionx+=1.5{
sleep .1;
putexplosion 1,explosionx,playery+1;
}
}
if(weaponfired && dir=1){
for(explosionx2=playerx-5; explosionx2>playerx-15; explosionx2-=1.5{
sleep .1;
putexplosion 1,explosionx2,playery+1;
}
}
if(weaponfired && dir=0){
for(explosiony=playery-5; explosiony>playery-15; explosiony-=1.5{
sleep .1;
putexplosion 1,playerx+1,explosiony;
}
}
if(weaponfired && dir=2){
for(explosiony2=playery+5; explosiony2<playery+15; explosiony2+=1.5{
sleep .1;
putexplosion 1,playerx+1,explosiony2;
}
}

i am now working on controlling the fire
__________________
Im still searching...

Last edited by Mal1core; 09-08-2003 at 03:41 AM..
Reply With Quote
  #7  
Old 09-08-2003, 03:20 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
Originally posted by Mal1core
lookie ^
icky-icky doo-doo
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #8  
Old 09-08-2003, 03:42 AM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
huh?
__________________
Im still searching...
Reply With Quote
  #9  
Old 09-08-2003, 04:10 AM
Riot-Starter Riot-Starter is offline
Registered User
Join Date: Aug 2001
Location: Central Florida, USA
Posts: 79
Riot-Starter is on a distinguished road
Send a message via AIM to Riot-Starter
Quote:
Originally posted by Mal1core
huh?
Hes saying the code uses bad format and inefficient coding.
Reply With Quote
  #10  
Old 09-08-2003, 04:19 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
woops, haha, I was in a rush while typing that so I could finish my homework *fix* (they all have the same error cause I copy/pasted ;o)
__________________

Reply With Quote
  #11  
Old 09-08-2003, 04:21 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by Mal1core
[snip]toweapons BOOMY;[/snip]
Use toweapons in a script online, and die.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #12  
Old 09-08-2003, 05:23 AM
Mal1core Mal1core is offline
Registered User
Join Date: Jul 2003
Location: Rochester, New York
Posts: 41
Mal1core is on a distinguished road
Send a message via AIM to Mal1core Send a message via Yahoo to Mal1core
Quote:
Originally posted by Tseng


Use toweapons in a script online, and die.
i have no experiance serverside, what would i replace it with?
__________________
Im still searching...
Reply With Quote
  #13  
Old 09-08-2003, 05:26 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Quote:
Originally posted by Mal1core


i have no experiance serverside, what would i replace it with?
In NC (the 4 green buttons on the bottom-right of RC, above the chat box), click the second button (the big red W), that will open the Database weapons list. Click add, set the weapon's icon, put the script in there, take out any playertouchsme & toweapons stuff, and put //#CLIENTSIDE at the top, click send.
to get the weapon, use addweapon WeaponName; in a script
__________________

Reply With Quote
  #14  
Old 09-08-2003, 05:44 AM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about-Ramirez- has a spectacular aura about
Quote:
Originally posted by Tseng


Use toweapons in a script online, and die.
I guess I should go die then. *points at Classic*
__________________
Kat
Reply With Quote
  #15  
Old 09-08-2003, 01:12 PM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Quote:
Originally posted by -Ramirez-

I guess I should go die then. *points at Classic*
except classic
__________________

Reply With Quote
  #16  
Old 09-08-2003, 03:40 PM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by -Ramirez-

I guess I should go die then. *points at Classic*
Yes, you should.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #17  
Old 09-08-2003, 07:20 PM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about-Ramirez- has a spectacular aura about
Quote:
Originally posted by Tseng


Yes, you should.
__________________
Kat
Reply With Quote
  #18  
Old 09-08-2003, 07:30 PM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by -Ramirez-

Make your new weapons for NPC-Server.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #19  
Old 09-08-2003, 08:46 PM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about-Ramirez- has a spectacular aura about
Quote:
Originally posted by Tseng


Make your new weapons for NPC-Server.
I haven't added any new permanent weapons, just messing around with the clientside-only scripting when I was first hired.
__________________
Kat
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 09:58 PM.


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