Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Jason Turner
@lefticus
you need to show us what you're actually trying to execute
Peter Taylor
@emersont1

chai.add( chaiscript::fun<std::string (bool)>( [](bool type) { if (type) { return "x"; } else { return "y"; } }), "function_name");
Except for its to a unique pointer to the engine, not a stack instance. It works with class member functions, but lambdas give the no matching function error
Jason Turner
@lefticus
and then how are you trying to call it? You're getting the error when you call it, not during the add, correct?
oh, I see that's a compile-time error you'r egetting
Peter Taylor
@emersont1
Yeah, i should have explicitly said that
Jason Turner
@lefticus
just do this instead:
chai.add( chaiscript::fun( [](bool type) -> std::string { if (type) { return "x"; } else { return "y"; } }), "function_name");
much cleaner
part of the problem is that you were trying to expose a function returning const char * as a function that returns std::string
Peter Taylor
@emersont1
Okay thanks for your help
maniurobert
@maniurobert1_twitter

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
{
private Rigidbody rb;
private float moveSpeed = 5f;
public float sprintSpeed = 10;
private float currentSpeed;

public global::System.Single MoveSpeed { get => moveSpeed; set => moveSpeed = value; }

void Start()
{
rb = GetComponent<Rigidbody>();
currentSpeed = MoveSpeed;
}

void update()
{
    if (Input.GetKeyDown(KeyCode.LeftShift)) {
        currentSpeed = sprintSpeed;
    }

    if (Input.GetKeyUp(KeyCode.LeftShift)) {
        currentSpeed = MoveSpeed;
    }

    PerformMovement();

void PerformMovement()
if (Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward* currentSpeed * Time.deltaTime);
 } 
if (Input.GetKey(KeyCode.S)) {
transform.Translate(Vector3.back * currentSpeed * Time.deltaTime);
 }

if (Input.GetKey(KeyCode.A)) {
transform.Translate (Vecctor3.left* currentSpeed * Time.deltaTime);
 }

if (Input.Getkey(Keycode.D)) {
transform.Translate (Vector3.right* currentSpeed * Time.deltaTime);
 }

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
{
private Rigidbody rb;
private float moveSpeed = 5f;
public float sprintSpeed = 10;
private float currentSpeed;

public global::System.Single MoveSpeed { get => moveSpeed; set => moveSpeed = value; }

void Start()
{
rb = GetComponent<Rigidbody>();
currentSpeed = MoveSpeed;
}

void update()
{
    if (Input.GetKeyDown(KeyCode.LeftShift)) {
        currentSpeed = sprintSpeed;
    }

    if (Input.GetKeyUp(KeyCode.LeftShift)) {
        currentSpeed = MoveSpeed;
    }

    PerformMovement();

void PerformMovement()
if (Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward* currentSpeed * Time.deltaTime);
 } 
if (Input.GetKey(KeyCode.S)) {
transform.Translate(Vector3.back * currentSpeed * Time.deltaTime);
 }

if (Input.GetKey(KeyCode.A)) {
transform.Translate (Vecctor3.left* currentSpeed * Time.deltaTime);
 }

if (Input.Getkey(Keycode.D)) {
transform.Translate (Vector3.right* currentSpeed * Time.deltaTime);
 }

} Nu stiu dece acceasta comanda nu mere , ma refer ce script e gresit , ma puteti ajuta sa faceti corect scriptu . Daca lai facut corect trimitetimi mail cu scriptu corect la maniurobert4@gmail.com

Jason Turner
@lefticus
@maniurobert1_twitter I'm not sure what programming language this is, or what your question is
Peter Taylor
@emersont1
hi, i don't know if this is an issue with chaiscript, but i'm getting an internal compiler error now
Jason Turner
@lefticus
@emersont1 hard to say, but if you're on the develop that now requires a C++17 compiler, and a pretty recent one
Peter Taylor
@emersont1
i'm on master, and i am using 17, let me double check all the configs
Jason Turner
@lefticus
Yeah that would be surprising to have an ICE there
Peter Taylor
@emersont1
right, it's minGW 8.1.0, it builds on linux. it's on 2e77b9
i'll try checking it out on develop
same issue
Peter Taylor
@emersont1
on MSVC i'm getting a ton of expression did not evaluate to a constant
(that's just on develop) it compiles fine on master
Christian Aguilera
@cristian64_gitlab

Hi everybody,

I spent some time this morning experimenting with ChaiScript, and wrote this basic example:

#include <memory>
#include <string>
#include <unordered_map>

#include <chaiscript/chaiscript.hpp>


class Interface final
{
public:
    void setAttr(const std::string& key, const std::string& value) {
        m_attributes[key] = value;
    }

    const std::string& getAttr(const std::string& key) {
        return m_attributes[key];
    }

private:
    std::unordered_map<std::string, std::string> m_attributes;
};

void execute(Interface& interface, const std::string& script)
{
    chaiscript::ChaiScript chai;

    // Add types.
    chaiscript::ModulePtr m(std::make_unique<chaiscript::Module>());
    chaiscript::utility::add_class<Interface>(*m,
        "Interface",
        {},
        {{chaiscript::fun(&Interface::setAttr), "setAttr"},
         {chaiscript::fun(&Interface::getAttr), "getAttr"}}
    );
    chai.add(m);

    // Bind global variables.
    chai.add(chaiscript::var(&interface), "interface");

    // Parse and run the script.
    chai.eval_file(script);
}

int main(int argc, const char* argv[])
{
    if (argc <= 1) { return -1; }

    Interface interface;
    const std::string script = argv[1];
    execute(interface, script);

    return 0;
}

It surprised me how easy it was to get it working.

So, here is the question. I would like to invoke the execute() function many times, with different Interface objects, but with the same script program. Ideally, I'd like to reuse the same chaiscript::ChaiScript chai instance to avoid parsing/interpreting the program each time. Is this possible at the moment with ChaiScript?

Thanks!

Christian Aguilera
@cristian64_gitlab
I've just learned that eval_file() (or eval(), or the operator()) can be evaluated several times. That is probably the answer to my previous question. A function execute() in ChaiScript can be defined with eval_file(), and then the function can be invoked several times, with different arguments, with chai("execute(interface);");
Peter Taylor
@emersont1
Hi,
On minGW I'm getting an object file too big error with the asm.exe, is there an easy fix for this?
(It doesn't affect MSVC or G++ on Linux)
Jason Turner
@lefticus
Yes, you must compile with at least -O1 on MinGW. It's, as far as I know, a bug in MinGW that has affected ChaiScript for at least 6 years. Also, you need to make sure you compile with threading disabled if you want to use MinGW (again, bugs in MinGW) @emersont1
Matthew Sanetra
@matthewsanetra
Hey guys, Im really confused on how to use this in my C++ project
Jason Turner
@lefticus
That's a really wide open statement. What exactly are you confused about?
Jonathan Gordon
@jdgordon
Hey, I'm using a rather older version (stuck on c++11), is use() expected to work with a folder heirachy? i.e if my script does "use("helpers/a.chai")" and then in helpers/a.chai I do "use("b.chai")", (expecting helpers/b.chai to be loaded).
Using version 5.7.0
Matthew Sanetra
@matthewsanetra
Hasn’t anyone got the latest version working with the Pre-Built library?
Rob Loach
@RobLoach
@jdgordon You'll need to interpret where the files are being loaded from. Relative won't work, unless you override how those functions owrk.
@rust4yy Later versions I find pretty fast, and haven't had a need to load from a pre-built.
Rob Loach
@RobLoach
@cristian64_gitlab Yes, with a wrapper class. Spiced did something similar: https://github.com/ChaiScript/Spiced/tree/master/src
Jason Turner
@lefticus
@rust4yy I don't even know the last time I uploaded a pre-built binary. It's been quite some time
Amos Bird
@amosbird
Hi, how is the performance of chaiscript compared to luajit?
Amos Bird
@amosbird
ChaiScript excels at calling C++ functions, not at math. does it mean chaiscript have no overheads when calling c++ functions or accessing c++ vectors?
Jason Turner
@lefticus
it has very low overhead when calling back into C++. You can get very good performance if you put all of your performance critical work in C++ then call it from ChaiScript. If performance is your 100% main concern you won't be happy with ChaiScript. If you want ease of use & and almost perfect interop with C++ choose ChaiScript. if you want performance and very good interop, choose sol2 for lua
Amos Bird
@amosbird
sol2 and lua still fails to meet my expectation
pavzia
@pavzia
I am brand new to chaiscript and trying to abandon lua, my first hurtle: from a C++ application, how do I load an external chaiscript file and run it ?
Sygmei
@Sygmei
@pavzia Use the eval_file method ?
ozan
@honamlioglu_gitlab
int doSome(const EqualityComparable&) what does & operator at the end of parameter
Za Ra Sa Ha
@Zrasha_gitlab
hahahahahahahahhaah
I just benchmarked Chaiscript, it's super slow
what a piece of garbage
Matt Godbolt
@mattgodbolt
I'd suggest you keep to constructive comments here, @Zrasha_gitlab