Page 1 of 1

advice on how to do something in Inform 7

PostPosted: Sat, 12Mar03 05:11
by lamont Sanford
First off a quick bit of backstory. I have been working on something for awhile and began running into compiling errors due to the amount of figures used, the bug report is filed. Anyway I decided to break the project up into 2 pieces. The game takes place over the course of a week beginning on monday and ending on friday. I broke part 1 up from mon- weds night and part 2 picking up on thurs morning. Ok now the problem is that actions you do or do not do during the earlier days directly or indirectly affect how things play out later so to carry settings over to the second part I decided to spit out a few passwords at the end of part 1 that you will then enter at the start of part 2 and these will carry settings over. The one problem I couldnt figure how to do is to bring the amount of money you have on you across but I will fudge my way through with that,

NOW, here is the problem I am now trying to do this but im not sure how, This is what I have at the moment.

Code: Select all
pregame is a scene.
pregame begins when play begins.

starting location is a room.

when play begins:
   now the player is in starting location.

when play begins:
   say "[paragraph break][paragraph break]Please enter the words listed at the end of (games name) below."

When play begins:
   change the command prompt to "Please enter first word > "
   
   
First Password is an indexed text that varies. Second Password is an indexed text that varies.  Third Password is an indexed text that varies. Fourth Password is an indexed text that varies. Fifth Password is an indexed text that varies.



To decide whether collecting First Password:
   if the command prompt is "Please enter first word > ", yes;
   no.

To decide whether collecting Second Password:
   if the command prompt is "Please enter second word > ", yes;
   no.

To decide whether collecting Third Password:
   if the command prompt is "Please enter third word > ", yes;
   no.

To decide whether collecting Fourth Password:
   if the command prompt is "Please enter fourth word > ", yes;
   no.

To decide whether collecting Fifth Password:
   if the command prompt is "Please enter fifth word > ", yes;
   no.




After reading a command when collecting first password:
   if the the player's command is "monkey":
      say "[paragraph break] Thank you.";
   change the command prompt to "Please enter second word";
   (here I would make changes that the entered password would cause).


so if theres 5 passwords and about 5 choices for each of the passwords how would I actually code that out?

Thanks alot

Re: advice on how to do something in Inform 7

PostPosted: Sat, 12Mar03 06:57
by Squeeky
Are you allowed a programming structure like that below?
Javascript for instance allows an "IF" structure using the keywords SWITCH and CASE.

Basically the structure is:
myVariable = "xxxxxxx"
switch (myVariable)
case "babe":
some form of action;
break;
case "bed":
some form of action;
break;
default:
action might be "try again".

I'm not going to try to be more precise as inform may not allow whatever I might propose (that said, I've use that structure previously but not under Javascript in a BASIC context quite some years ago). I suggest that you use "select case" or "switch" in a search engine. If javascript does in fact apply add that into the search.

Note my advice is that of a very low level amateur! :crazy:

Re: advice on how to do something in Inform 7

PostPosted: Sat, 12Mar03 08:16
by bosbrand
I found the following example:

if X is:

-- 1: say "A switch statement masquerades as an if statement. 'Unless' cannot be used.";
-- 2: say "Python style only.";
-- otherwise: say "There is no fall-through between cases, and no goto to restore it.";

in this Inform 7 tutorial.

Re: advice on how to do something in Inform 7

PostPosted: Sat, 12Mar03 21:41
by lamont Sanford
Thanks for the replies. Looks like I was 1 word off. changing

> After reading a command when collecting first password:
> if the the player's command is "monkey":

to

> After reading a command when collecting first password:
> if the the player's command matches "monkey":

does the trick.