Forum Discussion
Storyline 360 Advanced JavaScript API
I've been very interested in the potential of JavaScript for a while and was very happy to learn of the JavaScript API. A lot could already be accomplished with only the setVar() and getVar() methods but the recent enhancements, in particular the object IDs, allow for granular control of the elements on the screen.
Possibilities have always existed with animation paths, but now that the update() loop is open and code can more precisely manipulate objects, player-controlled animation can be even smoother. I'd hoped to come back to a platformer I've been working on, but it hit a snag (this was my first attempt at creating a very simple collision engine) so I'll gladly put it to rest here. (WASD/arrows to move.)
Were it finished, touching the secret door would teleport you to an end-game/congrats slide, so please imagine. ✨
I did leverage LLMs for some of this, especially for some high-level debugging, and it was great at explaining best practices like "jump buffers." LLMs have limits with extended conversations though so it was less useful the larger the scope or broader the question.
I think the API is really great already. I think there's already a wealth to explore with all of the objects and methods that've been exposed. I've only seen line shapes have a single x and y coordinate, so I wonder if there a dynamic line(x1,y1,x2,y2) might be possible?
Off the top of my head, that could allow a state-machine dog to wander around a screen with a dynamic "leash"/(line segment) with one end immobile at a "post" in the center and the other end following around the dog's position, giving the illusion of the dog on an elastic leash.
Outside of the API itself, I do still think the Execute JavaScript window is a significant bottleneck to me. I don't expect it makes sense for Art to spend too much time and energy upgrading it since so many external utilities exist, so I wonder then if the ability to add CDN links would be easier? A new menu button provides an input field to paste CDN links into, which maybe are retrieved for development purposes (e.g., verifying the available methods), and then maybe the course inserts them in the <head> tag for me when the story.html is published?
I have a lot of love for VSC so if there's a way I can easily create and import .js files into projects, or maybe open SL's Execute triggers in an external editor, that'd be amazing and would avoid anyone spending time reinventing intelli-sense. I've had luck pasting minified code into base-level triggers on a master slide so it can be called on every instance of that template slide, but not reliably enough to use it for anything more than experimentation.
Head-in-the-clouds selfish request? A stronger JavaScript audio API. I won't pretend to know what it would take to incorporate something like Howler.js, but the player now freely offering the positions and dimensions and depth of objects on the canvas could marry very well with spatial audio.
AndrewBlemings- thank you for the detailed feedback! I agree that the experience of using the trigger dialog for authoring and editing JavaScript is far from ideal; I've been thinking about some ways to improve it.