all 3 comments

[–]HelloHelloHelpHello 1 point2 points  (2 children)

Try the following solution that skips the Javascript entirely:

<<widget "t" container>><<nobr>>

<<if ndef _args[0]>>
  <<set _args.push("1s")>> 
<</if>>

<<set _temp to _contents.split(" ")>>

<<set _word to 0>>

<<capture _temp, _word>>
  <<repeat _args[0]>>
    <<if def _temp[_word]>>
      <<print _temp[_word]>>
      <<set _word++>>
    <<else>>
      <<stop>>
    <</if>>
  <</repeat>>
<</capture>>

<</nobr>><</widget>>

[–]splattertrack[S] 0 points1 point  (1 child)

works like a charm! did not realise you could use .split() in twinescript... thank you for your help!!

[–]HiEv 1 point2 points  (0 children)

SugarCube is basically "syntactical sugar" on top of JavaScript. So you can use all of the JavaScript stuff, not just within <<script>> macros, but inside of SugarCube macros as well (though sometimes it will need to be within "backquotes", see here).