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-18-2002, 02:43 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
Help

hey i dont understand Variables (cant spell it) and what the do. i went on your site projectshifter and i got to the variables bit and i just didnt understand what they do?can some one help me learn them?
__________________
V$:CONFL16T
Reply With Quote
  #2  
Old 09-18-2002, 11:00 PM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Ah, they are VERY useful. They keep track of numbers. For example:
NPC Code:

if (created)
{ this.hit=0;}

if (washit)
{ this.hit=this.hit+1;
hit();
}

function hit()
{ setcharprop #c,#v(this.hit);}


that makes this.hit go up ONE time everytime it was hit. And it will display it via #c as how many hits have happened. This.vars are ONLY for NUMBERS, no data can be stored in them. But I've done things like this:
NPC Code:

if (created)
{ this.dist=abs(npcs[1].save[1]-x)-abs(npcs[1].save[2].y);}


Something like that, i'm not exactly sure b/c I'm at school :P and i don't have much time. BUT I had a central NPC set npcs[1].save[1 and 2] to it's x and y. So this.dist was the distance it was from the central point. It was useful because I was making a clock that rotated around the middle, so I didn't have to code everything to be so far from the central point, I could move it out to ANY distance I wanted and it would still make a circle around that middle point. the radius changed, but the middle point didn't Try some stuff... I'll get you some examples if I get home in time.
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #3  
Old 09-19-2002, 03:01 PM
WanDaMan WanDaMan is offline
Master Tux
WanDaMan's Avatar
Join Date: Aug 2002
Location: England, United Kingdom
Posts: 5,571
WanDaMan is a jewel in the roughWanDaMan is a jewel in the rough
Send a message via MSN to WanDaMan
i get..

hey i get the top one but not the bottom one :/ i think it has something to do with the save and stuff in it
the top 1 is easy to understand and i think i can get the hang of it to
Quote:
if (created)
{ this.hit=1;}

if (washit)
{ this.hit=this.hit+3;
hit();
setcharprop #c,You have hit it #v(this.hit) Times;
}

function hit()
{ setcharprop #c,#v(this.hit);}
i think that might work i dunno i am guessing here XD
--snakeandy
__________________
V$:CONFL16T
Reply With Quote
  #4  
Old 09-19-2002, 04:51 PM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
do not format like shifter because his formatting is teh suck :| (no offence)
__________________
- R0bin
Reply With Quote
  #5  
Old 09-19-2002, 11:08 PM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
w00t WooT! USe my scripting style, it's going Revolutionary! people use it :P Yes, I like my scripting, just b/c you don't doesn't mean you are allowed to become jealous But obviously you're not sure how to use functions :P If you put: something(); it means that it will jump to the part of the scripted marked:
function something()
and perform all actions under it. I always use return; at the end if it isn't looping for teh hell of it. What you did would have it set it to what you said, then it would set to mine, so it then becomes inefficient b/c you are setting it twice and one will be erased too fast to read it?
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #6  
Old 09-19-2002, 11:33 PM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
i think functions should have custom variables that can only be used inside the functions, e.g.

PHP Code:
if (playerenters) {
  
killplayer(#a,Hahah you suck);
}

function 
killplayer(account,message) {
  
with (getplayer(account)) {
    
playerhearts=0;
    
say2 message;
  }

that would be teh 1337
__________________
- R0bin
Reply With Quote
  #7  
Old 09-20-2002, 02: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 R0b1n-NPC
i think functions should have custom variables that can only be used inside the functions, e.g.

PHP Code:
if (playerenters) {
  
killplayer(#a,Hahah you suck);
}

function 
killplayer(account,message) {
  
with (getplayer(account)) {
    
playerhearts=0;
    
say2 message;
  }

that would be teh 1337
Great idea, but this has been asked for since functions were added to graalscript long ago (like 3 years or something).
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #8  
Old 09-20-2002, 02:44 AM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
*realises this*

but it SHOULD be added.
__________________
- R0bin
Reply With Quote
  #9  
Old 09-20-2002, 04:13 AM
RavenTelvecho RavenTelvecho is offline
Registered User
RavenTelvecho's Avatar
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 0
RavenTelvecho is on a distinguished road
Send a message via ICQ to RavenTelvecho Send a message via AIM to RavenTelvecho Send a message via Yahoo to RavenTelvecho
Quote:
Originally posted by R0b1n-NPC
i think functions should have custom variables that can only be used inside the functions, e.g.

PHP Code:
if (playerenters) {
  
killplayer(#a,Hahah you suck);
}

function 
killplayer(account,message) {
  
with (getplayer(account)) {
    
playerhearts=0;
    
say2 message;
  }

that would be teh 1337
like php ^_^
__________________

^tuff newbie ;x
RavenTelvecho
!Booj
we are 'brothers'
Reply With Quote
  #10  
Old 09-20-2002, 04:27 AM
R0b1n-NPC R0b1n-NPC is offline
Registered User
Join Date: Sep 2002
Posts: 397
R0b1n-NPC is on a distinguished road
Exactly!
__________________
- R0bin
Reply With Quote
  #11  
Old 09-20-2002, 08:01 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
WTF is the point?? If you can ONLY set them in functions??? Just have the variables ONLY be changed by them then =/
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #12  
Old 09-20-2002, 08:39 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
You'd need an actual return command then, like

return account,message;
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #13  
Old 09-20-2002, 09:18 AM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
Um, this.vars work regardless of where. then ONLY have functions edit them x.X!
---Shifter
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
  #14  
Old 09-20-2002, 09:36 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
Shifter, what's your point? Of course there is a way to work around not being able to pass strings/variables to functions, but the point is that being able to do so would greatly increase the functionality of functions...
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #15  
Old 09-20-2002, 09:51 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Function arguments, it was suggested by me and a few other people long long time ago, yet never added, Some problem that graal isn't too object-orientated. *shrugs*
__________________

subliminal message: 1+1=3
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:51 AM.


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