Using Harlowe to display automatic text presentations

Twine Version: 2.9.0.0 [ Harlowe: 3.3.9 ]

Last year a wrote a script in Windows using AutoHotkey that took a list of text items and created a decent PowerPoint type text presentation. Users could adjust text style, color, transition and delay on a line by line basis.

I was wondering if the same could be done in Harlowe. Below is some sample text in an array called $item. Colors are set with code like , . Two larger text sizes are available using and . There are a few text styles and transitions as well. You can see those and add other ones via more else-if: statements.

Now, instead of creating a Windows program then saving its output to a GIF file, Twine can simply display the same result in any web browser. Hopefully some of you may benefit from this.

<!-- presentation title -->
###Looking Ahead
{
<!-- create empty hook called tText as a placeholder for the presentation -->
|tText>[ ]

<!-- create array of text items that make up the presentation -->
(set: $item to (a: 
"<cyan><dissolve>Looking ahead,",
"<cyan>what do you see?",
" ",
"<purple><dissolve><expand>Peace and prosperity,",
"<purple>chaos and strife,",
"<purple>people starting out,",
"<purple>couples marrying,",
"<purple>others retiring.",
" ",
"<red><dissolve><tall>We either see",
"<red>what we want to see",
"<red>or reality as it is.",
" ",
"<replace><green><dissolve>Actually, few see reality,",
"<green>as it is obscured",
"<green>by the news,",
"<green>social media,",
"<green>movies and music.",
" ",
"<orange><onepoint25><slide-right>This world is headed",
"<orange><onepoint25><fade-up>in a very specific direction.",
"<orange><onepoint25><fade-up>Keep watching and praying",
"<orange><onepoint50><fade-up><u>so you stay on the right path.</u>"
))

<!-- start of live loop to read through the text above -->
(set: _numItems to $item's length)
(set: _currentItem to 0)

<!-- default set to 2s or 2 seconds -->
(live: 2s)[
(set: _currentItem to it + 1)

<!-- exit loop if no more items -->
(if: _currentItem > _numItems)[(stop:)<br>[[Contents]]]
(else:)[
  <!-- get next text item -->
  (set: _t to $item's (_currentItem))
  
  <!-- set optional color  -->
  (if: _t contains "<red>")[(set: $color to "red")]
  (else-if: _t contains "<yellow>")[(set: $color to "yellow")]
  (else-if: _t contains "<green>")[(set: $color to "green")]
  (else-if: _t contains "<cyan>")[(set: $color to "cyan")]
  (else-if: _t contains "<blue>")[(set: $color to "blue")]
  (else-if: _t contains "<purple>")[(set: $color to "purple")]
  (else-if: _t contains "<orange>")[(set: $color to "orange")]
  (else:)[(set: $color to "white")]

  <!-- set optional size  -->
  (if: _t contains "<onepoint25>")[(set: $size to 1.25)]
  (else-if: _t contains "<onepoint50>")[(set: $size to 1.5)]
  (else:)[(set: $size to 1)]

  <!-- set optional style -->
  (if: _t contains "<tall>")[(set: $style to "tall")]
  (else-if: _t contains "<expand>")[(set: $style to "expand")]
  (else-if: _t contains "<rumble>")[(set: $style to "rumble")]
  (else:)[(set: $style to "none")]
  
  <!-- set optional transition -->
  (if: _t contains "<fade-up>")[(set: $fade to "fade-up")]
  (else-if: _t contains "<fade-down>")[(set: $fade to "fade-down")]
  (else-if: _t contains "<slide-right>")[(set: $fade to "slide-right")]
  (else-if: _t contains "<slide-left>")[(set: $fade to "slide-left")]
  (else-if: _t contains "<dissolve>")[(set: $fade to "dissolve")]
  (else:)[(set: $fade to "instant")]
    
  <!-- use <replace> to clear previous text; otherwise append -->
  (if: _t contains "<replace>")[(replace: ?tText)[(text-style: $style)+(t8n: $fade)+(text-color:$color)+(text-size: $size)[_t]<br>]]
(else:)[(append: ?tText)[(text-style: $style)+(t8n: $fade)+(text-color:$color)+(text-size: $size)[_t]<br>]]]
  ]
}