[SOLVED] Boolean Questions!

Anonynn
10 Mar 2016, 01:46
So I've been trying to figure out how to tell the game whether the player's character is naked or not and I think I found a solution with Booleans.
First off, I use Chase's Wearable Library and I have the player POV running as script.

On the player.object's attributes I added two...
nakedtop=true
nakedbottom=true

And then on all the clothing I have in the game, I put...
When Worn:
nakedtop=false
nakedbottom=false

...after the character "wears" a shirt or pants, or a complete outfit.

Afterward, I went to the player.object's player.tab and wrote...
{if player.nakedtop=true:You're not wearing any clothes over your chest.}
{if player.nakedbottom=true:You're bottom is naked and exposed.}

But when I went to test it with "x me" the two boolean if's didn't show up. Am I doing something wrong?

XanMag
10 Mar 2016, 02:29
Typical Xan question here, but did you get rid of the old 'look at' attribute in the attributes tab? It'll override anything in the setup tab. I always forget that it's there when I change the players appearance.

Anonynn
10 Mar 2016, 03:27
Oh, yeah the rest of the "x me" works just fine. It's about ...20,000 words long.

The only that doesn't work is the boolean I just inserted.

OH! I figured out what the problem was! It has to be...

{if player.nakedtop=True:}

and so on. The true and false must be capitalized! <3

XanMag
10 Mar 2016, 03:52
Ahhhh! A victim of the syntax!! Been there done that!

Anonynn
10 Mar 2016, 04:00
LOL :) !

HegemonKhan
10 Mar 2016, 20:29
I didn't know true/false has to be capitolized with the text processor commands, as in the normal coding you don't need to capitolize true/false.

-------

also, with booleans, you can shorten it when its the 'true' expression (and also the 'false' expression if you use the 'not' logic operator), I'll explain below.

if (orc.dead = true) { msg ("The orc is dead") }
if (orc.dead = false) { msg ("The orc is alive") }
if (not orc.dead = true) { msg ("The orc is alive") }
if (orc.dead <> true) { msg ("The orc is alive") }
if (not orc.dead = false) { msg ("The orc is dead") }
if (orc.dead <> false) { msg ("The orc is dead") }

when I started learning to code (not actual coding/programming learning which I'm doing now) with quest long ago (~3 yrs ago), I liked having:

if (orc.dead = true)

as this is how I understood booleans, in terms of string matching, see below:

orc.dead = true
if (orc.dead = true)
if (true = true) -> TRUE (t-r-u-e = t-r-u-e) -> msg ("Indeed, the orc is dead")

orc.dead = false
if (orc.dead = true)
if (false = true) -> FALSE (f-a-l-s-e =/= t-r-u-e) -> msg ("um no, the orc is still quite alive")

example of this same "string matching" concept with non-booleans (strings):

color = "red"

if (color = "red")
if ("red" = "red") -> TRUE (r-e-d = r-e-d)

if (color = "blue")
if ("red" = "blue") -> FALSE (r-e-d =/= b-l-u-e)

color = "blue"

if (color = "red")
if ("blue" = "red") -> FALSE (b-l-u-e =/= r-e-d)

if (color = "blue")
if ("blue" = "blue") -> TRUE (b-l-u-e = b-l-u-e)

for strings, you obviously have to have the '=blah', but you shouldn't have the '=true/false' with booleans, as I explain below (which I now understand well, as I'm learning to actually program, be a programmer, though when I started I didn't really understand why all the programmers hated my use of the '=true/false' with booleans)

however, those who knew programming, hated me doing this, as to them (and indeed it is) it is redundant in terms of how the programming works and thus is also an extra unneeding programming operation.

so, it can be shortened to this:

if (orc.dead) // if (true), do ...
and
if (not orc.dead) // if (not true) // if (false), do ...

as you don't need the: '= true', and nor the '=false' if you use the 'not' in front of it

but for me, at least during this early time of before I started to learn programming, it really helped me to understand booleans, by having that '=true/false' unneeded part, despite the cringing of all the programmers here, as it helped make sense to me, and thus when I tred to help and explain booleans to others, I used that '=true/false' as I figured if it helped me to understand booleans, it'd help them too. Though in terms of actual programming, this wasn't a good thing to be teaching them, which is why the programmers hated me doing it and kept correcting me with it.