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-22-2008, 02:12 AM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
booleans, can I do this?

PHP Code:
setlevel2((player.guild == "Convict" && player.level != "era_prison-break.nw""era_present_00-00.nw""era_prison-break.nw"), 3030); 
with the 2 checks?
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #2  
Old 08-22-2008, 02:24 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
Try this:
PHP Code:
setlevel2(((player.guild == "Convict" && player.level.name != "era_prison-break.nw" ) ? "era_presemt_00-00.nw" "era_prison-break.nw"), 3030); 
__________________
Reply With Quote
  #3  
Old 08-22-2008, 04:25 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
Try this:
PHP Code:
setlevel2(((player.guild == "Convict" && player.level.name != "era_prison-break.nw" ) ? "era_presemt_00-00.nw" "era_prison-break.nw"), 3030); 
I agree on the player.level.name fix, but adding another bracket around it was just stupid.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 08-22-2008, 11:14 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by xXziroXx View Post
I agree on the player.level.name fix, but adding another bracket around it was just stupid.
It wasn't stupid, adding a parentheses around the entire expression was the pointless part.

This will work just find:

PHP Code:
 setlevel2((player.guild == "Convict" && player.level != "era_prison-break.nw") ? "era_present_00-00.nw" "era_prison-break.nw"3030); 
If you did want to keep those parentheses though, you could do something even cooler:

PHP Code:
 setlevel2("era_" @ ((player.guild == "Convict" && player.level != "era_prison-break.nw") ? "present_00-00" "prison-break") @ ".nw"3030); 
The comma operator will automatically parse the whole set of arguments and end whatever expression you put in the first argument of the function unless there is an unbalanced/unclosed parentheses (which should be fixed anyways). You can leave extra parentheses though, it just can be rather difficult (or at least annoying) when dealing with 3+ sets of them nested together.
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 08-22-2008, 08:38 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Holy crap what's wrong with you people.

That script may work but it looks horrible.

PHP Code:
if (player.guild == "Convict" && player.level.name != "era_prison-break.nw") {
  
player.setlevel2("era_present_00-00.nw"3030);

When you script you need to consider that other people will be reading your script in the future. Don't over-complicate things just because you can.
__________________
Reply With Quote
  #6  
Old 08-22-2008, 08:42 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Inverness View Post
PHP Code:
if (player.guild == "Convict" && player.level.name != "era_prison-break.nw") {
  
player.setlevel2("era_present_00-00.nw"3030);
} else 
player.setlevel2("era_prison-break.nw"3030); 
Fixed.


Also, I'm not agreeing with the way he did it, but the thread wasn't made to argue about that.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #7  
Old 08-22-2008, 08:45 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by xXziroXx View Post
Fixed.
PHP Code:
if (player.guild == "Convict" && player.level.name != "era_prison-break.nw") {
  
player.setlevel2("era_present_00-00.nw"3030);
}
else {
  
player.setlevel2("era_prison-break.nw"3030);

Now it's fixed. Mixing styles like you did looks bad too.
Quote:
Originally Posted by xXziroXx View Post
Also, I'm not agreeing with the way he did it, but the thread wasn't made to argue about that.
Doesn't matter why the thread was made. A bad habit (imho) shouldn't be encouraged.
__________________
Reply With Quote
  #8  
Old 08-22-2008, 08:58 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Inverness View Post
Doesn't matter why the thread was made. A bad habit (imho) shouldn't be encouraged.
Ignoring it completely isn't the same as encouraging, which I definitely wasn't doing, as you can see in my first post in the thread.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #9  
Old 08-22-2008, 09:24 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Inverness View Post
Holy crap what's wrong with you people.

That script may work but it looks horrible.

PHP Code:
if (player.guild == "Convict" && player.level.name != "era_prison-break.nw") {
  
player.setlevel2("era_present_00-00.nw"3030);

When you script you need to consider that other people will be reading your script in the future. Don't over-complicate things just because you can.
Wow.
__________________
Do it with a DON!
Reply With Quote
  #10  
Old 08-22-2008, 11:28 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Inverness View Post
Don't over-complicate things just because you can.
It may be over complicated for you, but it looks fine to me.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #11  
Old 08-22-2008, 11:41 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Tigairius View Post
It may be over complicated for you, but it looks fine to me.
I agree. I fail to understand how a common alternative syntax to if statements would be "complicated" to anyone. If they fail to read it correctly then I don't want them touching my code anyways.

I do agree that they should not be used beyond one level of nesting though, because then the same syntax is being used multiple times in one line which can be an eyesore.
Reply With Quote
  #12  
Old 08-23-2008, 12:01 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Inverness View Post
Holy crap what's wrong with you people.

That script may work but it looks horrible.

PHP Code:
if (player.guild == "Convict" && player.level.name != "era_prison-break.nw") {
  
player.setlevel2("era_present_00-00.nw"3030);

When you script you need to consider that other people will be reading your script in the future. Don't over-complicate things just because you can.
He was asking for if he could do it with booleans, as in not an if(){}else{}.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #13  
Old 08-23-2008, 12:24 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Switch View Post
He was asking for if he could do it with booleans, as in not an if(){}else{}.
If you think about it, if statements are just a form of writing booleans. I can understand something==somethingelse?function:anotherfunction, but if else statements are much easier to read.
Reply With Quote
  #14  
Old 08-23-2008, 12:30 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Quote:
Originally Posted by Codein View Post
If you think about it, if statements are just a form of writing booleans. I can understand something==somethingelse?function:anotherfunction, but if else statements are much easier to read.
It's all opinion in the end of it.
Reply With Quote
  #15  
Old 08-23-2008, 12:58 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by TheStan View Post
It's all opinion in the end of it.
And guess which version 95% of all programmers would chose?
__________________
Follow my work on social media post-Graal:Updated august 2025.
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 06:36 AM.


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