return script_return_obj (script_obj_new_number (reply_double));
}
-
static script_return_t script_lib_math_double_from_double_double_function (script_state_t *state,
void *user_data)
{
return script_return_obj (script_obj_new_number (reply_double));
}
+static script_return_t script_lib_math_random (script_state_t *state,
+ void *user_data)
+{
+ double reply_double = random() / ((double)RAND_MAX + 1);
+ return script_return_obj (script_obj_new_number (reply_double));
+}
+
static double double_to_int (double value)
{
return (double) (int) value;
double_to_int,
"value",
NULL);
+ script_add_native_function (math_hash,
+ "Random",
+ script_lib_math_random,
+ NULL,
+ NULL);
script_obj_unref (math_hash);
data->script_main_op = script_parse_string (script_lib_math_string, "script-lib-math.script");