Using Escoria script functions inside a regular GDScript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexwbc
:warning: Old Version Published before Godot 3 was released.

Basically, what the title states: I like the Escoria framework very much; and also the escoria scripting looks nice. But for some cases is very limiting, and I need to access to both gdscript and escoria scripting for the same object function.
for example the change_scene function; I tried to address directly the function with something like:

get_tree().get_root().get_node("vm").change_scene(["res://where/to/teleport.scn"], null)

but didn’t worked to me

:bust_in_silhouette: Reply From: alexwbc

I’ve found sort of “fix” for this: I hope someone will come with a more elegant way, in meanwhile, for those google’s traveler, here’s how I am doing it actually:

Make a regular escoria item as said here: /chapter: The-Items / Creating Point and Click Games with Escoria

And attach the escoria script, with the stuff you want, in the Event Path. ie:

say “this is the escoria script I want to use in the regular GDScript.”

Now attach the escoria node as child of the node that use your main GDScript… you can name your “slave” escoria node whatever you want, I do call it just “slave”

Whenver in your main GDSscript run a:

get_node(“slave”).activate(“look”, null)

the slave node will perform the escoria escoria script you need (in this example, the player will simply speak). You can also hide the slave node, since we don’t really use it.

:bust_in_silhouette: Reply From: Matthew Valancy

Here’s what I am doing to trigger level changes but this should work for anything?

get the magic controller guy that does everything

var vm = get_tree().get_root().get_node(“vm”)

this is equivalent to a line in a .esc file

var event = [{“name”:“change_scene”, “params”:[scene_file]}]

then launch it just like it was loaded from the .esc file (in this example scene file is a string to the resource)


By putting a break point at run_event inside you can watch examples coming up for different command from .esc scripts.