Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help (https://forums.graalonline.com/forums/showthread.php?t=38161)

WanDaMan 09-18-2002 02:43 PM

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?

emortylone 09-18-2002 11:00 PM

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 :D Try some stuff... I'll get you some examples if I get home in time.
---Shifter

WanDaMan 09-19-2002 03:01 PM

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

R0b1n-NPC 09-19-2002 04:51 PM

do not format like shifter because his formatting is teh suck :| (no offence)

emortylone 09-19-2002 11:08 PM

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

R0b1n-NPC 09-19-2002 11:33 PM

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 :D

Dach 09-20-2002 02:20 AM

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 :D

Great idea, but this has been asked for since functions were added to graalscript long ago (like 3 years or something).

R0b1n-NPC 09-20-2002 02:44 AM

*realises this*

but it SHOULD be added.

RavenTelvecho 09-20-2002 04:13 AM

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 :D

like php ^_^

R0b1n-NPC 09-20-2002 04:27 AM

Exactly!

emortylone 09-20-2002 08:01 AM

WTF is the point?? If you can ONLY set them in functions??? Just have the variables ONLY be changed by them then =/
---Shifter

Dach 09-20-2002 08:39 AM

You'd need an actual return command then, like

return account,message;

emortylone 09-20-2002 09:18 AM

Um, this.vars work regardless of where. then ONLY have functions edit them x.X!
---Shifter

Dach 09-20-2002 09:36 AM

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...

Falcor 09-20-2002 09:51 AM

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*

emortylone 09-20-2002 09:59 AM

Okay, I must admit I am QUITE confused. Are you saying functions aren't able to use vars?!?! What is the point of vars that ONLY can be read and edited by functions? It shouldn't matter because if you have a this.var and the only thing that modifies it is the functions, it works out. I guess I must be missing what you guys are saying...
---Shifter

Graal2001_NAT 09-20-2002 10:12 AM

Quote:

Originally posted by emortylone
Okay, I must admit I am QUITE confused. Are you saying functions aren't able to use vars?!?! What is the point of vars that ONLY can be read and edited by functions? It shouldn't matter because if you have a this.var and the only thing that modifies it is the functions, it works out. I guess I must be missing what you guys are saying...
---Shifter

in php and other programming languages(i think c and c++ as well) there are things such as params, like in php

function(showing,stuff);
if i called that and the function name was

function($1,$2){
echo "$1";
echo "$2";
}
it would display this


showing
stuff

VampiricTutorNewHD 09-20-2002 10:13 AM

Variables can be used in functions. If statements are run before functions.

R0b1n-NPC 09-20-2002 01:51 PM

meh but im so lazy... and i dont see why it cant be done this way.

i can see(by the brackets at the end of the function) that this way was in use once or was planned to be in use.

R0b1n-NPC 09-20-2002 01:53 PM

Quote:

Originally posted by 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*
:\ make it object oriented x.x

Falcor 09-21-2002 05:56 AM

Quote:

Originally posted by R0b1n-NPC


:\ make it object oriented x.x

Directed that to me? I am hardly in a position to edit graal's sorce code, nore would I have any knowledge on what to do.

Graal2001_NAT 09-21-2002 05:58 AM

Quote:

Originally posted by R0b1n-NPC
meh but im so lazy... and i dont see why it cant be done this way.

i can see(by the brackets at the end of the function) that this way was in use once or was planned to be in use.

or maybe stefan needed a way for graal to tell what is a function

R0b1n-NPC 09-21-2002 07:14 AM

stop killing my fun dammit!

Inphektid 09-21-2002 07:17 AM

*Jealous of Robin's signature image* :(

R0b1n-NPC 09-21-2002 07:46 AM

Bwahaha upgrade account for me and i will make one like it for you

LilbrojX 09-21-2002 02:18 PM

blah blah blah why are you trying to script? your just copying some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script who copied some one else who learned how to script and it keeps going on and on so if you dont wanna be flamed like this pointless post you should just give up now because being original is the shnap

WanDaMan 09-21-2002 02:24 PM

well
 
i really need help on how to make money on graal with scripts like bread making from 2001 and so on
thats all i really wanna learn i think i got the hang of vars
this.x=+4;
blah de blah XD

-Snakeandy

LilbrojX 09-21-2002 02:27 PM

Re: well
 
Quote:

Originally posted by WanDaMan
i really need help on how to make money on graal with scripts like bread making from 2001 and so on
thats all i really wanna learn i think i got the hang of vars
this.x=+4;
blah de blah XD

-Snakeandy

wut helped me out the most is that cyb gave me access to the NPC server on frolic and I took a look at those scripts... maybe that's the best way to learn, I'm not too good but I'm a lot better than I used to be...

R0b1n-NPC 09-21-2002 04:23 PM

Magnoria... sounds a bit like maloria

just the name :P

LilbrojX 09-22-2002 11:25 AM

Quote:

Originally posted by R0b1n-NPC
Magnoria... sounds a bit like maloria

just the name :P


is that why I get flamed? the name?? maybe I'll change it... but I thought of magnoria a long time ago and posted some stuff on it then maloria came up and I was like "wut the heck..?"

R0b1n-NPC 09-22-2002 11:55 AM

yeah buddy right


All times are GMT +2. The time now is 02:14 AM.

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