Hello.
I'm trying to embed some custom js functions and js objects into Skulpt in my javascript application.
For example the way I embedded a function:
Sk.builtins.moveRight = function() { person.xPosition += 1 }
So, when I run a simple script - Sk.importMainWithBody('myScript', false, 'moveRight()', true); - the function moveRight is triggered in js and changes the 'person' position. It works fine.
But I have an issue with injecting a js-object to Skulpt. For instance, the former way is not working and I'm getting error "AttributeError: '<invalid type>' object has no attribute 'moveRight' on line 1"
Sk.builtins.hero = {
moveRight: () => person.xPosition += 1
}
Sk.importMainWithBody('myScript', false, 'hero.moveRight()', true);
Appreciate any help or ideas. Thanks!
BR,
Sergey