using 'and' ?
NecroDeath
16 Sept 2016, 17:02Is it possible to have two conditionals in an 'If' script? e.g. player has to have object x AND be in room y for a verb to perform an action?
hegemonkhan
16 Sept 2016, 20:58yep (actually as many as you want --- that, quest/computer or you-lol, can handle), quest uses the very user-friendly 'and' and 'or' and 'not', instead of the programming symbols that are often used in/for/with most programming languages (and: &&, or: ||, not: !)
also, make sure you at least have a basic understanding of the truth table (boolean) logic that is involved with 'and', 'or', and 'negation/not' :
https://en.wikipedia.org/wiki/Truth_table (the main three: logical negation: not, logical conjunction: and, logical disjuntion: or)
NOT:
true -> FALSE
false -> TRUE
AND:
false * false -> FALSE
false * true -> FALSE
true * false -> FALSE
true * true -> TRUE
OR:
false + false -> FALSE
false + true -> TRUE
true + false -> TRUE
true + true -> TRUE
the main thing to remember, you need a (full) statement for each condition
(full) statement: NAME_OF_OBJECT.NAME_OF_ATTRIBUTE = VALUE_OR_EXPRESSION
here's some examples:
// statement 1 (condition 1): player.alias = "HK"
// statement 2 (condition 2): player.sex = "male"
if (player.alias = "HK" and player.sex = "male") {
// if ( (player.alias:"HK" = "HK") and (player.sex:"male" = "male") {
// if ( (true) and (true) ) { -> TRUE (run the msg: Yes, that is me.)
msg ("Yes, that is me.")
} else if (player.alias = "HK" and player.sex = "female") {
msg ("That's some other 'HK', as I'm not a girl.")
}
-----------------------------------------------------------
// statement 1 (condition 1): player.alias = "HK"
// statement 2 (condition 2): player.sex = "female"
if (player.alias = "HK" and player.sex = "male") {
// if ( (player.alias:"HK" = "HK") and (player.sex:"female" = "male") {
// if ( (true) and (false) ) { -> FALSE (go to the 'else if' line/step)
msg ("Yes, that is me.")
} else if (player.alias = "HK" and player.sex = "female") {
msg ("That's some other 'HK', as I'm not a girl.")
}
----------------------------------------
if (player.test1.score >= 90 and player.test2.score >= 90) {
player.grade = "A"
} else if (player.test1.score >= 80 and player.test2.score >= 80) {
player.grade = "B"
} else if (player.test1.score >= 70 and player.test2.score >= 70) {
player.grade = "C"
} else if (player.test1.score >= 60 and player.test2.score >= 60) {
player.grade = "D"
} else {
player.grade = "F"
}
--------------------------------------
if (player.sex = "male" or player.sex = "female" or player.sex = "hermaphrodite") {
player.is_sexual_organism = true
msg ("You reproduce via meiosis (faulty/mutational hybridization: "sex")")
} else if (player.sex = "asexual") {
player.is_sexual_organism = false
msg ("You don't reproduce if not an organic organism or you reproduce via mitosis (copying/replicating/duplicating) if an organic organism or as a non-organic machine")
}
also, on top of having multiple conditions, you can also "nest" the 'if' Scripts too (combined with multiple conditions or instead of using multiple conditions):
if (player.alias = "HK") {
if (player.sex = "male") {
msg ("Yes, that is me.")
} else if (player.sex = "female") {
msg ("that's some other HK, as I'm a male.")
}
} else if (player.alias ="human") {
if (player.sex = "male") {
msg ("That is a male human.")
} else if (player.sex = "female") {
msg ("that is a female human.")
}
}
vs (multiple conditions)
if (player.alias = "HK" and player.sex = "male") {
msg ("Yes, that is me.")
} else if (player.alias = "HK" and player.sex = "female") {
msg ("that's some other HK, as I'm a male.")
} else if (player.alias ="human" and player.sex = "male") {
msg ("That is a male human.")
} else if (player.alias ="human" and player.sex = "female") {
msg ("that is a female human.")
}
vs both multiple conditins and "nesting"
if (player.alias = "HK" and player.sex = "male") {
if (player.age_integer >= 18) {
msg ("Yes, that is me, an adult.")
} else if (player.age_integer < 18) {
msg ("that was my younger self, years ago.")
}
} else if (player.alias = "HK" and player.sex = "female") {
if (player.age_integer >= 18) {
msg ("Yes, that is some other HK, as an adult.")
} else if (player.age_integer < 18) {
msg ("that is some other HK, as a minor")
}
}

Alex Warren
16 Sept 2016, 21:02You don't need to write your entire post in a code block HK...
hegemonkhan
16 Sept 2016, 21:12@ Alex:
The reason I often use the code block for my entire post, is because:
I don't know what/what-symbols/etc-whatever works fine outside of the code block, whereas the code block preserves everything for me, saves me time of having to edit more the post (which I already edit a lot anyways, lol) because some symbols aren't working in the normal (non-code block) post, and/or the formatting isn't preserved or gets messed up. It's a pain of having to go back and figure out what isn't showing up and putting it into code block so it does show up, and/or for any messed up formatting, so it's much more convenient/effective to just put everything into the code block, as nothing gets messed up that way. Saves me "maintenence/developer time", as it preserves everything correctly (no maintence/developer time by me is required, aside from writing the post, lol). It's a real pain in figuring out (and worse having to go back and trouble shoot why my post is missing chunks of content and/or my formatting is messed up --- I have a bit difficulty with using multiple code boxes as I forget to open/close them properly and have to trouble shoot / fix up that stuff --- conpared to just using a single code box which I don't mess up the opening/closing of, as it's just one of them), what needs to go into the code box and what doesn't, compared to just putting everything into the code box, and not having any of these hassles at all.
Does the code block cause too much overhead, that it'd help out the site/server for users to not use the code box, if/when they don't have to, as, as much as possible as they can do so without needing to use it, ???
@ Necro Death :
I don't know if it can be done (it probably can be done, lol, as multiple conditions are important) and/or what the script option choice/s are for doing multiple conditions in the GUI~Editor, but if you choose the '[EXPRESSION]' script option choice, it let's you type in the code, allowing you to do multiple conditions.
giving the examples in code is easier for me, so hopefully you can figure out how to do multiple conditions in the GUI~EDitor's script option choices (run as script -> add new script -> choose a script and its script options), but if not, there's using the '[EXPRESSION]' script option choice, as I mentioned above.
NecroDeath
18 Sept 2016, 12:43Thanks so much!