Newbie question - mulitple booleans in "IF"

Bluevoss
Playing with code. There are Booleans to tell you if you have a "tube" and a "bracket". If you have both, you can build a "fitting" (which sets tube and bracket to false and fitting to true). I've looked all over, even the source code, and am stumped how to do this. Ideas?

[[hall]]:
{if tube: You have a tube}
{if bracket: You have a bracket}
{if fitting: You have a fitting}

{if tube: [examine tube]}
{if bracket: [examine bracket]}
{if tube and bracket:[[make fitting]]} <<this ain't right!

Thanks in advance!

TyCamden
This is the only way I know how to handle it. I am fairly new as well:

@start start

[[start]]:
set("tube",1)
set("bracket",1)
set("fitting",0)

[[begin]]

[[begin]]:

{if tube=1: You have a tube}

{if bracket=1: You have a bracket}

{if fitting=1: You have a fitting}

{if tube=1: [examine tube]}

{if bracket=1: [examine bracket]}

{if tube=1:{if bracket=1:[[make fitting]]}}

[[leave]]

[examine tube]:

examine tube section

[examine bracket]:

examine bracket section

[[make fitting]]:

set("fitting",1)

set ("tube", get("tube") - 1 );

set ("bracket", get("bracket") - 1 );

You have created a fitting.

[[begin]]

[[leave]]:

You leave

Dennis Carlyle
I came up with this, which may be only part of what you're looking for. You'd have to tinker with it to get a good range of "You have ... but you need..." messages, but at least it shows only what you haven't picked up in the basement. I found trying to do too much with Squiffy's If/Else when it comes to setting / displaying attributes to be very problematic.


@start start

[[start]]:
@set tube = 0
@set bracket = 0
@set fitting = 0

[[ Start it up! ]](Basement)

[[Basement]]:
@clear
There's a lot of stuff here in the basement.
{if tube=0:You see a [tube] here.}
{if bracket=0:There is a [bracket] here.}

A tube and bracket might go together to make a [[fitting]].

[tube]:
@set tube = 1
You pick up the tube. It's about two feet long, and should work as part of a [[fitting]].

[[continue . . .]](Basement)

[bracket]:
@set bracket = 2
You take a sturdy steel bracket. It could form part of a [[fitting]].

[[continue . . .]](Basement)


[[fitting]]:
var Txt = "";
if (get("tube") == 1) {Txt = Txt +"You have a tube.";}
if (get("bracket") == 2) {Txt = Txt +" You have a bracket.";}

if ((get("tube") == 1) && (get("bracket") == 2)) { Txt = Txt + " You have both parts needed, so you now have a fitting."; }

set("Gtxt", Txt);

Tube: {tube}
Bracket: {bracket}

{Gtxt}

[[continue . . .]](Basement)


Bluevoss
TyCam had the trick I was looking for, but both of these examples are going into my how-to file. Using his trick, I could do it with Booleans...

[[start]]:

@set tube
@set bracket
@set not fitting

[[go to main room]]

[[go to main room]]:

{if tube: you have a tube<br>}
{if bracket: you have a bracket<br>}
{if fitting: you have a fitting<br>}
{if tube:{if bracket:[build a fitting](buildit)}}

[[bug out]]

[buildit]:

@set not tube
@set not bracket
@set fitting

You build a fitting out of your tube and bracket.

[[bug out]]:
And we're done.<br>
{if tube: you have a tube<br>}
{if bracket: you have a bracket<br>}
{if fitting: you have a fitting<br>}

=====

This way, I can handle objects as straight Booleans: you have one or you don't. But now I can do nested IFs to get that AND. Thanks to all!

TyCamden
And you taught me how to use Boolean logic. Thanks!

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

Support

Forums