Hey everyone. I wanted to recycle a post I made on Reddit earlier and share it with anyone who would find the information useful. This may have been discussed before but for anyone new to Tasker or those looking for some stimuli for new ideas, I thought I'd post it. I am in no way a "Tasker Pro" like I view a lot of you so please be kind if there is an easier way of doing this. It's just something I was able to research and figure out on my own and felt proud of myself haha. So please bring me down gently if you have any critiquing. Anyway, here is a cool, simple, little trick that I use. You can apply it in any way that you want but this is one way in which I use it. It's a good example of how to get random lines of text from a file. In this example I have a task that is launched when I swipe up (Nova Launcher) on my home screen. Originally the task was just a simple SAY action with "How can I help you?" then an Autovoice Recognize action to receive voice commands. It got boring hearing the same response every single time I launched the task so I wanted to add a little "life" to it. Here is what I did. First, create a .txt file on your phone or computer. In the .txt file, each line of text acts as a separate response so make sure to hit enter after each one. Also, since we are having the contents of this spoken, make sure you format the sentence correctly so that it is spoken properly. When you have a few different sounding responses save the file and upload it to your phone (if it's not there already). Next, you will create a new task. The first action will be a Variable Randomize. For the name choose any variable name you want and for the Min and Max vaules set them to the range of lines you have in your .txt file. So, for example, if you have 15 lines in your .txt file the Min=1 and Max=15. Now add a Read Line action. File= "yourtextfile.txt" Line= "Variable Randomize variable"(created in first action) and ToVar= "another variable you make up". By doing this, you have created a variable that contains a random number between 1 and 15. Then you are telling tasker to use that randomized number to select the line in the text file and set that line of text to a variable. The last action, a Say action, uses that variable to speak the line that was selected. When all of this is complete a random response will be spoken each time the task is triggered. I apologize if I am not the best at describing the steps but hopefully this will be useful for some of you and maybe help spark some new ideas on how to implement the concept.
Enter: Swipe Up On Launcher (4)
A1: Variable Randomize [ Name:%random Min:1 Max:13 ]
A2: Read Line [ File:Download/launchresponses.txt Line:%random To Var:%launchresponses ]
A3: Say [ Text:%launchresponses Engine:Voice:com.ivona.tts:eng-AUS Stream:3 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ]
A4: AutoVoice Recognize [ Configuration:No Dialog: true