Applescript help

Joined
Sep 20, 2011
Messages
1
Reaction score
0
Points
1
I'm trying to get into programming and I figured what a better place to start than applescript? So I started with some basics and then decided that I would try my hand at a text based exploration game as a learning experience.

I've been using this format for coding the game:

set answer1 to text returned of (display dialog "" default answer "")
if answer1 contains "" then set answer2 to text returned of (display dialog "" default answer "")

the problem I have is that in order for a player to control where they go in the game, they use compass directions. This becomes an issue when going more than one step away from the origin because I have to start doing this:

if answer1 contains "" and answer2 contains "" then set answer3 to text returned of (display dialog "" default answer "")

in order to make the world fully explorable I have to code for every single direction they can take and at three moves away from the origin I gave up counting the possibilities I would have to code because they were over 150. This left me with two pages of code for only three moves away.

If I'm going to expand the game any further I need a way to get rid of all the if answerX contains and answerY contains and answerZ contains...

Is there anyway to consolidate all that into something simple? I really can't come up with new variables for answers everytime the player moves?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top