pub fn eval_number_expression_instance(instance_index: usize, id: (BehaviorType, usize, usize, String), data: &mut GameData) -> Option<f64> {
    add_target_to_scope(instance_index, data);

    if let Some(ast) = data.ast.get(&id) {
        let r = data.engine.eval_ast_with_scope::<Dynamic>(&mut  data.scopes[instance_index], ast);
        if r.is_ok() {
            let nn = r.unwrap();
            if let Some(n) = nn.as_float().ok() {
                return Some(n);
            }
            if let Some(n) = nn.as_int().ok() {
                return Some(n as f64);
            }
        } else {
            println!("{:?}", r);
        }
    } else {
        if let Some(value) = get_node_value((id.1, id.2, &id.3), data, id.0) {
            let script = replace_target_variables(value.4);
            if let Some(ast) = data.engine.compile_expression_with_scope(&mut  data.scopes[instance_index], script.as_str()).ok() {
                let r = data.engine.eval_ast_with_scope::<Dynamic>(&mut  data.scopes[instance_index], &ast);
                if r.is_ok() {
                    data.ast.insert(id.clone(), ast);
                    let nn = r.unwrap();
                    if let Some(n) = nn.as_float().ok() {
                        return Some(n);
                    }
                    if let Some(n) = nn.as_int().ok() {
                        return Some(n as f64);
                    }
                } else {
                    println!("{:?}", r);
                }
            }
        }
    }

    None
}
/// Evaluates a numerical expression in the given instance.
Evaluates a numerical expression in the given instance.
Evaluates a numerical expression in the given instance .
pub fn eval_number_expression_instance(instance_index: usize, id: (BehaviorType, usize, usize, String), data: &mut GameData) -> Option<f64> {
    add_target_to_scope(instance_index, data);
    if let Some(ast) = data.ast.get(&id) {
        let r = data.engine.eval_ast_with_scope::<Dynamic>(&mut  data.scopes[instance_index], ast);
        if r.is_ok() {
            let nn = r.unwrap();
            if let Some(n) = nn.as_float().ok() {
                return Some(n);
            }
            if let Some(n) = nn.as_int().ok() {
                return Some(n as f64);
            }
        } else {
            println!("{:?}", r);
        }
    } else {
        if let Some(value) = get_node_value((id.1, id.2, &id.3), data, id.0) {
            let script = replace_target_variables(value.4);
            if let Some(ast) = data.engine.compile_expression_with_scope(&mut  data.scopes[instance_index], script.as_str()).ok() {
                let r = data.engine.eval_ast_with_scope::<Dynamic>(&mut  data.scopes[instance_index], &ast);
                if r.is_ok() {
                    data.ast.insert(id.clone(), ast);
                    let nn = r.unwrap();
                    if let Some(n) = nn.as_float().ok() {
                        return Some(n);
                    }
                    if let Some(n) = nn.as_int().ok() {
                        return Some(n as f64);
                    }
                } else {
                    println!("{:?}", r);
                }
            }
        }
    }
    None
}
pub fn eval_number_expression_instance ( instance_index : usize , id : ( BehaviorType , usize , usize , String ) , data : & mut GameData ) -> Option < f64 > { add_target_to_scope ( instance_index , data ) ; if let Some ( ast ) = data . ast . get ( & id ) { let r = data . engine . eval_ast_with_scope :: < Dynamic > ( & mut data . scopes [ instance_index ] , ast ) ; if r . is_ok ( ) { let nn = r . unwrap ( ) ; if let Some ( n ) = nn . as_float ( ) . ok ( ) { return Some ( n ) ; } if let Some ( n ) = nn . as_int ( ) . ok ( ) { return Some ( n as f64 ) ; } } else { println ! ( " " r ) ; } } else { if let Some ( value ) = get_node_value ( ( id . 1 , id . 2 , & id . 3 ) , data , id . 0 ) { let script = replace_target_variables ( value . 4 ) ; if let Some ( ast ) = data . engine . compile_expression_with_scope ( & mut data . scopes [ instance_index ] , script . as_str ( ) ) . ok ( ) { let r = data . engine . eval_ast_with_scope :: < Dynamic > ( & mut data . scopes [ instance_index ] , & ast ) ; if r . is_ok ( ) { data . ast . insert ( id . clone ( ) , ast ) ; let nn = r . unwrap ( ) ; if let Some ( n ) = nn . as_float ( ) . ok ( ) { return Some ( n ) ; } if let Some ( n ) = nn . as_int ( ) . ok ( ) { return Some ( n as f64 ) ; } } else { println ! ( " " r ) ; } } } } None }
Evaluates a numerical expression in the given instance.
Evaluates a numerical expression in the given instance .
instance_index
usize
id
(BehaviorType, usize, usize, String)
data
&mut GameData
instance_index
usize
id
(BehaviorType, usize, usize, String)
data
&mut GameData