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 05-05-2011, 01:56 AM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by cbk1994 View Post
It is good practice to always format well, even if you're the only person who is going to see it. You will generally make less mistakes.
I only meant if 'he' wanted to do it, and no one else would see it, he can go ahead.. Not saying everyone in general should do it lol.. I took the time in changing Stefans 2001 baddy script styling it correctly. D:

If I didn't I don't think I'd ever have figured out what it was doing..
But I agree.. It is kind of like doing a turn single at a turn or stop sign even if there is no one else there to see.. Still a good habit to keep/practice..



Quote:
Originally Posted by cbk1994 View Post
It will return the result of the statement.

PHP Code:
echo(== 1); // echoes true
echo(== 0); // echoes false
echo("a" == "a"); // echoes true
echo((2) == 7); // echoes true 
Oh I see.. So would this be a good thing inside a class / function for ... w/e the function might do.. assuming the point is to be true or false... Also, can you return more then one thing, for instance maybe X and Y? or would you have to return X and Y in an array with X and Y in it?

I usually do this. variables so they work through the whole script D: and have not made any real functions that needed to be in classes and used everywhere, but I would like to make a bush system.. and other things..

One more thing... xD returns do not return temp. variables? I've had a problem with this and had to make the temp. a this. to pass it back x.x;
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #2  
Old 05-05-2011, 02:05 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Devil_Lord2 View Post
Oh I see.. So would this be a good thing inside a class / function for ... w/e the function might do.. assuming the point is to be true or false...
Not sure what you're asking.

Quote:
Also, can you return more then one thing, for instance maybe X and Y? or would you have to return X and Y in an array with X and Y in it?
You can only return one value. Use arrays for returning multiple.

Quote:
One more thing... xD returns do not return temp. variables? I've had a problem with this and had to make the temp. a this. to pass it back x.x;
Functions return values, not variables. You can assign them to whatever variable you want to.
__________________
Reply With Quote
  #3  
Old 05-06-2011, 09:29 AM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by cbk1994 View Post
Not sure what you're asking.
For instance, I guess function onPlayerGrabs(){ }
could be made a class that could return true and make the if statement work..

if (onPlayerGrabs()){} "I think could work assuming it is joined to the class"
could return true or false.. I don't know how it works really...

Quote:
Originally Posted by cbk1994 View Post
You can only return one value. Use arrays for returning multiple.
Oh I see.. thanks ^.^;
In the future could they do it with commas to add more, or is there no point?


Quote:
Originally Posted by cbk1994 View Post
Functions return values, not variables. You can assign them to whatever variable you want to.
I've had a function go through all players, and didn't accept externals.
I had it as:
variable
temp.count = 0;

a lot of script...

return temp.count
and
return count

which kept becoming 0 or null... in the end I set it to this.count = temp.count and it finally worked with:

return this.count

I couldn't get it to pass the temp. variable D:
__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



Reply With Quote
  #4  
Old 05-06-2011, 12:15 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Devil_Lord2 View Post
For instance, I guess function onPlayerGrabs(){ }
could be made a class that could return true and make the if statement work..

if (onPlayerGrabs()){} "I think could work assuming it is joined to the class"
could return true or false.. I don't know how it works really...
That would be an event, not a statement. GS2 is event-based, so you do things after an event happens, unlike GS1 where you use if-statements for events, lol.

Quote:
Oh I see.. thanks ^.^;
In the future could they do it with commas to add more, or is there no point?
There is no reason to, arrays make more sense.

Quote:
I've had a function go through all players, and didn't accept externals.
I had it as:
variable
temp.count = 0;

a lot of script...

return temp.count
and
return count

which kept becoming 0 or null... in the end I set it to this.count = temp.count and it finally worked with:

return this.count

I couldn't get it to pass the temp. variable D:
Do you have the script? You must have been doing something else wrong.
__________________
Reply With Quote
  #5  
Old 05-06-2011, 09:09 PM
Devil_Lord2 Devil_Lord2 is offline
David K?
Devil_Lord2's Avatar
Join Date: Apr 2011
Location: PA, MD.
Posts: 643
Devil_Lord2 can only hope to improve
Quote:
Originally Posted by cbk1994 View Post
That would be an event, not a statement. GS2 is event-based, so you do things after an event happens, unlike GS1 where you use if-statements for events, lol.
I don't know D: It was an example I got a while ago from Thor, I was going to make a movement system like he did but I didn't quite understand it. I asked and he said functions can give true and false and be used in statements..

PHP Code:
if(movement.isAttemptingMove()){
  
setani("walk");
  return;

Quote:
Originally Posted by cbk1994 View Post
Do you have the script? You must have been doing something else wrong.
I don't offhand but I think it was either on twinnys page or somewhere on the forum.. I think I can find it. I was having the problem with getting more playercount than there were on the actual server.. found something to overcome it, but it still listed RC's lol


-EDIT-
Nevermind, I'm still using it ^.^;


PHP Code:
function getPlayerCount(){
  
temp.count 0;
    for (
temp.plallplayers ){
      
temp.count += (! pl.isExternal );    
    }
 
this.count count;
 return 
this.count;

if I did this.chat = count; or temp.count inside the function it would give back the correct number.

if I did this.chat = count; or temp.count outside the function it would give back the 0 or null. "I mean inside the same statement / function it is being called in"

Eventually I kept it and settled for this. but now that I think about it, this. isn't really returning because it's global in the script clientside, isn't it? lmao


>.> Further clarification..
PHP Code:
function onWa****(){
  
getPlayerCount();
  for(
i=0;i<allplayers.size();i++){
    
triggeraction(x,y,"door",allplayers[i]);
    
sleep(.1);
  }
}
function 
getPlayerCount(){
  
temp.count 0;
    for (
temp.plallplayers ){
      
temp.count += (! pl.isExternal );    
    }
 
this.count count;
 return 
this.count;

__________________

Digital Media Artist - David K? </3 (UnLoved)
www.davidkrout.com
www.twitch.com/DavidKkz



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 12:53 PM.


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