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
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 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:
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!
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.
Thanks, I'll keep in mind when to use visited() is 1/etc. and when to use hasVisited() from now on.