Howdy, Stranger!

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

Help with macros "adding" space on text

Hello!

I'm fairly newbie on any kind of languages but I'm trying to make a game on Twine anyway. On a certain passage of my game, a whatsapp conversation take place, so I made a macro to put a "Carolin is typing..." message and, after a while, it would disappear and the actual reply would take place. Everything seems to work so far but it adds a lot of spaces between the first message and the other part of the macro, and I honestly don't know what's doing that.

This is the code:
[ "So you can't call me sleepyhead, can you?"]<answer1|
[ "Oh, alright then."]<answer2|
[ "Why were you so tired?"]<answer3|
[ "Did you dreamt about me?"]<answer4|
[ "Don't answer"]<answer5|

{
(click: ?answer1) [ (replace: ?answer1) ["So you can't call me sleepyhead, can you?"] (replace: ?answer2) [] (replace: ?answer3) [] (replace: ?answer4) [] (replace: ?answer5) []
[//Carolin is typing...//]<ctm|
(live: 5000ms) [
(set: $elapsedtime to (round: time / 100) )
(set: $typingtime to $typingtime - $elapsedtime)
(if: $typingtime < 0) [ (replace: ?ctm)
[ (display: "So you") ]
] ] ]
}
And that's the result: undefined.

Anyone got any ideas? :(

Comments

  • It's because the line breaks between your "answer#" hooks are being displayed. One workaround I've used for that particular issue is to include the line breaks in the hooks. That way, when you replace the hook text with blanks, it eliminates the line breaks as well.

    Something like this:
    [ "So you can't call me sleepyhead, can you?"]<answer1| [
    "Oh, alright then."]<answer2| [
    "Why were you so tired?"]<answer3| [
    "Did you dreamt about me?"]<answer4| [
    "Don't answer"]<answer5|
    Alternately, you could put a hook around the whole choice selection and just replace it with the contents of the selected choice.
    |answers>[[ "So you can't call me sleepyhead, can you?"]<answer1|
    [ "Oh, alright then."]<answer2|
    [ "Why were you so tired?"]<answer3|
    [ "Did you dreamt about me?"]<answer4|
    [ "Don't answer"]<answer5| ]

    {
    (click: ?answer1) [ (replace: ?answers) ["So you can't call me sleepyhead, can you?"]
    [//Carolin is typing...//]<ctm|
    (live: 5000ms) [
    (set: $elapsedtime to (round: time / 100) )
    (set: $typingtime to $typingtime - $elapsedtime)
    (if: $typingtime < 0) [ (replace: ?ctm)
    [ (display: "So you") ]
    ] ] ]
    }
  • A third option is you use the { } markup to remove unwanted line-breaks and white-space:

    {(set: $var to 1)
    This should
    all appear on
    the first line}
    The currently unreleased 1.1.0 version of Harlowe also includes the Twine 1 backslash \ feature, which removes line-breaks if add to the end of a line:

    (set: $var to 1)\
    This should \
    all appear on \
    the first line
  • Guys, thank you so much! I used the second method InspectorCaracal showed and really helped me (I just keep getting the text far to the right, but the huge gap is gone). Now I found another "issue": when I try to keep my "chat" going by showing another passage after a click on a choice, the choice dissapears! I'm almost sure it's because of my "live" and the "display: so you" that it keep getting back. I tried to chance the (if: $typingtime < 0) to (if: $typingtime = 0), but got no luck. Sorry if I'm misusing this space asking too many things but, as I said, I am clueless about programing.
  • The (live: interval) macro will keep occurring every time interval until you tell it to (stop:)

    I suggest you change your example to:

    |question>[[ "So you can't call me sleepyhead, can you?"]<answer1|
    [ "Oh, alright then."]<answer2|
    [ "Why were you so tired?"]<answer3|
    [ "Did you dreamt about me?"]<answer4|
    [ "Don't answer"]<answer5|]

    {
    (click: ?answer1) [
    (replace: ?question) ["So you can't call me sleepyhead, can you?"]
    [//Carolin is typing...//]<ctm|
    (live: 5000ms) [
    (set: $elapsedtime to (round: time / 100) )
    (set: $typingtime to $typingtime - $elapsedtime)
    (if: $typingtime < 0) [
    (replace: ?ctm)[(display: "So you")]
    (stop:)
    ]
    ]]}
    note: I also cleaned up the clearing answers by wrapping them all in a question hook
  • Sorry about my delay but thank you so much guys!! It really helped me a lot, now everything works fine and I learned some really handy tricks with hooks. Thank you again!
Sign In or Register to comment.