Pass variable from SL project to another SL project
Dec 17, 2013
How do I pass a variable from a SL project to another SL project? In other words, let's say that I have a variable called "color" in a SL project I named "project1" and I assign the variable color to be 0, that is color=0. In project1, let's say that I create a button with a trigger that when the user presses the button it changes the value of color to 1, that is color=1. Now, let's say that I have another SL project called "project2" and that I want to pass the variable color to Project2 with the value 1, not 0 since the user has already pressed the button in project1 so that color=1 not color=0. I start with project1 and go to project2 by creating a button with a trigger to jump to URL/file.
I found the following site here that gives me some ideas, but I'm not sure how to do what I am describing. I presume that I could possible execute some javascript code in project2 to bring in the variable color from project1 with the value 1, but I am not sure. I would appreciate any help. Thanks.
3 Replies
Hi Dallin and welcome to Heroes!
There is not a built in way to pass a variable from one Storyline course to another, but there is some discussion in this thread on how to pass variables into Storyline using Javascript.
Ashley,
Thanks for the response. The thread at least gave me some ideas. I messed around with the code from the thread:
var query = window.location.search.substring(1); //verify syntax is accurate for what you want to do; I didn't but it should be close
var slPlayer = GetPlayer(); //reference to SL player
var myStorylineVar = query;
slPlayer.SetVar("theNameOfYourStorylineDefinedVarHere", myStorylineVar );
Let's say that I have a url address for my SL project named https://www.mySLproject/story.html. I noticed that if I inserted my name "Dallin" after my url like this https://www.mySLproject/story.html?Dallin and created a variable called theNameOfYourStorylineDefinedVarHere and then executed the Javascript code above in my SL project %theNameOfYourStorylineDefinedVarHere% returned Dallin.
However, I don't know how to retrieve a variable from a different SL project using an url.
For example, although this doesn't make sense I think it gets across the point:
https://www.mySLproject/story.html?www.mySLproject2/story.html/RetrieveVariableFromOtherStorylineProject
Hi Dallin,
It's something I'll have to defer to the community on, as I'm not equipped to support the creation of Javascript, but it sounds like you're off to a good start!
This discussion is closed. You can start a new discussion or contact Articulate Support.