MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / random_float

Function random_float

aiscript-vm/src/stdlib/random.rs:63–75  ·  view source on GitHub ↗
(
    _state: &mut State<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

61}
62
63fn random_float<'gc>(
64 _state: &mut State<'gc>,
65 args: Vec<Value<'gc>>,
66) -> Result<Value<'gc>, VmError> {
67 if !args.is_empty() {
68 return Err(VmError::RuntimeError("random() takes no arguments".into()));
69 }
70
71 RNG.with(|rng| {
72 let val: f64 = rng.borrow_mut().random();
73 Ok(Value::Number(val))
74 })
75}
76
77fn random_int<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
78 if args.len() != 2 {

Callers

nothing calls this directly

Calls 2

RuntimeErrorClass · 0.85
borrow_mutMethod · 0.45

Tested by

no test coverage detected