Prolog check if
- by NickLee
I'm creating a text adventure game on SWI-Prolog and I want to include (some kind of) dialogs.
What I have so far is:
dialog1(1):- nl,write('blah blah'),nl
write('a: this is answer a'),nl,
write('b: this is answer b'),nl.
a:- write('respond to answer a'),nl.
b:- write('respond to answer b'),nl.
That's pretty much the first dialog. Now I want to create a second dialog similar to the first one.
dialog1(2):- nl,write('blah blah'),nl,
write('a: this is answer a'),nl,
write('b: this is answer b'),nl.
a:- write('respond to answer a'),nl.
b:- write('respond to answer b'),nl.
How can I check if the dialog is the first or the second one? I want to do that because when the user types a., I need the right answer a to be shown.
I thought I could use something like
a(1):- write('respond to answer a'),nl.
b(1):- write('respond to answer b'),nl.
/* and on the second dialog*/
a(2):- write('respond to answer a'),nl.
b(2):- write('respond to answer b'),nl.
But still, if the user is on dialog 2 and he types a(1),the first answer will appear.