Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upExecute single expressions #241
Comments
This comment has been minimized.
This comment has been minimized.
Izzeri
commented
May 30, 2016
|
What I had in mind was something akin to stack based implementations of other scripting languages, where you can execute expressions one at a time. Something like: dyon::execute("let a = 10");
let result = dyon::execute("10 + a");I don't know if this makes sense for Dyon, but it would be really nice for doing stuff like damage formulas, e.g.: pub struct Battler {
pub hp: i32,
pub dmg: i32,
pub def: i32,
}
dyon_obj!{ Battler { hp, dmg, def } }
let hero = Battler { hp: 10, atk: 10, def: 4 }
let enemy = Battler { hp: 5, atk: 3, def: 2 }
dyon::set_var("attacker", hero);
dyon::set_var("defender", enemy);
enemy.hp -= dyon::execute("attacker.atk - defender.def").ok(); |
This comment has been minimized.
This comment has been minimized.
|
I am unsure about the best approach for this. Some lifetime/type checking is required, but this runs currently on whole modules. The run-time is also designed to run whole programs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bvssvni commentedMay 30, 2016
This was requested on reddit https://www.reddit.com/r/rust_gamedev/comments/4lk6la/dyon_gets_adhoc_types/d3owjsq