2019-01-13 05:16:19 -05:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/module_loader.hpp"
|
|
|
|
#include "game/game.hpp"
|
|
|
|
|
|
|
|
class scripting final : public module
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void post_load() override
|
|
|
|
{
|
2019-01-13 06:07:19 -05:00
|
|
|
this->chai_.add(chaiscript::fun(&function), "function");
|
|
|
|
|
|
|
|
double d = this->chai_.eval<double>("function(3, 4.75);");
|
|
|
|
printf("Result: %f", d);
|
2019-01-13 05:16:19 -05:00
|
|
|
}
|
2019-01-13 06:07:19 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
chaiscript::ChaiScript chai_;
|
|
|
|
|
|
|
|
static double function(int i, double j)
|
|
|
|
{
|
|
|
|
return i * j;
|
|
|
|
}
|
|
|
|
|
2019-01-13 05:16:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_MODULE(scripting)
|