Displaying pre-selected lines of text at random

Hello! I’m a new creator and as such I have a thousand gimmicky silly ideas for faces, but I’m still learning the ropes and am not yet sure what the limits of the creator are, so forgive me if this is a silly question or if I’ve put it in the wrong place.

For the face I’m currently working on, I would like to have a field which, once every twenty seconds, selects a random entry from a list of pre-written sentences and displays it on the watchface. Like a “random fact of the day” sort of thing, except it’s a “random fact of the twenty seconds”. What’s the best way to do this? I can probably figure out how to roll a bounded random number and assign it to a variable, but I don’t know how to go about using that variable to select a sentence, or how/where I can best store the sentences.

In other coding systems I would do this by creating a single .txt file with a sentence on each line, generating a random number, and using it in a command like “display line #(number)”. What would be the closest equivalent for doing this in Facer?

(edit: for clarification, I’m thinking here about a list of several hundred sentences).

3 Likes

Depends a bit, there are multiple options.

You can work with opacity. Each text element can have a time based opacity and adding random values to it. This would need quite some math …

Another option, which is a lot easier, is to display a random text upon wake (wakeRand function). Considering most watches time out into dim mode after 15 seconds or less anyway.

If you need more help, let us know…

6 Likes

wakeRand seems like it would achieve what I want in terms of update frequency, thanks!

How can I connect that number to a list of sentences?

3 Likes

As @tom.vannes suggested, you can create 20 text or image elements and in the opacity set it using wakeRand(min, max) expression.
E.g. $(wakeRand(1,20))==1?100:0$
This would require 20 different layers with the opacity having the == 1 to 20.
$(wakeRand(1,20))==1?100:0$
$(wakeRand(1,20))==2?100:0$
$(wakeRand(1,20))==3?100:0$
And so on…

4 Likes

Ah, sorry, misunderstood what they were saying.

Is creating a large amount of text elements/layers like that (seriously, I’ve got like 200 so far) liable to slow down or crash the editor/watch, or affect battery life? I was also considering putting each sentence in one large image and using the variable to change its Y co-ordinate, in case that was easier to process/more convenient to set up.

3 Likes

I have seen some threads where people have had over 300 layers in a watch.
Text layers will be less intensive than images IMO and you only need the opacity formula.
If you use a single or multiple images, the file size of each image will likely not do you any favours, plus having to put additional formula in X and Y.

Here is facer studio example

5 Likes

This is exactly what I needed, thanks so much!

4 Likes

Welcome to the best Smart Watch Community on the planet :grinning:
As you can see, we’ve lots of friendly/helpful people here.
For what it’s worth, here’s a Face I created a while ago that has certain elements changing every 10 seconds

4 Likes

I think inserting hundreds of layers and changing opacity formula in each individually would not only be very tedious, it would make the browsing trough layers and managing the project terribly annoying (at least my browser starts handling the layers gradually sluggish with 50+ layers).

Why not just put all the conditions in one text field next to each other, leaving the “else part” empty like this:
$(wakeRand(1,400))==1?"first text":$$(wakeRand(1,400))==2?"second text":$$(wakeRand(1,400))==3?"third text":$...$(wakeRand(1,400))==400?"four hundredth text":$
image
It will allow you to stitch the “lines” together automatically in excel or another spreadsheet program, also it will allow you to change the font or size or position of the text at whim later on, which I cant imagine doing after adding half of the intended layers.

5 Likes

Nice one! It definitely has advantages.

2 Likes

@Welcome @drewtmoffatt . In my experience it gets difficult to save a Face if what you have added in images gets near 2MB . I think you can take it to 3 but you must be prepared for it to crash when you try save it to the server . I did a Stop Frame thing with 90 images at 20k per image . Zieneth star has done some Stop Frame stuff with a higher number of images but I do not know what the image sizes was . If you are interested I will find one for you .
Sadly Random Does Not Work it is not possible to trap it . So as you have discovered wakeRand is the only thing that Works .
I have no Idea what the limit might be on the Strategy Peter has Proposed . It is well worth a test .
I am not sure how to get a Spreadsheet to export in One Line .
.
I have looked at your Debut Publication . Well done . The only thing I will say is a Lot of Smartwatch wearers are interested in the battery power reserve . Also many look for the date as a minimum .

3 Likes

I have tested it with 365 conditions in row for a names day calendar and it worked. About the spreadsheet, I only attach hint images on how to do it, it only needs to copy the last row into as many rows as needed, fill the column with texts and the automatic stitching does the rest.
(then copy and paste the value from the last cell, not the formula for stitching).


4 Likes

I think inserting hundreds of layers and changing opacity formula in each individually would not only be very tedious, it would make the browsing trough layers and managing the project terribly annoying

After trying this method last night, it was very tedious, especially when the text needed multiple lines! This method looks a lot more manageable, I’ll give it a go this evening. Thanks!

Is it possible to use line breaks in single text elements, or have multiple fonts/colours in one element? A couple of my sentences need more than one line, or to have one word in bold, and while I can think of some workarounds here it’d be convenient to be able to do the formatting in the same text field.

3 Likes

Thanks for that Peter . I will give that a Go .

Unfortunately no, for each line and each text format variation you would need extra text element…

4 Likes

I have looked at your Debut Publication . Well done . The only thing I will say is a Lot of Smartwatch wearers are interested in the battery power reserve . Also many look for the date as a minimum .

Ahh, thank you! I absolutely considered both of those and more, but decided that my goals were to convey the message and accurately pastiche the Taskmaster style, rather than produce a significantly functional face, and given that it’s already super cramped I decided not to let function compromise form and left it as an expressive piece rather than a useful one. :slight_smile:

3 Likes

Unfortunately no, for each line and each text format variation you would need extra text element…

Dang. If I have wakeRand in two separate fields, do both fields get the same number, or will they roll two different things?

2 Likes

I cant test this right now, but I think they return same number. rather test it before splitting the work :slight_smile:

3 Likes

Yes . You get the same number . It is the number that is trapped on Wake . Peter thanks for the lesson On Spread Sheet Stitching . Amazing . Just have to try remember now .
.
.
$wakeRand(0,6)==0?zero:$$wakeRand(0,6)==1?one:$$wakeRand(0,6)==2?two:$$wakeRand(0,6)==3?three:$$wakeRand(0,6)==4?four:$$wakeRand(0,6)==5?five:$$wakeRand(0,6)==6?six:$

2 Likes

Or just remember where to find it :slight_smile:

2 Likes