by

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
  1. There's the docs that need to be updated, like the cheatsheet and perhaps some architecture doc
  2. ChaiScript 6.0 has an optimization framework that starts with the AST and optimizes it at parse time. It is almost limitless for possibilities for transformations and optimizations that can be performed
Germán Méndez Bravo
@Kronuz
Trying to update to my project to use c++1z and it's complaining about something I just can't figure out: https://ghostbin.com/paste/vh5os any idea?
(Chaiscript 6.0)
Chris Kaminski
@ckaminski
My understanding is that 6.0 is not 1z/17 compatible.
Switch to the develop branch.
Germán Méndez Bravo
@Kronuz
oh, that must be it then
let me try
Germán Méndez Bravo
@Kronuz
There's a bunch of new things in c++17
Germán Méndez Bravo
@Kronuz
@ckaminski that did work (using development branch) thank you! :)
Jason Turner
@lefticus
I really really need to tag a release for 6.1 to get all of the improvements out to everyone
Chris Kaminski
@ckaminski
Pretty please.
Jason Turner
@lefticus
My work and travel schedule has not given me much time for ChaiScript lately, but I can probably do something in the next week or two to wrap up a release
Peter Repukat
@Alia5
is there some inbuilt method for checking types of derived classes?
something along the lines of
if (Derived* derived = dynamic_cast<Derived*>(base))
Peter Repukat
@Alia5

nevermind...

something different though, are namespaces removed in v6.0.0?
I can still find it in the cheatsheet...

Jason Turner
@lefticus
they were added after 6.0
jhihn
@jhihn
Hey Jason, you're a really smart guy. I thought I knew C++ until I saw your videos. I was wondering though, have you ever thought about an automated tool to scan C++ code and "optimize" it? There's so much optional decorator stuff that could be applied automatically I think, like const, noexcept, references, etc. It would output full properly decorated code. Or is there something like this already? It's kinda like a linter but not.
Jason Turner
@lefticus
cppcheck will get you close. Nothing right now will tell you when something could/should be noexcept tho
and I don't know how hard it would be to write something that could detect that
jhihn
@jhihn
Well, I think you'd "just" have to scan all the things and know which ones throw exceptions, then back it up the hierarchy.
Thanks, I'll check cppcheck.
One annoyance I just discovered, because I work in multiple languages any given day, is the C++14 initializer syntax. Where JS uses var z = {} c++ is int z {6}. Not being able to use an '=' between the name and the value bugs me. And then there's "int x(6)" which would also be shared.
they look so close.
Jason Turner
@lefticus
jhihn
@jhihn
Hey yeah, I saw that in your videos. It's pretty amazing stuff.
Ooh I see what you mean. Was on mobile. Had to zoom in.
Jason Turner
@lefticus
it's not common usage, but it works the same way, as far as I can tell anyhow
Germán Méndez Bravo
@Kronuz
I'm having an issue using chaiscript since I started using string_view... I have a custom object which has operator[] receiving a string_view, and I configured a chaiscript class for that object in which I also added the operator "[]" to t_funcs
the issue is I'm getting an error when I run my script, saying it "Can not find appropriate array lookup operator '[]'. With parameters: (MyObject, const string)"
ans sure there isn't, as I declared (MyObject, string_view), but not the other one... now, in MyObject I can't declare both const std::string& and std::string_view, as it would result in ambiguities
how should I go about fixing this?
Germán Méndez Bravo
@Kronuz
got it! I just added a conversion from string to string_view
(sounds so obvious) :P
Stefan Agartsson
@Zephyrox_twitter
Guys I'm totally lost in ampersands, static casts, shared pointers and too much coffee! How can I add this method to Chaiscript:
template <typename T, typename... Args> std::shared_ptr<T> CreateComponent(Args... args)
It exists in Entity class
This is what I have come up with, but it doesn't work: chai->add(chaiscript::fun(static_cast<std::shared_ptr<DummyComponent1> (Entity::*) ()>(&Entity::CreateComponent<DummyComponent1>)), "CreateDummy1");
Stefan Agartsson
@Zephyrox_twitter
Never mind I'm an idiot, we shall never speak of this again!
Peter Taylor
@emersont1
hi, i'm not sure what i'm doing wrong but when i try to add a function that is a lambda i get a error: no matching function for call to ‘fun<std::__cxx11::string(bool)>( ... ::<lambda(bool)>) would me having the scripting engine as a unique_ptr cause this?
Peter Taylor
@emersont1
just from the cheatsheet example
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);
 }

}