add: random()
This commit is contained in:
@@ -63,9 +63,18 @@ launchApp("微信");
|
|||||||
当脚本处于应当停止运行的状态时返回true, 否则返回false。
|
当脚本处于应当停止运行的状态时返回true, 否则返回false。
|
||||||
由于脚本引擎的关系,有时即使强制停止正在运行的脚本也不会生效,此时会出现isStopped()为true但脚本仍在运行的情况。
|
由于脚本引擎的关系,有时即使强制停止正在运行的脚本也不会生效,此时会出现isStopped()为true但脚本仍在运行的情况。
|
||||||
|
|
||||||
### notStopped()
|
### isRunning()
|
||||||
当脚本处于应当停止运行的状态时返回false, 否则返回false。
|
当脚本处于正在运行的状态时返回true, 否则返回false。
|
||||||
|
|
||||||
### stop()
|
### exit()
|
||||||
立即停止脚本运行。
|
立即停止脚本运行。
|
||||||
|
|
||||||
|
### random(min, max)
|
||||||
|
* min \<Number\> 随机数产生的区间下界
|
||||||
|
* max \<Number\> 随机数产生的区间上界
|
||||||
|
|
||||||
|
返回一个在\[min...max\]之间的随机数。例如random(0, 2)可能产生0, 1, 2.
|
||||||
|
|
||||||
|
### random()
|
||||||
|
|
||||||
|
返回在[0, 1)的随机浮点数。
|
||||||
@@ -19,6 +19,8 @@ module.exports = function(__runtime__, scope){
|
|||||||
return !isStopped();
|
return !isStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope.isRunning = scope.notStopped;
|
||||||
|
|
||||||
scope.exit = function(){
|
scope.exit = function(){
|
||||||
__runtime__.exit();
|
__runtime__.exit();
|
||||||
}
|
}
|
||||||
@@ -55,5 +57,12 @@ module.exports = function(__runtime__, scope){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope.random = function(min, max){
|
||||||
|
if(arguments.length == 0){
|
||||||
|
return Math.random();
|
||||||
|
}
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
scope.setScreenMetrics = __runtime__.setScreenMetrics.bind(__runtime__);
|
scope.setScreenMetrics = __runtime__.setScreenMetrics.bind(__runtime__);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user