Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I7 : Or Condition Logic (Unvisited Rooms)

1 view
Skip to first unread message

Jeff Nyman

unread,
Dec 29, 2009, 2:15:34 PM12/29/09
to
I basically want a code construct like this:

Every turn during Prologue:
if the protagonist is in the Palace Gate:
if Broad Walk is unvisited or if Flower Walk is unvisited:
...

The idea here is that if either the Broad Walk *or* the Flower Walk
has not been visited when this condition is run, a prompt to the
player will be displayed. If either has been visited, then this prompt
should not display since the player has at least moved around a bit.

However, the code above gives an error about how the condition, as
stated, couldn't be broken down into smaller conditions. What I have
there seems logical to me but I'm clearly missing how to do this in a
way that isn't programmatically verbose.

Any ideas?

- Jeff

Victor Gijsbers

unread,
Dec 29, 2009, 2:24:24 PM12/29/09
to

It's very simple: you have written one "if" too many. :) Just take out
the "if" before "Flower Walk" and everything will work.

Regards,
Victor

Jeff Nyman

unread,
Dec 29, 2009, 2:42:03 PM12/29/09
to
On Dec 29, 1:24 pm, Victor Gijsbers <vic...@lilith.gotdns.org> wrote:
> It's very simple: you have written one "if" too many. :) Just take out
> the "if" before "Flower Walk" and everything will work.
>

Thanks, Victor. I did try that originally. The problem is that if I
remove the second "if", while it does compile, the condition actually
isn't checked. Meaning, the my response text will print *even if* the
Broad Walk or Flower Walk is visited.

If I just leave one condition in, the logic works as expected.

So originally I thought that was because it wasn't recognizing the
second clause ("Flower Walk is unvisited") as an if condition, which
is why I put in the second "if" term. I should have indicated that in
my original post.

- Jeff

Victor Gijsbers

unread,
Dec 29, 2009, 3:45:56 PM12/29/09
to
Jeff Nyman wrote:
> On Dec 29, 1:24 pm, Victor Gijsbers <vic...@lilith.gotdns.org> wrote:
>> It's very simple: you have written one "if" too many. :) Just take out
>> the "if" before "Flower Walk" and everything will work.
>>
>
> Thanks, Victor. I did try that originally. The problem is that if I
> remove the second "if", while it does compile, the condition actually
> isn't checked. Meaning, the my response text will print *even if* the
> Broad Walk or Flower Walk is visited.

I'm not sure I understand the problem? The behaviour you describe here
is the expected behaviour: your response text should print even if the
Broad Walk or the Flower Walk is visited, it just shouldn't print when
they are _both_ visited. Thus, this program works as expected:

==============
"Visitation" by Victor Gijsbers

The Church is a room. The player is in The Church.

The Chapel is west of the Church. The Graveyard is east of the Church.

Every turn:
if the Chapel is unvisited or the Graveyard is unvisited:
say "There is still a location you have not visited!".
===============


If you want the description to be printed only when _neither_ of the
locations is visited, you need to write this:


=============
"Visitation" by Victor Gijsbers

The Church is a room. The player is in The Church.

The Chapel is west of the Church. The Graveyard is east of the Church.

Every turn:
if the Chapel is unvisited and the Graveyard is unvisited:
say "There are still two locations you have not visited!".
==============

Notice the "and" instead of "or" in the second program. Both programs
work for me.

Kind regards,
Victor

Jeff Nyman

unread,
Dec 29, 2009, 3:57:25 PM12/29/09
to
On Dec 29, 2:45 pm, Victor Gijsbers <vic...@lilith.gotdns.org> wrote:

> If you want the description to be printed only when _neither_ of the
> locations is visited, you need to write this:

Correct, indeed, Victor.

I wasn't thinking it through correctly. Basically the idea is that if
neither the Broad Walk nor the Flower Walk have been visited, a "scene
prod" should occur. If one or both has been visited, no such scene
prod should occur.

Thanks for the assist and jump-starting my brain.

- Jeff

0 new messages