Help with upgrading to v6


#1

I was using 5.8.1 as follows:

    std::unique_ptr<chaiscript::ChaiScript> create_chaiscript()
    {
        auto chai = std::unique_ptr<chaiscript::ChaiScript>(new chaiscript::ChaiScript(chaiscript::Std_Lib::library()));
    chai->add(createChaiscriptBindings());
    auto scriptFileName = cocos2d::FileUtils::getInstance()->fullPathForFilename("World1.chai");
    chai->eval_file(scriptFileName);
    
    return chai;
}

   // Get the Chaiscript Engine
    auto chaiscript = CocosChai::create_chaiscript();

   // Get a reference to the function in the script
     auto setupLevel_script = chaiscript->eval<std::function<void (int, WorldLayer*)>>("setUpLevel");
   // Call the function
     setupLevel_script(level, this);

Now I am trying to get this working with v 6 and I get build error “no matching constructor”.

I have seen (and tried to use) a previous answer to a similar question - but my C++ skills just aren’t up to it!

I’d appreciate any help you may be able to offer


#2

If I read your code correctly I think all you need to do is change:

auto chai = std::unique_ptr<chaiscript::ChaiScript>(new chaiscript::ChaiScript(chaiscript::Std_Lib::library()));

to

auto chai = std::unique_ptr<chaiscript::ChaiScript>(new chaiscript::ChaiScript());

And you should be moving forward again (or at least getting a different error :smiley: )


#3

Wow! That was easier than I thought it was going to be!
Thanks so much!

(you’re right about different errors, but they seem to be related to how the script is being interpreted - it looks as if something has changed with the way I"m handling addition of Vec2s - but at least I can run again now!

Thanks again