Howdy, Stranger!

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

Simple text changing on passage revisit?

I'm hoping a macro already exists for this, it seems like something that would be simple and useful. My game involves revisiting passages, with some text changing on subsequent visits. As a simple example, the player might be surprised by something they see the first time, but the next time the thing would just be described. Currently I'm doing this by setting variables for each instance, but its getting really messy because there's a lot of it in my game.

I'm picturing the syntax something like this:

<<changingtext>>You are surprised to see a cat here!<<second>>That cat's still hanging around.<<third>>The cat meows plaintively.<<final>>You're getting sick of that damn cat.<<endchangingtext>>

The final text would stay consistent for all visits after that.

I'm in Sugarcube, by the way. Thanks for reading!

EDIT: L's <<later>> macro (part of the revision macro set) almost does what I want, except that it doesn't display text on the initial passage visit.

Comments

  • Hi MU,
    I have just started my first game (and this is my first post here  :)  ).  I would be interested to see what replies you get to this question. I have been doing the very same thing as you - using variables and as you say, my code is getting very clunky - not that I would know :)
    Stew.
  • Thinking about this, we could probably use a combination of the <<once>> macro and the <<later>> macro, both in L's set. I'll be testing that later. There might be a better way, though.
  • Is there a reason you don't just use <<if>>, <<elseif>> and <<else>> macros?
  • That's what I'm currently doing. The main reason is I don't want to have to name, initialise set and check all those variables. There's loads of them, and it just feels messy.  :)
  • You don't need variables, you can use the 'visited' function:

    <<if visited(state.active.title) == 1>>You are surprised to see a cat here!\
    <<elseif visited(state.active.title) == 2>>That cat's still hanging around.\
    <<elseif visited(state.active.title) == 3>>The cat meows plaintively.\
    <<else>>You're getting sick of that damn cat.\
    <<endif>>
  • That will do very nicely. Thanks, mth!
  • The SugarCube docs say that if the argument to 'visited' is omitted, it will default to the current passage. So this should work too:

    <<if visited() == 1>>You are surprised to see a cat here!\
    <<elseif visited() == 2>>That cat's still hanging around.\
    <<elseif visited() == 3>>The cat meows plaintively.\
    <<else>>You're getting sick of that damn cat.\
    <<endif>>
  • mth wrote:

    The SugarCube docs say that if the argument to 'visited' is omitted, it will default to the current passage.


    Exactly right.  Unless you need to check another passage, calling visited() with no argument is the way to go.
  • setup::
    <<silently>>
    <<set $cat to [ "You are surprised to see a cat here!", "That cat's still hanging around.","The cat meows plaintively.","You're getting sick of that damn cat."]>>
    <<endsilently>>

    ::cat_msg
    <<set $ix to visited() - 1>><<if $ix gte $cat.length>><<set $ix to $cat.length - 1>>$cat[$ix]

    ::Room
    <<cat_msg>>
    Now you should be able to...
    ::msg
    <<set $arr to Parameter(0)>><<set $ix to visited() - 1>><<if $ix gte $arr.length>><<set $ix to $arr.length - 1>>$arr[$x]

    ::Room
    <<msg $cat>>
    ...but to get it to work with 1.4.1 you need to code:

    [/code]::Room
    <<msg state.history[0].variables.cat>>[/code]
Sign In or Register to comment.