Random Custom Text Variable

340 views
Skip to first unread message

Jay M

unread,
Jul 31, 2013, 3:48:52 PM7/31/13
to tas...@googlegroups.com
Im making a simple app and i have a Scene which has a button and a text box in the text box is a Random number from 1 to 20 (The numbers on a dartboard except the bullseye) when I press the button the Number changes to another random number, This works great But now I need to do exactly the same thing but instead of using numbers I need to use text

I need it to pick randomly from these. Single,Double, Triple. But I can't enter text into the input
field anyone no how I can do this or if it can even be done. Cheers.

The idea is I want the app to give me a random number to hit but also tell me to hit either a triple a double or a single

Wes Stacey

unread,
Jul 31, 2013, 3:52:06 PM7/31/13
to tas...@googlegroups.com
Are you trying to enter text into a "text element" or a "text input Element"?

Jay M

unread,
Jul 31, 2013, 4:17:31 PM7/31/13
to tas...@googlegroups.com

Neither, I was trying to enter it in to the screen on variable Randomize.

I have this

New Task.

Variable Randomize

Name= %RANDOMNUMBER

min = 1
Max = 20

Then I just added a button to my scene and added that task to the button so it runs on tap. Then I added a Text Element which I wrote in %RANDOMNUMBER. So everytime I pressed the button the number updates to a new random number.

I don't no were to begin with the Random Text Variable tho, I tried writing it into variable Randomize but new it wouldn't work because it only accepts numbers.

I'm trying to create a text element that randomly cycles through the words Single, Double,Triple whenever I press the button. Hope that makes sense.cheers.

Jay M

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Wes Stacey

unread,
Jul 31, 2013, 4:21:48 PM7/31/13
to tas...@googlegroups.com, jaymen...@googlemail.com
hmmmm single, double, triple....sounds to me like that matches up pretty well with 1, 2, 3. you can randomize on 1,2,3 in a local variable say %randomize_num and then do a series of if statements to change it over to single, double, triple based on the number returned.

Jay M

unread,
Jul 31, 2013, 4:22:19 PM7/31/13
to tas...@googlegroups.com

That's my Scene the empty Text Element on the bottom is were I want it to Randomly say Single, Double, Triple.Hopefully now it makes more sense

Jay M

IMG_20130731_212016.jpg

Wes Stacey

unread,
Jul 31, 2013, 4:23:23 PM7/31/13
to tas...@googlegroups.com, jaymen...@googlemail.com
see my reply above.

Jay M

unread,
Jul 31, 2013, 4:25:48 PM7/31/13
to Wes Stacey, tas...@googlegroups.com

Great idea that should work cheers.

Jay M

Rob Rogers

unread,
Jul 31, 2013, 4:28:04 PM7/31/13
to tas...@googlegroups.com

Try an array... Here's a stand alone task I just wrote, but you should be able to integrate something similar into your scene.

Dart Zone (105)
A1: Array Push [ Name:%Zone Position:1 Value:single Fill Spaces:Off ]
A2: Array Push [ Name:%Zone Position:2 Value:double Fill Spaces:Off ]
A3: Array Push [ Name:%Zone Position:3 Value:triple Fill Spaces:Off ]
A4: Variable Randomize [ Name:%z_pos Min:1 Max:3 ]
A5: Flash [ Text:%Zone(%z_pos) Long:Off ]
A4

Jay M

unread,
Jul 31, 2013, 4:44:18 PM7/31/13
to tas...@googlegroups.com

That works great azwell I never used an array before so thanks for exporting that for me it really helps.

Jay M

Bob Hansen

unread,
Jul 31, 2013, 5:19:16 PM7/31/13
to tas...@googlegroups.com
Tasker's array function is quite useful.

There are several ways to create an array. For your array where you are defining a set of words and want to pick one based on the position in the array, the follow actions are the most efficient as in it takes the least effort on your part.

A1: Variable Set MyArray To: Single Double Triple
A2: Variable Split MyArray 

The above will create the array. Tasker's Variable Split action will split the original variable and by default it will use a space character as the splitter. If you wanted to create an array of text phrases you could do the smae thing except add a splitter between each phrase like this:

A1: Variable Set MyArray To: Your out!, Your safe, Foul ball
A2: Variable Split MyArray   Splitter: ,

This would create MyArray(1) Your out!   MyArray(2) Your safe   MyArray(3) Foul ball

Jay M

unread,
Jul 31, 2013, 7:13:02 PM7/31/13
to tas...@googlegroups.com

Nice, I think il have to start using arrays there sweeeet.

Jay M

Reply all
Reply to author
Forward
0 new messages