Skip to content

Calling functions from other scripts #541

@quou

Description

@quou

I'm using ChaiScript for a simple game engine project that I'm working on at the moment. I have a basic scripting system implemented so far, where each entity can have a script attached to it, and each entity gets a separate ChaiScript object. I would like to add a feature so that a script can call a function that is inside another script, example:
In one script I could have:

def someFunction() {
    return 1 + 2;
}

And then in another script I want to be able to do the following (I already have FindEntity set up and working):

// Call someFunction, that is defined in the script attached to "Some Entity"
FindEntity("Some Entity").GetScript().someFunction();

How would this be done, if it is possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions