How does one reseat a variable?


#1

I have a World class that adds a global b2World variable like so:

void World::setup_chai() {
    ....
    context().chaiscript.add_global(var(&World::b2_world), 
                                         "g_box2d_world");
    ....
}

When I’m trying to call World::setup_chai more than once, I obviously get a name_conflict_error exception. Is it possible to just change what "g_box2d_world" is pointing to if the variable already exists?


#2

The develop branch now has a set_global function that will set or reset the global value. I believe it does what you want.

I’m working on tagging a new release, it should be out in a few days.


#3

Thanks. That’s exactly what I wanted.