From efb7b314873a8567d09eb41ee507f718cbd10ec2 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 31 Mar 2016 07:06:39 -0700 Subject: [PATCH] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index af0a873f..046d83e2 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,21 @@ fn main() { } ``` +You can also evaluate a script file: + +```Rust +extern crate rhai; +use rhai::Engine; + +fn main() { + let mut engine = Engine::new(); + + if let Ok(result) = engine.eval_file::("hello_world.rhai") { + println!("Answer: {}", result); // prints 42 + } +} +``` + # Working with functions Rhai's scripting engine is very lightweight. It gets its ability from the functions in your program. To call these functions, you need to register them with the scripting engine.