UofTMADLab / reach

A VR format for Twine
0 stars 0 forks source link

Add ability to load external twine passages #53

Open samesimilar opened 4 years ago

samesimilar commented 4 years ago

This would let us load sets of passages as a 'library' remotely, keeping the core 'reach' format smaller.

Libraries of %code% passages could be loaded into a story and then referenced to create more complicated scene items.

samesimilar commented 4 years ago

This has been added in the latest commit. You can load an external story (that was 'published' to html) with:

window.story.import("http://url_of_story.html", "nameSpaceToUse");
// namespace can be anything (letters or numbers, no spaces). 
// It's used just in case there are name collisions.

Note that the import function has to run in the 'story' javascript ('edit story javascript' command in Twine). The story will not start running until all external scripts have been loaded.

Any code passages in the imported story can be used as special codes. e.g. if there is an imported passage named %customTextPanel%, then it can be accessed like : [customTextPanel[parameter1]parameter2]

So this an extension of the [img[url]link] syntax to support custom types of elements. Typically the javascript in the imported code would construct some kind of specialized elemenet in the scene.

The parameters are passed to the imported code as params.parameter1 and params.parameter2.

The full syntax is:

{"jsonOption": value}[codeName[parameter1]parameter2]
samesimilar commented 4 years ago

This way we can use Twine to prototype all sorts of specialized types of objects that users could use in their stories, without modifying the core 'reach' library. Then we can just publish it for others to use.