Howdy, Stranger!

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

How to make a statement that contains a variable appear only in this circumstance...

edited March 2016 in Help! with 2.0
Sorry if this has been asked before. So I have a non-physical item (sort of like karma) that players get when they click off to the backstory passages.

So, to be clear, I have 1 main passage that contains 3 links. When the reader clicks off to one of the links they gain 1 "karma." Their only option is to go back to the main passage.

I need it to say, "You now have 1 karma" when they return, but I don't want the page to mention anything about karma when they first land on it.

The function I'm using to build up karma is: (Set: $karma += 1)

I've placed that on every "backstory" passage. Each one link back to the main passage.

On the main passage, I am using (if: $getkarma >= 1)[You now have $karma karma]

But that doesn't work further down the line when I have them build up karma again. If they didn't do it the first time, their karma would be zero, so the function won't work as intended.

I guess what I need is a way to keep the count of variable $getkarma so that it builds up throughout the story.

Thanks for any help, and please let me know if I'm not being clear (very possible!)

~Tommy


Edit: Oh, and if anyone knows how to make it so that variable declarations and functions don't take up space on the output page, that would be really appreciated. I'm using Harlow.


Edit 2:

I *think* I've solved it with this bit of logic:

(set: $haskarma to false)
(if: $getkarma > 0)[
(set: $haskarma to true)
]
(if: $haskarma is true)[

**You now have $karma karma.**]

Comments

  • I normally run an entry macro at the top of each page. One of the checks it makes is:
    <<if $entry neq 0>><<print $entry>><<set $entry to 0>><<endif>>
    

    Then you can make the destination for the karma giving link go back to the same page and set $entry to the message you want displayed at the top of the page:
    [[Sommit good|Here][$karma to $karma + 1;$entry to "You now have "+ $karma + karma.<br><br>"]]
    

    Translation to Harlowe left as an exercise for the reader.
Sign In or Register to comment.