Howdy, Stranger!

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

If score is less than or whatever, go to passage is not working

edited January 2016 in Help! with 2.0
This is Harlowe

I've done almost a whole game, based around a singular tree but what you click on (good/bad/indifferent links) changes your overall $score

A score of 70+ should take you to a "light" ending. Less than 30 is a "dark" ending and anything between 31-69 is a "grey" ending.

Unfortunately it's just not working.

This is my code:
(link-reveal:"What would it take to just admit to your demons and let them exorcise you?")[(if: $score is <= 30)[(goto:"dark ending")dark ending](elseif: $score is <= 70)[(goto: "grey ending")grey ending](elseif: $score is <= 200)[(goto: "light ending")light ending]

The link doesn't even work, which is endlessly frustrating to me.

What am I doing wrong, please?


(Bonus question: I've used a stylesheet to make the background black, the text white and the links ((link-reveal:) for example) a grey colour.

But my "<a href="link">thing</a>" links are still dark blue. How do I change the colour of those?)

Comments

  • Cheers,

    I'm not coding in Harlowe but how about something like that:
    (set: $score to 15)
    
    The Score is: $score!
    
    {(if: $score < 30)[[[ What would it take you ...->Dark_Ending]]]
    (if: $score > 31 and $score < 70)[[[You walk between light and shadow ...->Grey_Ending]]]
    (if: $score >= 70)[[[You walk in the light ...->Light_Ending]]]}
    

    The"{" and "}" are there to suppress linebreaks and while (a) my example does what I think you try to do (and in Harlowe, to boot) I also think the "code" is more readable than those layered conditions inside of one link in your not working example.
  • Thank you @Harald_Schuster :3 I did a couple of adjustments to put my gotos back and those ifs work perfectly. Thank you so much!
  • Because only one of the three (if:) macros in Harald_Schuster's example can be true at any one time it would be better to change the 2nd and 3rd ones to use the (else-if:) macro instead. Harlowe currently has an issue correctly parsing three square bracket [[[ in a row (like in the (if:) / markup link combo) so you may need to insert a space character between the first and second square bracket.

    A modified version of Harald_Schuster's example:
    (set: $score to 15)
    
    The Score is: $score!
    
    {(if: $score < 30)[ [[What would it take you ...->Dark_Ending]]]
    (else-if: $score > 31 and $score < 70)[ [[You walk between light and shadow ...->Grey_Ending]]]
    (else-if: $score >= 70)[ [[You walk in the light ...->Light_Ending]]]}
    
  • edited January 2016
    greyelf wrote: »
    Because only one of the three (if:) macros in Harald_Schuster's example can be true at any one time it would be better to change the 2nd and 3rd ones to use the (else-if:) macro instead. Harlowe currently has an issue correctly parsing three square bracket [[[ in a row (like in the (if:) / markup link combo) so you may need to insert a space character between the first and second square bracket.

    A modified version of Harald_Schuster's example:
    (set: $score to 15)
    
    The Score is: $score!
    
    {(if: $score < 30)[ [[What would it take you ...->Dark_Ending]]]
    (else-if: $score > 31 and $score < 70)[ [[You walk between light and shadow ...->Grey_Ending]]]
    (else-if: $score >= 70)[ [[You walk in the light ...->Light_Ending]]]}
    

    Ah, a thing to keep in mind should I ever finish with my current project and try to do one in Harlowe (which has some really appealing aspects, I have to admit).

    I wasn't too sure about what contitional statements would work in front of a hook and which would not, that's why I went with the if, if, if cascade.

    Since you're saying that else-if works (which means it's not just a local test but is aware of the failed test before) ... shouldn't a simple "else" then take care of the final check?
    {(if: $score < 30)[ [[What would it take you ...->Dark_Ending]]]
    (else-if: $score > 31 and $score < 70)[ [[You walk between light and shadow ...->Grey_Ending]]]
    (else: $score >= 70)[ [[You walk in the light ...->Light_Ending]]]}
    
  • Since you're saying that else-if works (which means it's not just a local test but is aware of the failed test before) ... shouldn't a simple "else" then take care of the final check?
    The (else:) macro has no parameter so the $score >= 70 part of your example is invalid and is disregarded, other than that you could replace the (else-if: $score >= 70) in my example with (else:).
  • Since you're saying that else-if works (which means it's not just a local test but is aware of the failed test before) ... shouldn't a simple "else" then take care of the final check?
    That is correct, though you've left the conditional expression in, which you shouldn't.
    <!-- Instead of the following. -->
    (else: $score >= 70)[…]
    
    <!-- Write it this way. -->
    (else:)[…]
    

    Beyond that, the way the conditions are currently written a few score values are unrepresented. The scores 30 and 31 are not given an ending based on the current logic. I'm assuming that it should be something like the following instead:
    {(if: $score < 30)[ [[What would it take you ...->Dark_Ending]]]
    (else-if: $score >= 30 and $score < 70)[ [[You walk between light and shadow ...->Grey_Ending]]]
    (else:)[ [[You walk in the light ...->Light_Ending]]]}
    
  • Sighs --- memo to self: Never try to post unchecked code past 11pm (or make sure you're properly coffeinated)!
Sign In or Register to comment.