Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Multiple unless statements

Hi! I am making a map. It is one passage that increments or decrements either the x-position or the y-position of the player and then it reloads the passage with the new position. Then there are specific locations that take you to other passages so that the story can go on. I have a nested list containing a 10 by 10 grid and I compare the $posx and $posy values every time the map passage reloads to that list (I'v been a little lazy at certain points where I have just compared the variables to raw numbers).

It works, but I have a slight problem. I need to cut off parts of the map to finish this assignment on time. the way I tried to do it is to use the unless: statement combined with the link: statement. Unless you are at these coordinates, the link "South" will appear, increment your y-value and go-to: the same passage again.

it works at the south edge of the map ( (x, 10) ) and at one specific location; (2,4) but the other ones do not work! what's going on?


this is the statement, $list is the nested list of numbers 1 to 10 and $posx and $posy, the x and y coordinates for the player. brace yourselves:

(unless: $posy is $list's 2nd's last OR $posx is 2 AND $posy is 4 OR $posx is 3 AND $posy is 4 OR $posx is 4 AND $posy is 4 OR $posx is 4 AND $posy is 8 OR $posx is 5 AND $posy is 8 OR $posx is 6 AND $posy is 8 OR $posx is 7 AND $posy is 8 OR $posx is 8 AND $posy is 8 OR $posx is 9 AND $posy is 6)[(link: "South")[(set: $posy to it + 1)(go-to: "Forest map")]]

I know it looks like shit, but at this point I don't care, I just need the particular set of things to work.

Comments

  • You need to state which Story Format you are using when you ask a question, as answers can be different for each one. Based on your example I am going to assume you are using Harlowe.

    Without knowing the exact value of the $list array (so I know what the value of $list's 2nd's last is) I am going to guess your main issue is due to Operator Precedence.

    Because you are not using parenthesis to influence the order your conditions are getting processed in then they will be processed from left-to-right with the AND operator taking precedence over the OR operator, so basically your code look something like the following where each line represents a potentially true statement which will immediately cause the (unless:) to fail.
    (unless: 
    $posy is $list's 2nd's last 
    OR $posx is 2 AND $posy is 4 
    OR $posx is 3 AND $posy is 4 
    OR $posx is 4 AND $posy is 4 
    OR $posx is 4 AND $posy is 8 
    OR $posx is 5 AND $posy is 8 
    OR $posx is 6 AND $posy is 8 
    OR $posx is 7 AND $posy is 8 
    OR $posx is 8 AND $posy is 8 
    OR $posx is 9 AND $posy is 6
    )[
    	(link: "South")[
    		(set: $posy to it + 1)
    		(go-to: "Forest map")
    	]
    ]
    
  • Sorry about not stating what Story Format I was using, but you are correct, it is Harlowe.

    Yes that is exactly how I meant to do it. In any of those coordinates in the Unless - statement, I wanted it to fail so that you could not continue south. But it would only work with $posy == $list's 2nd's last ($posy == 10) and the third row in your example (2,4). At any other of those coordinates, the link "South" would appear.

    I did a workaround which is functional. But it is horrible and nasty. A new array with 2 elements each containing an array. First representing the x-values and the second representing the y-values. Their individual elements are paired up with each other so that 1st's 1st go with 2nd's 1st and so on.

    And then I made this monstrous abomination :
    (if: $posx is $southWall's 1st's 1st AND $posy is $southWall's 2nd's 1st)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 2nd AND $posy is $southWall's 2nd's 2nd)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 3rd AND $posy is $southWall's 2nd's 3rd)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 4th AND $posy is $southWall's 2nd's 4th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 5th AND $posy is $southWall's 2nd's 5th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 6th AND $posy is $southWall's 2nd's 6th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 7th AND $posy is $southWall's 2nd's 7th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 8th AND $posy is $southWall's 2nd's 8th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 9th AND $posy is $southWall's 2nd's 9th)[
    (set: $showSouth to false)](else-if: $posx is $southWall's 1st's 10th AND $posy is $southWall's 2nd's 10th)[
    (set: $showSouth to false)] 
    

    And now, the link "South" only appears when $showSouth is true. (It is set to true in the top of the map passage to make it the default value)

    Thank you for replying!
Sign In or Register to comment.