Is there a way to have an and statement

falconesabc
When doing an if statement, can I have two requirements without nesting the if statement?

HegemonKhan
yes, there's the 'and' and 'or' (and also the 'not' / negation) logic operators, but you got to make sure you're doing the full statement for each condition.

if (player.alias = "HK" or player.alias = "HegemonKhan") {
// NO error

if (player.alias = "HK" or "male") {
// ERROR

example (stupid/lame one... my mind is not creative at the moment, lol):

if (player.alias = "HK" and player.sex = "male") {
msg ("Yep, that's me!")
} else if (player.alias = "HK" and player.sex = "female") {
msg ("Nope, that's someone else, a different HK")
} else if (not player.alias = "HK" and player.sex = "male") {
msg ("That person is not HK, but they're a male.")
} else if (not player.alias = "HK" and player.sex = "female") {
msg ("That person is not HK, but they're a female.")
}


as for how to do this in the GUI~Editor:

I don't know the GUI~Editor's Scripts' [xxx] options that well, but you can choose the 'if' Script's [EXPRESSION] option, allowing you to type/code in what you want, for example (red font is your typed in code):

if [expression] player.alias = "HK" and player.sex = "male"

XanMag
Check out this link. I've compiled some of the most helpful threads I've experienced for my games. These are all really good solutions to some problems and none of them are super complex or too specific. It has a link in there to 'and' and 'or' statements. Hope it's helpful.

viewtopic.php?f=10&t=5835&p=40368&hilit=useful+threads#p40368

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums