[SOLVED] Using an IF to check TWO flags

XanMag
Is there a GUI way to check to see if two flags are set? The intent is to describe an object IF two different things have been done to it. I have a piece of paper that can be 'cut' and 'folded'. Code is below - note the HERE =)

if (GetBoolean(paper, HERE is where I need GUI support OR proper code to check for both flags)) {
msg ("It is a sheet of paper with some writing at the top. There is a crease down the middle and there is a cut in the paper as if someone has folded this paper AND cut it!<br/><br/>Thing you can do with the paper - take, drop, read, fold, and cut.")
}
else if (GetBoolean(paper, "cut")) {
msg ("It is a sheet of paper with some writing at the top. There is a cut in the paper as if someone has used a pair of scissors on it.<br/><br/>Thing you can do with the paper - take, drop, read, fold, and cut.")
}
else if (GetBoolean(paper, "folded")) {
msg ("It is a sheet of paper with some writing at the top. There is a crease down the middle as if it has been folded once.<br/><br/>Thing you can do with the paper - take, drop, read, fold, and cut.")
}
else {
msg ("It is a nice, flat sheet of paper with some writing at the top.<br/><br/>Thing you can do with the paper - take, drop, read, fold, and cut.")
}


If there is no way to do this using the GUI, what is the code I could use to check for both flags? It has something to do with using AND, but I'm not sure.
Or, is there an easier way to do this? This is in my 'objects' room of my tutorial so I want to be as clear as possible with my explanation.

I know I can do combinations of make visible/invisible on other created objects or I could use a series of flags, but I'm going for as simple as possible.

Thanks!

HegemonKhan
I'm not sure of a specific script option, but you can choose the: if [expression] option, to be able to write in the desired code for doing multiple condition checking within a single (if and/or else if) code line.

and this is how you write/code it in (via the GUI~Editor):

// run as script -> add new script -> scripts -> 'if' Script -> if [expression] -> (see below)

GetBoolean (paper, "cut") and GetBoolean (paper, "folded")

// --------------------------------------------------------------------------

// your script(s) for when the paper is cut and folder

// your etc scripts (2 else ifs and optional more else ifs and/or an else)


--------------------

and this is how you write/code it as/in CODE (non-GUI-Editor):

(opening up the file itself with a text software, seeing your full game code, or using the 'code view' button at the menu bar at the top of the screen in the GUI~Editor, showing you the entire game code, not the other button on the add scripts, just showing you the code box for that individual script)

if (GetBoolean (paper, "cut") and GetBoolean (paper, "folded")) {
// script(s)
} else if (GetBoolean (paper, "cut")) {
// script(s)
} else if (GetBoolean (paper, "folded")) {
// script(s)
} else {
// script(s)
}

XanMag
Works like a charm. Thanks!

HegemonKhan
the key to writing it:

each condition, requires the full statement, for examples:

(remember that parenthesis can be used to specify the desired order of operations, just like you use them in math equations to do that)

conditional statement 1: GetBoolean (paper, "cut")
conditional statement 2: GetBoolean (paper, "folded")
conditional statement 3: GetBoolean (paper, "stained")
etc etc etc

then it's just a matter of using the logic operators to connect them in the desired way:

(remember that 'and/or' only compares two conditions, one to its left and one to its right)
and: both conditions must be true, for it to be TRUE
or: at least only one condition must be true, for it to be TRUE
------
not: (negation); true->FALSE, false->TRUE
(remember that 'not' only compares one condition, the condition that is on its right side)

for examples (only a few out of tons of combinations):

if (GetBoolean (paper, "cut") and GetBoolean (paper, "folded")) { /* scripts */ }
f (GetBoolean (paper, "cut") or GetBoolean (paper, "folded")) { /* scripts */ }
if (GetBoolean (paper, "cut") and GetBoolean (paper, "folded") and GetBoolean (paper, "stained")) { /* scripts */ }
if (GetBoolean (paper, "cut") or GetBoolean (paper, "folded") or GetBoolean (paper, "stained")) { /* scripts */ }
if ((GetBoolean (paper, "cut") and GetBoolean (paper, "folded")) or GetBoolean (paper, "stained")) { /* scripts */ }
if (GetBoolean (paper, "cut") and (GetBoolean (paper, "folded") or GetBoolean (paper, "stained"))) { /* scripts */ }
if ((GetBoolean (paper, "cut") or GetBoolean (paper, "folded")) and GetBoolean (paper, "stained")) { /* scripts */ }
if (GetBoolean (paper, "cut") or (GetBoolean (paper, "folded") and GetBoolean (paper, "stained"))) { /* scripts */ }

though, this requires boolean logic knowledge, and can be very confusing if you don't keep it simple, lol:

https://en.wikipedia.org/wiki/Truth_table

all code (booleans, characters/symbols, and numeric values) gets reduced to binary (zeroes and ones), which is logical(imaginary/concept)/software ~ (programming), is matched up (somehow) with circuitry/electricity/currents (real/physical/hardware) which gives us the "magic" of computers' and their software/logic (programming):

https://en.wikipedia.org/wiki/Logic_gate (the 2nd half of my 101 assembly language and computer architecture class deals with this stuff, I'm scared, lol, see the logic gate diagrams below!)

google search (images): logic gate diagrams
( http://www.google.com/search?q=logic+ga ... gbwQYhEUsQ )

ask if got any questions

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

Support

Forums