tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

Weird interaction with `<<type>>` and `<<capture>>` within widgets. #177

Closed ChapelR closed 2 years ago

ChapelR commented 2 years ago

Describe the bug. This is a weird one, so strap in.

Consider the following widgets:

<<widget "works" container>><<nobr>>
  <<set _say to _contents>>
  <<capture _say>>
    <<type 50ms>><<= _say>><</type>>
  <</capture>>
<</nobr>><</widget>>

<<widget "notworking" container>><<nobr>>
  <<capture _contents>>
    <<type 50ms>><<= _contents>><</type>>
  <</capture>>
<</nobr>><</widget>>

<<widget "alsoworks" container>><<nobr>>
  <<capture _contents>>
    <<timed 50ms>><<= _contents>><</timed>>
  <</capture>>
<</nobr>><</widget>>

If you test all of these out, the <<notworking>> widget will print [undefined]. As near as I can tell, this only happens to widget _args and _contents special variables and only with type. Outside widgets or using other variables, <<capture>> and <<type>> work together as expected. Likewise, this issue does not appear to occur with other macros that delay output, as seen with the <<alsoworks>> widget.

To Reproduce:

:: widgets [widget]
<<widget "works" container>><<nobr>>
  <<set _say to _contents>>
  <<capture _say>>
    <<type 50ms>><<= _say>><</type>>
  <</capture>>
<</nobr>><</widget>>

<<widget "notworking" container>><<nobr>>
  <<capture _contents>>
    <<type 50ms>><<= _contents>><</type>>
  <</capture>>
<</nobr>><</widget>>

<<widget "alsoworks" container>><<nobr>>
  <<capture _contents>>
    <<timed 50ms>><<= _contents>><</timed>>
  <</capture>>
<</nobr>><</widget>>
:: Start
<<works>>Hi there yay it's me mario whee!!!!<</works>>

<<notworking>>Hi there yay it's me mario whee!!!!<</notworking>>

<<alsoworks>>Hi there yay it's me mario whee!!!!<</alsoworks>>

Expected behavior. A clear and concise description of what you expected to happen.

Screenshots. If applicable, add screenshots to help explain your problem.

Project details.

Desktop details.

Smartphone/tablet details.

Additional context. Add any other context about the problem here.

tmedwards commented 2 years ago

Duplicate of #138 .

ChapelR commented 2 years ago

my bad

tmedwards commented 2 years ago

No harm, no foul. Better a duplicate issue than not reported at all. 😄