|
|
|
@ -10,6 +10,7 @@ |
|
|
|
|
#include <QInputDialog> |
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <QDateTime> |
|
|
|
|
#include <random> |
|
|
|
|
|
|
|
|
|
using namespace Builtin::Error; |
|
|
|
|
|
|
|
|
@ -208,4 +209,26 @@ ValueHolder subwinname(Script&, std::vector<ValueHolder>& args) |
|
|
|
|
return cwin->getButtonText().toStdString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ValueHolder rand(Script& std, std::vector <ValueHolder>& args) |
|
|
|
|
{ |
|
|
|
|
if (args.size() != 2) |
|
|
|
|
throwInsufficientParameters("rand", args.size(), 4); |
|
|
|
|
|
|
|
|
|
if (args[0].getType() != ValueHolder::Type::Integer) |
|
|
|
|
throwNotANumber("rand", 1); |
|
|
|
|
|
|
|
|
|
if (args[1].getType() != ValueHolder::Type::Integer) |
|
|
|
|
throwNotANumber("rand", 2); |
|
|
|
|
|
|
|
|
|
int lo = ValueExtract(args[0]).toInt(); |
|
|
|
|
int hi = ValueExtract(args[1]).toInt(); |
|
|
|
|
|
|
|
|
|
static std::random_device device; |
|
|
|
|
static std::mt19937 generator(device()); |
|
|
|
|
|
|
|
|
|
std::uniform_int_distribution<int> distribution(lo, hi); |
|
|
|
|
|
|
|
|
|
return ValueHolder(distribution(generator)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|