Howdy, Stranger!

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

macro not working as intended

edited August 2016 in Help! with 2.0
Hey all.

I'm trying to create a passage where it shows a sentence the first time, and on the second and following visits, it shows a different sentence. I tried using L's <<once>> + <<becomes>> macro

like so:


<<once>>"OK, well in that case, I'll see you later then.<<becomes>>"Oh come on! You've already come in here <<print visited("watermill")>> times just to loaf around. It'd be nice if I could get some help for once..."<<endonce>>

However there seems to be a problem where it will show the first sentence on the first visit (good), then the "becomes" sentence on the second visit (good), but on the 3rd and subsequent visits, show nothing (bad).

Is there something I'm doing wrong? I just want the "becomes" sentence to be the final sentence that shows on all visits after the 1st.

Thanks in advance.

Comments

  • As far as I know, what you're describing is exactly how <<once>> is supposed to work.

    That said, I'm unclear as to why you're even using <<once>> in the first place. What you want to do is easily doable without it. For example:
    <<if not hasVisited(passage())>>"OK, well in that case, I'll see you later then.\
    <<else>>"Oh come on! You've already come in here <<print visited("watermill")>> times just to loaf around. It'd be nice if I could get some help for once..."<</if>>
    
    If the passage containing this is the "watermill" passage, which it sounds like from the text, then you can simply the <<print>> a bit since visited() uses the name of the current passage by default if one isn't specified. For example:
    <<if not hasVisited(passage())>>"OK, well in that case, I'll see you later then.\
    <<else>>"Oh come on! You've already come in here <<print visited()>> times just to loaf around. It'd be nice if I could get some help for once..."<</if>>
    
  • Hi TheMadExile,

    Thanks for the reply: I forgot to mention I was using Twine 2, Sugarcube 2 format. The code there does not seem to work.

    However I did find a work around: <<if visited("passage") is 1>>\
    "OK, well in that case, I'll see you later then."
    <<else>>"Oh come on! You've already come in here <<print visited("passage")>> times just to loaf around. It'd be nice if I could get some help for once..."
    <<endif>>\

    seems to work, because 1 would be the first visit and all other visits will eq a value higher than 1.

    I'll be more careful with the <<once>> macro from now on.

    Thanks again!
  • You tagged the thread with "sugarcube 2", so I was aware of the basic story format, if not the specific version. I did assume you were using the latest, which is v2.7.0—important because it's the version in which hasVisited() debuted.

    I didn't spend enough brain cells on this earlier. If the passage you're testing is the current passage, then you do indeed need to use something like visited(…) is 1 as hasVisited() would always return true. On the other hand, if the tested passage is not the current passage, then it really is more efficient to use hasVisited(), since it potentially does a lot less work.
  • Ah, I was unaware that sugarcube 2 had been updated again since my download. I was using 2.6.2, so no wonder it didn't work.

    Thanks, I'll keep in mind when to use visited() is 1/etc. and when to use hasVisited() from now on.
Sign In or Register to comment.