Hi, I'm trying to do a double map like this:
this.anims = [
"stand": [
"left": Animation(love.graphics.newImage("assets/bomberman_stand_left.png"), 24, 24, 0.2f),
"right": Animation(love.graphics.newImage("assets/bomberman_stand_right.png"), 24, 24, 0.2f),
"up": Animation(love.graphics.newImage("assets/bomberman_stand_up.png"), 24, 24, 0.2f),
"down": Animation(love.graphics.newImage("assets/bomberman_stand_down.png"), 24, 24, 0.2f)
],
"walk": [
"left": Animation(love.graphics.newImage("assets/bomberman_walk_left.png"), 24, 24, 0.2f),
"right": Animation(love.graphics.newImage("assets/bomberman_walk_right.png"), 24, 24, 0.2f),
"up": Animation(love.graphics.newImage("assets/bomberman_walk_up.png"), 24, 24, 0.2f),
"down": Animation(love.graphics.newImage("assets/bomberman_walk_down.png"), 24, 24, 0.2f)
]
]
this.anim = this.anims[this.stance][this.direction]
But I'm getting this error: Error: "Missing clone or copy constructor for right hand side of equation" With parameters: (Image)
var status
is some times an int, and some times a string, and it should always be an int
run()
is a C++ function that always returns an int, and internally does an eval()
on a script
var running = true;
while(running)
{
printRaw("/");
var line = readLine();
if(line == "exit")
{
running = false;
print("Good bye.");
}
else
{
var status = run(line);
print(status);
if(status == 0)
{
print("Success");
}
else
{
print("Program returned error");
}
}
}
int ChaiOs::run(const string& path)
{
if(fileExists(path))
{
try
{
auto script = loadScript(path);
int r = chai.eval<int>(script);
return r;
}
catch(chaiscript::exception::eval_error& e)
{
cout << "eval_error: " << endl << e.pretty_print();
return 1;
}
catch(chaiscript::exception::bad_boxed_cast& e)
{
cout << "bad_boxed_cast" << endl << e.what();
return 1;
}
}
else
{
cout << "Program not found" << endl;
return 1;
}
}
printRaw("Test Program, type something:");
var input = readLine();
print("You entered: " + input);
return 0;
Hi all!
I have a question regarding the chai embedded interpreter in C++. Is there any kind of environment/isolation/sandbox (milion of names) while doing eval
so that the objects/variables/functions declared inside the script reside only in the environment?
Example would be
auto script = R("
hp = 10";
def attack() { hp -= 5; }
");
chai.eval(script, env1);
chai.eval(script, env2);
chai.eval("attack()", env1);
assert.true(env1["hp"], 5);
assert.true(env2["hp"], 10);
chai.boxed_cast<SomeType>(chai.eval("v"));