Macro.add("html5loadvideo",{ handler:function(){
/* video qualitaty settings from var */
var vQ = SugarCube.State.active.variables.videoQuality;
var fileName = this.args[1];
var src = fileName.replace(".mp4", '_'+vQ+'.mp4');
src = src.replace(".ogg", '_'+vQ+'.ogg');
if ($("#"+this.args[0]).length == 0){
$("body").append('<video id="'+this.args[0]+'" class="html5backgroundvideo" poster="'+this.args[2]+'" style="display:none;" preload="none"><source src="'+src+'"></video>');
}
}
});
Unfortunately I get the following error since beta8 release - I used alpha7/beta2 before:
Error [StoryInit]: cannot execute macro <<html5loadvideo>>: SugarCube.State is undefined.
I don't know why I didn't see this when it was first posted. Oh well, better late than never, I suppose.
First of all, you should not be using the SugarCube global. It is for debugging purposes only.
Second, I believe you have your story mixed up a bit. The State object has only existed since v2.0.0-beta.8, before then it would have been state (notice the case difference). The reason that SugarCube.state no longer works is because, again, the SugarCube global is only for debugging. You should have been using state.active.variables.videoQuality from the start, which still works because I've added legacy aliases.
Anyway, from v2.0.0-beta.8 onwards, instead of even state.active.variables.videoQuality, what I'd recommend is State.variables.videoQuality.
IOW, change the following:
var vQ = SugarCube.State.active.variables.videoQuality;
Twine 2.x: Included as a built-in. See the SugarCube 1.x in Twine 2 guide if you want to install another local copy (e.g. to install a newer version than is included).
Changelog highlights:
Fixed an issue in IE and Edge with the audio macros where a playing track would stop and restart when issued certain actions.
Fixed character escape shenanigans with the story name when compiled by Twine 2.
Twine 2.x: Included as a built-in. See the SugarCube 1.x in Twine 2 guide if you want to install another local copy (e.g. to install a newer version than is included).
Changelog highlights:
Added the fadeoverto action to both the <<audio>> and <<playlist>> macros.
By request, for those heavily invested in SugarCube v1.x.
It's not a macro, its an action for the <<audio>> and <<playlist>> macros. Assuming that was simply a mistype, try refreshing your browser's cache, because I guarantee you that it is in the current v1.x <<audio>> macro documentation (likewise for <<playlist>>). If not, well, you should know where to look by now.
I suppose I could also go over the basic usage for <<audio>> here as well:
→ Start playback and fade from the current volume to 75% volume over 30 seconds
<<audio "track_id" fadeoverto 30 0.75>>
→ Start playback and fade from 25% to 75% volume over 30 seconds
<<audio "track_id" volume 0.25 fadeoverto 30 0.75>>
Twine 2.x: Included as a built-in. See the SugarCube 1.x in Twine 2 guide if you want to install another local copy (e.g. to install a newer version than is included).
Changelog highlights:
Fixed some timing issues related to fading which affected the audio macros.
Fixed an issue with objects stored within story variables where the object's own methods would not be deserialized properly.
Updated the default print formatting for objects to use their custom toString() methods, if available, and altered the default formatting of Map objects slightly.
Fixed a bug in the processing of config.history.maxStates where a setting of 0 was treated as though it were 1.
Fixed a styling issue with empty menu lists.
Added a debug view, which consists of a configuration object property config.debug and story loading hooks to automatically enable it in Twine 1 (Test Play From Here) & Twine 2 (Test Mode).
Altered the default formatting of Map objects slightly.
Some internal refactoring and cleanup.
Updated the Twine 1 story format support file to add coloring for the PassageFooter and PassageHeader as special passages.
The Bleached style for 2.x was also updated (specifically, for the debug view).
Debug view notes:
It's enabled by default when in test mode. You can toggle it off with the button at the top of the UI bar. If you've removed/hidden the UI bar, a construct like the following will allow you to toggle it on and off:
Fixed an issue with the <<script>> macro where it could create two debug views.
Fixed an issue where the PassageReady and PassageDone special passages' debug views were created whether the passages existed or not.
Updated the <<silently>> macro's error message tooltip to include its full contents.
Added the hidden mode to the debug views for <<break>>, <<continue>>, and <<stop>>, as they produce no output.
Adjusted the vertical alignment for block debug views.
Added temporary _variables, which are like story $variables and should work in most of the same places. Their differences: they aren't part of the story state, their lifetime is limited to that of their containing passage, and they are not supported by the <<remember>> and <<forget>> macros.
Added optional CSS transitions to the <<timed>> and <<repeat>> macros.
Added the missing macro-display class to the <<display>> macro's optional content container.
All time sensitive DOM operations now have a minimum delay. This is mostly to protect against pathological instances (e.g. reflows) which can take significant time to complete.
Refactored the macro context payload objects to include an args object, which is similar in form and function to the macro context args object.
This is the first release of a rather significant update, so this is a testing release only—not a general release. Those who don't want to play guinea pig should skip it. For those who do try it out, please report any regressions or other issues so they may be addressed.
Major refactoring. Chiefly revolving around updating the codebase to ES6 (mostly).
Refactored how expired moments are handled to allow the "visited" family of story functions (lastVisited, visited, visitedTags) to work as intended even over long playthroughs when expiring moments.
Fixed the filenames of exported saves and added a datestamp to them.
Major refactoring. Chiefly revolving around updating the codebase to ES6 (mostly).
Refactored how expired moments are handled to allow the "visited" family of story functions (lastVisited, visited, visitedTags) to work as intended even over long playthroughs when expiring moments.
Fixed the filenames of exported saves and added a datestamp to them.
Added the <Array>.delete() and <Array>.deleteAt() native object methods.
A slew of other fixes and improvements.
Additionally, the documentation has seen some expansion and cleanup.
Re: debug mode, is there a way to set it to default to off? I like to use "test play" to see how individual passages will look without debugging them or going through the story from the beginning, so I don't always want to have debug mode on even though it is pretty cool.
The toggle button works, but I'd rather not have to click that every time.
For example, put the following in your Story JavaScript (or, if using Twine 1, a script-tagged passage):
Config.debug = false;
Whenever you want Test Mode to function again, simply comment that line out or remove it.
Oh, cool. Already tried that using the documentation but it didn't work--copy and paste'd and now it does, so I guess I typed it wrong or something.
Guess I might as well say this to make this post not wasted space: sugarcube is awesome, I don't think I'd be using Twine if not for it. So thanks for making it.
Twine 2.x: Included as a built-in. See the SugarCube 1.x in Twine 2 guide if you want to install another local copy (e.g. to install a newer version than is currently included).
Changelog highlights:
Fixed an issue with the <<cacheaudio>> macro whereby it would fail to properly handle URLs containing query or hash strings.
Fixed the visited link class feature so that it checks the entire played history, rather than just the in-play history (i.e. it now checks expired moments too).
Moved the core foreground/background color properties from the html element back to the body element. This is a reversion of a change made in v2.6.0—it's proven itself to be more annoying than the issue it was meant to alleviate.
Modified the line continuation markup to support being used at the start of lines, in addition to at the end.
Added backtick expressions to discrete argument style macros, which allows you to use an expression as a singular argument. See the macro library documentation (at the top) for more information.
Added the hasVisited() story function, which returns whether the given passages have been played. If you simply want to know if the player has been to a passage, this is the most efficient method.
Fixed a bug which caused the <<numberpool>> macro's <<onchange>> to be executed before the associated variables and controls were updated, rather than after.
Comments
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights (since 2.0.0-beta.8):
StoryInit:
Story javascript:
Unfortunately I get the following error since beta8 release - I used alpha7/beta2 before:
Help appreciated!
Thanks in advance!
Best regards,
Matthias
StoryInit:
Story javascript:
Unfortunately I get the following error since beta8 release - I used alpha7/beta2 before:
Help appreciated!
Thanks in advance!
Best regards,
Matthias
First of all, you should not be using the SugarCube global. It is for debugging purposes only.
Second, I believe you have your story mixed up a bit. The State object has only existed since v2.0.0-beta.8, before then it would have been state (notice the case difference). The reason that SugarCube.state no longer works is because, again, the SugarCube global is only for debugging. You should have been using state.active.variables.videoQuality from the start, which still works because I've added legacy aliases.
Anyway, from v2.0.0-beta.8 onwards, instead of even state.active.variables.videoQuality, what I'd recommend is State.variables.videoQuality.
IOW, change the following: To:
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights (since 2.0.0-rc.1):
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
I suppose I could also go over the basic usage for <<audio>> here as well:
Thanks.
----
Announcing SugarCube v1.0.34:
Announcing SugarCube v2.1.1:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Debug view notes:
It's enabled by default when in test mode. You can toggle it off with the button at the top of the UI bar. If you've removed/hidden the UI bar, a construct like the following will allow you to toggle it on and off:
Hovering over most things shows the code behind them.
I fully expect that the debug view may need tweaking, so don't hesitate to comment.
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
PS: Under Downloads > Add-ons is a new optional macro package <<numberbox>>. Might be useful to some.
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
This is the first release of a rather significant update, so this is a testing release only—not a general release. Those who don't want to play guinea pig should skip it. For those who do try it out, please report any regressions or other issues so they may be addressed.
Downloads:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
The toggle button works, but I'd rather not have to click that every time.
For example, put the following in your Story JavaScript (or, if using Twine 1, a script-tagged passage): Whenever you want Test Mode to function again, simply comment that line out or remove it.
Oh, cool. Already tried that using the documentation but it didn't work--copy and paste'd and now it does, so I guess I typed it wrong or something.
Guess I might as well say this to make this post not wasted space: sugarcube is awesome, I don't think I'd be using Twine if not for it. So thanks for making it.
----
Announcing SugarCube v2.6.0:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Announcing SugarCube v1.0.35:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/
Changelog highlights:
Downloads & documentation for all Twine versions: http://www.motoslave.net/sugarcube/2/ (under: Downloads > Add-ons)
Changelog highlights: