Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 02 17:24
    Build #908 passed
  • Sep 02 17:24
    Build #908 passed
  • Sep 02 12:25
    Build #907 passed
  • Sep 02 12:25
    Build #907 passed
  • Aug 19 20:06
    Build #906 passed
  • Aug 19 20:06
    Build #906 passed
  • Aug 19 20:00
    Build #905 passed
  • Aug 19 20:00
    Build #905 passed
  • Jul 28 14:10
    Build #904 passed
  • Jul 28 14:10
    Build #904 passed
  • Jul 08 23:59
    Build #903 passed
  • Jul 08 23:59
    Build #903 passed
  • Jul 08 17:04
    Build #902 passed
  • Jul 08 17:04
    Build #902 passed
  • Jun 18 14:53
    Build #901 passed
  • Jun 18 14:53
    Build #901 passed
  • Jun 09 05:41
  • Jun 09 05:27
    Build #900 passed
  • Jun 09 05:27
    Build #900 passed
  • Jun 09 03:13
    Build #899 passed
Addison Schuhardt
@aschuhardt
Maybe I'm misunderstanding what the add_class utility is supposed to be doing?
var k = Key.KEY_N0 throws this error:
Error: "Error with function dispatch for function 'KEY_N0'" With parameters: (const Function).(string)
What am I missing?
Addison Schuhardt
@aschuhardt
Welp. Figured it out. It adds global(?) constants. This works:
var k = KEY_N0;
in case anyone has the same question
Sam Jeeves
@jeevcat
What's the difference currently between the vs2019 fixes and the develop branches right now? Which is more current?
Vladyslav
@vtronko

chaiscript::exception::global_non_const If t_bv is not a constant object

Does it mean that t_bv should be const-qualified or just that I shouldn't ever modify it?
Moreover,

ChaiScript_Basic& chaiscript::ChaiScript_Basic::add_global_const     (     const Boxed_Value &      t_bv,
        const std::string &      t_name 
    )

it is const& in signature.
I am confused. Can someone elaborate?

Stefan Agartsson
@Zephyrox_twitter
I would like to create some form of code completion in my script editor. Is there a way to get all classes and methods I've registered with chaiscript?
GrahamAsher
@GrahamAsher

I don't understand the distinction between the normal and the static-library versions of ChaiScript. I watched Jason's Intro To ChaiScript video, which showed him compiling normally in Linux, getting a library load error, then correcting the error by compiling using the static-lib constructor argument; but when I try a simple example using the normal version in Windows, it works correctly without the need to create any dynamically loaded library. Here's my sample code, which includes the main chaiscript header and adds no other chaiscript source code files:

include <chaiscript/chaiscript.hpp>

...

auto hello = [](const std::string& aName)->std::string
    {
    return "Hello " + aName;
    };
chaiscript::ChaiScript chai;
chai.add(chaiscript::fun(hello),"hello");
chai.eval("puts(hello(\"Graham\"))");

So I assume there's a difference between the way this library-loading system works under Windows and on other platforms. It would be great to have an explanation.

curtiplas
@curtiplas
So I'm working with a product that utilizes chaiscript (not embeddded within C++); and I'm curious if chaiscript supports any manipulation of strings ( such as a function/method to search a string for a specific char and/or splitting a string into multiple strings)?
vocaviking
@vocaviking
@0xd800 Going by the documentation, t_bv has to be constant! See: chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const, throws if object exists
I haven't checked the internals, but I think constness is required because ChaiScript does some performance optimization on these variables, which it cannot do if you want the value to change during evaluation...
vocaviking
@vocaviking
@curtiplas ChaiScript supports some string functions via the Extras library However, it probably not enough for the average string tasks. You will need to either hook up the STL into ChaiScript, or write your own functions.
alanyangbo
@alanyangbo
Translate chai into c++
zhanglistar
@zhanglistar
hi there
first time to hear chaiscript
do u guys know to use chaiscript ?
compare to lua ?
Rob Loach
@RobLoach
I use ChaiScript. It's slower than Lua, but I find it easier to use and more powerful.
GrahamAsher
@GrahamAsher
ChaiScript is now an integral part of CartoType's data import system. I wrote some brief notes here to help people use it: http://www.cartotype.com/developers/documentation/125-notes-on-chaiscript. And there are some useful links here (in the section Notes on ChaiScript): http://www.cartotype.com/developers/documentation .
小呆
@Smalldy
do I have a shell tool like python or lua that can type some var and print it ?
Rico P
@RicoP
Hi there. I wanted to ask how do I correctly reset the state of chai? I want to execute a script several times and have always clean slate global namespace. I try the following but executing the script twice will raise a exception because x is already declared
static std::string chai_message = "";
static chaiscript::ChaiScript::State default_state;

void ros_print(const std::string &s) { chai_message = s; }

std::string helloWorld(const std::string &t_name) { return "Hello " + t_name + "!"; }

ChaiSystem::ChaiSystem() : chai(nullptr) {}

void ChaiSystem::initialize() {
  chai = new chaiscript::ChaiScript();
  chai->add(chaiscript::fun(&helloWorld), "helloWorld");
  chai->add(chaiscript::fun(&ros_print), "ros_print");
  default_state = chai->get_state();
}

void ChaiSystem::execute() {
  static char script[16 * 1024] = "var x= 1\nros_print(helloWorld(\" Bob \"));";

    try {
      chai->set_state(default_state);

      chai->eval(script);
    } catch (chaiscript::exception::eval_error &ee) {
      chai_message = "Error: " + ee.reason;
      throw;
    } catch (...) {
      chai_message = "Unknown Error: ";
    }
}
chai->set_state(default_state) doesn't seem to reset my global state
I am on version 6.1. revision ac0d7ce. The master branch currently doesnt compile with VS2019
Jean-André Santoni
@kivutar

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)

Jean-André Santoni
@kivutar
Ok, I had to do this.anim := this.anims[this.stance][this.direction] with the reference assignment
Adam Brown
@Wavesonics
I've got a frustrating crash I can't figure out. I have a chai script that loops, accepting input from the user. It uses that input as a script name, to load and run another script, and get a return code back. Some times it's the int return code, and some times it's a string that the user entered in the 2nd script?!
that 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;
    }
}
Adam Brown
@Wavesonics
here's the test script it's loading:
printRaw("Test Program, type something:");

var input = readLine();
print("You entered: " + input);

return 0;
Pat Callahan
@callahanp
hmm.just ran into chaiscript for the first time.
Douglas Tinkham
@dtinkham_gitlab
Just ran across this. If I have a c++ app, for example a Qt gui app, I could have a text control where users write chaiscript code (or opens existing chaiscript files) that calls my C++ functions inside my app. Is this correct?
jhihn
@jhihn
@dtinkham_gitlab , why would you do that when Qt already has a JS engine?
or, PyQt (or PySide2)
Douglas Tinkham
@dtinkham_gitlab
Why? Because I didn't know qt had js or pyqt that would do such things. I'll have a look.
Daniel Brunner
@0xFEEDC0DE64
Hi, I am trying to embed chaiscript in a small microcontroller (ESP32) and I have problems while compiling
I do not have rtti, there is simply not enough space on the flash
Can I use ChaiScript without all the dynamic_casts all over the place?
Ambrase
@Ambrase
Hello, I'm working on an app where users provide a script function that is executed with objects that I get from my infrastructure. Can I limit the execution time of the user's script and its memory consumption? I assume for the memory limit I can override STL in ChaiScript with a custom allocator. But I have no idea about the execution time limit. Is it possible? Thanks
Branimir Malesevic
@penumbra23

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);
Tony
@DigDyn
Is chaiscript dead? -- Seems no new version for 2 1/2 years.
Tony
@DigDyn
Seems even more dead, if my question gets no response in a month.
linweiyang
@linweiyang
Does anyone know how to compile the chai script file to be another file to protect programmers’ code.
Does anyone know how to compile the chai script file to be another file to protect programmers’ code?
Patrick Mulder
@mulderp
hello, i was wondering how to pass a map from chaiscript language to a c++ function
AI-Messiah
@AI-Messiah
How do I pass a Chaiscript vector to and from my C++ classes and functions