Documentation

Una is developed by Una Technologies Limited

All rights reserved

© 2022 Una Technologies Limited

Print

Choosing the Random Value

Pick Random 0 to 10

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"device_random\" disabled=\"true\" x=\"-22\" y=\"652\"><value name=\"min\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">0</field></shadow></value><value name=\"limit\"><shadow type=\"math_number\" disabled=\"true\"><field name=\"NUM\">10</field></shadow></value></block></xml>"}
				
			

This block is used to choose the random number between the range.

Parameters: Condition: Number (Default: 0)

Output: Number

Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"device_random\"><value name=\"min\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value><value name=\"limit\"><shadow type=\"math_number\"><field name=\"NUM\">10</field></shadow></value></block></value></block></statement></block></xml>"}
				
			

The output:

Random - Output
Previous Changing the Number to Absolute Value