Howdy, Stranger!

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

Issue with Items

Hello! I'm creating a game using Harlowe 1.2.3 in Twine 2, and I'm experiencing a bit of difficulty with items.

I'd like for the player to track down some currency before leaving their home, and I'm using an if macro to track whether the player has enough money on them before proceeding. I thought I was using the relevant macro to increase this variable, but it doesn't seem to be working, and I'm not sure if I'm using the accurate code (which is likely as I'm a complete novice). I've also been using the back button to return to different areas, and I've read that serves as a reset, so that might also be a contributing factor.

Thank you for taking the time to read this.

Comments

  • Can we see the code you're using?
  • The story's History system records the current state of all known variables before a passage is shown to the reader.

    The Harlowe Undo link (in the left sidebar) winds the story's history system back one step to display the previous passage, which results in all known variables being reverted back to the state they were before the previous passage was displayed.

    If you want to return to the previous passage while retaining any variable changes done in the current passage then you need to add a link like either of the following to the current passage. (they work in both v1.2.3 and v2.0.0)
    (link: 'Back')[(goto: (history:)'s last)]
    
    (link-goto: "Return", (history:)'s last)
    
  • Thank you for confirmation regarding the Undo function, and apologies for omitting the code!

    I suspect there's likely some errors with my coding (my Internet connection's been a bit unstable so checking I've input the correct code has been tricky)

    To increase the currency variable I used:
    (set: $(currencyname) to $(currencyname) + 5)
    

    And as for the if/else statements:
    (if: $(currency) is > 10)[Player can progresss. [[link to next passage]]]
    (else:)[Player cannot progress.]
    

    Any corrections would be most welcome.
  • edited April 2017
    1. You really shouldn't use non-alphabet characters immediately after the sigil ($) in variable names. $(currencyname) and $(currency) should probably be $currencyname and $currency. I'm not sure if harlowe allows parentheses in variable names at all, but it isn't a great practice either way.

    2. In the (if:) macro, you have 'is >', this should just be '>'. Harlowe 2.0.0+ allows the 'is', but it's not a good practice anyway, since 'is' is translated into '===', so your code reads '=== >'. Since you're using harlowe 1.2.3, you'll need to fix this. Remember that 'is' is an operator in harlowe's code, not just some grammar.

    3. You misspelled 'progesss', just FYI.

    4. You are using two different variables here, so keep that in mind. I'm not sure why, or if it's necessary, but just know that the first chunk of code you provided will have no effect on the second because of this.
  • Ah, the parentheses isn't actually part of the in-game code, that was simply a poor choice on my part. The variable names are also the same in-game; apologies, I realise I ought to have the written the names as-is. I'll make sure I'm more accurate in the future. Also, thank you for the heads-up regarding 'is'. It now seems to be working as intended so thank you once again for responding.
  • ...I realise I ought to have the written the names as-is.
    Generally it is a good idea to cut-n-paste the actual code you are having an issue with into your question rather than retyping it, because as you found out the example code can be changed during the re-typing which in turn may add/modify/remove the actual error(s) in it.
Sign In or Register to comment.