var x=0
var maxwidth=100
var textInput="some kind of text"
var textOutput=""
var word=""
start of layout
repeat tokencount(textInput, " ") times
-- set word to tokenat(textInput, loopindex, " ")
-- add measure(word&" ") to x
-- compare x > maxwidth
-- -- add newline to textOutput
-- -- set x to 0
-- add word&" " to textOutput
The measure function isn't actually in construct. To measure the text it will depend on how you are displaying text.
If using the text object the best you have is the Text.textwidth expression but that is only updated when the object is drawn. But Javascript can be used to measure the text. Basically in javascript create a html canvas with a 2d context, set the font, and then use context.measureText(text).width. The main thing you'll have to deal with is the font sizes will be different so the font size will have to be scaled somehow. I can't find an example where I figured that one out.
With spritefonts it can be easier. It has the spritefont.CharacterWidth(char) expression, but since it only measures a character at a time you'll have to use a loop to add the widths up for the whole word. You can also take advantage of mono spaced spritefonts by calculating the width=len(word)*charwidth.
An alternate way is to use texture atlas of a font and a json of the widths and where to find the letters.
Anyways here is a c3p that does the text wrapping manually with the last idea. The logic would basically be the same for the others. I don't have any examples for the other object types.
dropbox.com/s/67ukw6bak4gvq41/no_dom_text_scroll.c3p
For simple I often I just use the automatic text wrapping used in the text and spritefont objects. Worst case you can just add the newlines yourself to the text you're using if the automatic stuff isn't satisfactory. Those are the only simple solutions I know