Not entirely correct. Yes the name attribute should be set as well, oversight on my part, but the id should most certainly be getting set as well. This is not an either-or situation. And, I fixed the name snafu in the devel repo about thirty minutes ago, so that's no longer an issue.
There already is, or will be, a way to set them for a group, the $variable used. The name attribute, along with the id, are set based on the name of the $variable, which means <<radiobutton>>s are grouped by the $variable used (that's what the name attribute is for, grouping).
The default state is another oversight, which I'll need to fix for both the <<checkbox>> and <<radiobutton>> macros.
Thanks for all the fixes. We now have proper groups of radio buttons!
I know you can't just ignore the id, and it needs to be set too, but in this case all I needed was to set the name to group them. Just a very quick hack!
In a story I have a passage that offers several options for continuing. However, depending on what you did before and on luck, some options might fail to produce the desired effect. In this case, the remaining options will be displayed. I implemented it like this:
However, if I pick option A and then use the browser's back button, the passage returned to will no longer show option A. This means that the "Option A" passage is still considered visited even though I undid the action to go there (I see the browser back button as "undo"). Is this a bug or are my expectations wrong?
I'm using SugarCube -3030.
Edit: I get this problem in Firefox. In Konqueror (WebKit renderer) it doesn't occur.
Published a new release which should fix the <<checkbox>> & <<radiobutton>> issues (check the docs for the new checked state syntax) and the visited() snafu in Firefox.
greyelf, regarding saving in iOS 7: That was not a silly question. Turns out that Private Browsing was on, and it was the culprit. Saves and loads now work just fine. So thanks very much for that suggestion!
I have to say, though, I don't recall setting it to Private at all. Perhaps it came that way by default when I updated to iOS 7, or maybe I brushed the button accidentally at some point. Rather annoying.
Published a new release addressing some additional <<checkbox>> & <<radiobutton>> issues. Notably, <<checkbox>> gained a required unchecked value argument, so existing uses will require updating.
I've encountered some Firefox weirdness in the past day (though I really, really wish I'd found it earlier).
If I load my story, then go to other websites, and then try to return to my story (by the back button, by a bookmark, or by retyping the URL), it attempts to load but then puts up the "Error: TypeError: window.history.state is undefined" dialog. Quitting Firefox, relaunching it, and then trying my story again loads it just fine. I was able to reproduce this in Firefox on Windows and Mac. I can't reproduce it in Chrome or IE.
This was happening in 3025. I tried updating to 3050 (since I saw that 3040 addressed some Firefox stuff), but that didn't make a difference.
EDIT (3/25): Ah, I see. Thanks for your reply, TheMadExile. I won't worry about the problem, then!
I've encountered some Firefox weirdness in the past day (though I really, really wish I'd found it earlier).
If I load my story, then go to other websites, and then try to return to my story (by the back button, by a bookmark, or by retyping the URL), it attempts to load but then puts up the "Error: TypeError: window.history.state is undefined" dialog. Quitting Firefox, relaunching it, and then trying my story again loads it just fine. I was able to reproduce this in Firefox on Windows and Mac. I can't reproduce it in Chrome or IE.
That's a bug in Firefox. It appeared 2-3 releases ago now and it seemed to be fixed in the next point release. Apparently, it was only partially fixed.
I get an uncaught type error: Cannot read property title of undefined, when I try to use the replace macro set/the cyclinglink macro.
It's been a while since I last tested those. Let me check. Okay, found the problem.
I've published updates for both SugarCube itself as well as the SugarCube versions of the replacelink macro set and cyclinglink macro. That should fix the problem. Sorry about the trouble.
Another update to allow the <<checkbox>>, <<radiobutton>>, and <<textbox>> macros to set object/array properties (e.g. "$foo.bar", "$foo['bar']", & "$foo[0]"), which is something I've meant to do for a while but kept forgetting about.
Published a new release (-3100), which includes a <<textbox>> bugfix and behavior change:
Fixed a race condition in the <<textbox>> macro under certain browser engines (WebKit/Blink and Presto). (n.b. the Extras button-toting variant was also updated)
Added a polyfill for Math.trunc().
Added two more Twine/Twee 1.4+ vanilla header compatibility shims: turns() and passage().
Updated the <<textbox>> macro to set the $variable to the default value of the control at initialization.
Updated certain error messages (currently, macros and HTML tags) to include tooltips on the error elements which show the source of the item which generated the error.
Updated the error messages of the <<print>>, <<if>>, <<set>>, <<unset>>, <<remember>>, and <<forget>> macros.
Updated the htmlTag formatter to apply special processing for <a> and <img> tags which contain the "data-passage" attribute.
Updated the macro processing code to allow the options and setup objects to be passed as arguments.
Updated the python header support file to return an "unsupported" message within the StorySettings UI and to apply coloring to the titles of both widget tagged passages and the SugarCube-specific special passages. (requires Twine 1.4.2 rc1 or better)
Updated the htmlTag formatter to improve the special processing for tags containing data-* attributes. In particular:
The data-passage attribute now supports $variables.
Added special processing for the <area> tag (same as for the <a> tag).
If an <a> or <area> tag has a data-passage attribute, then it may also include a data-setter attribute, which sets $variables (similar to the setter link wiki-text markup).
Changed the wiki link and image formatters so that they accept expressions for their various components (e.g. you can now do this: [["I'll go talk to " + $who|$who + " Talk Scene"]]).
Retired windowHistory mode in favor of sessionHistory mode for all browsers (save Interner Explorer when using the file:// scheme), as it is simply much too slow when loading games with both large states and numbers of turns.
User functions and RegExp objects are now safe to store in $variables, even being automatically restored from saves.
Updated save exports so that they are now compressed and Base64 encoded. Their extension also changed from ".json" to ".save".
Updated the store area element to include Twine 1.4.2's data-size attribute.
Updated some error messages.
Added polyfills for <String>.contains() and <Array>.contains().
Fixed an issue with the rewind menu in sessionHistory mode, which would cause it to fail, and a few other minor issues.
Updated the config.saves.autosave property to also accept an array of tag names.
Changed the document loader's message from "Loading Resources" to "Initializing. Please wait", since the former could easily be mistaken as an indication that external resources were being loaded.
Changed the style of the UI dialog closer so that it looks like a standard UI component and altered its positioning slightly, and decreased the duration of the fade-in animation for it, as it was taking noticeably longer to appear than the dialog in several browser engines.
Increased the minimum allowed margin between the viewport and UI dialogs by 60%.
Fixed the issue where several static Wikifier methods were broken in certain circumstances (bugs introduced in r3250).
Fixed the issue with macro evaluation if the last line was an inline comment.
Fixed the issue with mobile browsers which have broken window.history.state implementations.
Updated the <Array>.contains() method to accept lists, either as multiple arguments or a single array.
Added several new polyfills.
Added additional tests to a few of the capability checks.
Completely overhauled how serialization and deserialization is handled. In addition to user functions and RegExp objects, Date objects are now properly serialized.
Changed the History prototype and its static methods to delta encode all copies of the history stack, including saves.
Changed the Hash history mode to encode all state, not simply path information.
Changed the version object: added the prerelease property, added the short() and long() methods, and toString() is no longer an alias of the latter.
Changed the build system: the build script has been completely rewritten for Node.js and the JavaScript minifier has been changed to UglifyJS 2.
Changed build metadata so that releases will now largely follow the Semantic Versioning 2.0.0 format.
Majorly overhauled the CSS. Key style changes: reworked how the <body> and #passages elements interact, and reworked the @media queries. Additionally, the CSS has been split into several separate <style> elements (one for each: init screen, fonts, structural, appearance, basic @media queries, narrow viewport @media queries), which will allow entire style groups to be removed or replaced by authors upon initialization.
Changed how the MenuStory passage in transformed into the story menu. The StoryMenu passage is, temporarily, unaffected by this change. Basically, if you're using either passage as a dumping ground for non-menu content, you need to find someplace else for it (StoryCaption might be a nice place).
Changed how the Rewind and Share menu dialogs work.
Updated the macro processor to unescape string literals used as arguments to macros (e.g. "\"You can't make me!\"" will now yield "You can't make me", just as it would in JavaScript).
Updated the visited() function to make it fully compatible with its vanilla counterpart.
Updated the previous() function to allow it to take an optional integer offset.
Added the lastVisited() function, which returns the number of turns that have passed since the last instance of the given passage occurred within the story history or -1 if it does not exist.
Added the state.has() method, which returns whether any states with the given title exist within the story history (e.g. state.has("Bar") is equivalent to visited("Bar") neq 0, save that state.has() returns immediately upon finding an instance of Bar while visited() traverses the entire history to count all instances of Bar).
Added the capability to flag internal passage links as having been visited by adding the class link-visited, which is configured via the config.addVisitedLinkClass property (default: false).
Added an additional test to the browser requirements check.
Other improvements.
Note: If you override any of SugarCube's non-trivial styling, then release 1.0.0 probably breaks your CSS. Seriously, you have been warned.
Hey, I just installed sugarcube and I want to resize the header that has the title and author and whatnot. How do I do that? Or how do I make the text in the passages scrollable?
Comments
There already is, or will be, a way to set them for a group, the $variable used. The name attribute, along with the id, are set based on the name of the $variable, which means <<radiobutton>>s are grouped by the $variable used (that's what the name attribute is for, grouping).
The default state is another oversight, which I'll need to fix for both the <<checkbox>> and <<radiobutton>> macros.
I know you can't just ignore the id, and it needs to be set too, but in this case all I needed was to set the name to group them. Just a very quick hack!
I'm using SugarCube -3030.
Edit: I get this problem in Firefox. In Konqueror (WebKit renderer) it doesn't occur.
I have to say, though, I don't recall setting it to Private at all. Perhaps it came that way by default when I updated to iOS 7, or maybe I brushed the button accidentally at some point. Rather annoying.
If I load my story, then go to other websites, and then try to return to my story (by the back button, by a bookmark, or by retyping the URL), it attempts to load but then puts up the "Error: TypeError: window.history.state is undefined" dialog. Quitting Firefox, relaunching it, and then trying my story again loads it just fine. I was able to reproduce this in Firefox on Windows and Mac. I can't reproduce it in Chrome or IE.
This was happening in 3025. I tried updating to 3050 (since I saw that 3040 addressed some Firefox stuff), but that didn't make a difference.
EDIT (3/25): Ah, I see. Thanks for your reply, TheMadExile. I won't worry about the problem, then!
That's a bug in Firefox. It appeared 2-3 releases ago now and it seemed to be fixed in the next point release. Apparently, it was only partially fixed.
It's been a while since I last tested those. Let me check. Okay, found the problem.
I've published updates for both SugarCube itself as well as the SugarCube versions of the replacelink macro set and cyclinglink macro. That should fix the problem. Sorry about the trouble.
This lines of codes does not modify the variable : I can't see what's wrong.
How Many Zombies do you want to fight?
<<radiobutton "$battle.enemies" 10 checked>>10
<<radiobutton "$battle.enemies" 25>>25
<<radiobutton "$battle.enemies" 50>>50
<<radiobutton "$battle.enemies" 100>>100
<<radiobutton "$battle.enemies" 250>>250
<<radiobutton "$battle.enemies" 500>>500
<<radiobutton "$battle.enemies" 800>>800
if i input <<print $battle.enemies>> on any other pages after, I get my initial value of 0.
Thanks, i'll update first.
EDIT: It works.
Thanks for SugarCube, it made possible to make the game I wanted to make.
Here is a glimpse of my combat system with about 20% of the real combat system. Witch is about 10% of my game.
http://www.northernlightsgames.com/Outbreak/Combat.html
<<textbox>>
bugfix and behavior change:<<textbox>>
macro under certain browser engines (WebKit/Blink and Presto). (n.b. the Extras button-toting variant was also updated)Math.trunc()
.turns()
andpassage()
.<<textbox>>
macro to set the $variable to the default value of the control at initialization.<<print>>
,<<if>>
,<<set>>
,<<unset>>
,<<remember>>
, and<<forget>>
macros.data-*
attributes. In particular:data-passage
attribute now supports $variables.<area>
tag (same as for the<a>
tag).<a>
or<area>
tag has a data-passage attribute, then it may also include adata-setter
attribute, which sets $variables (similar to the setter link wiki-text markup).<<for>>
,<<break>>
, and<<continue>>
macros.window.history.state
implementations.<Array>.contains()
method to accept lists, either as multiple arguments or a single array.RegExp
objects,Date
objects are now properly serialized.History
prototype and its static methods to delta encode all copies of the history stack, including saves.short()
andlong()
methods, andtoString()
is no longer an alias of the latter.Published a new release (v1.0.0):
- Majorly overhauled the CSS. Key style changes: reworked how the
- Changed how the
- Changed how the Rewind and Share menu dialogs work.
- Updated the macro processor to unescape string literals used as arguments to macros (e.g.
- Updated the
- Updated the
- Added the
- Added the
- Added the capability to flag internal passage links as having been visited by adding the class
- Added an additional test to the browser requirements check.
- Other improvements.
Note: If you override any of SugarCube's non-trivial styling, then release 1.0.0 probably breaks your CSS. Seriously, you have been warned.<body>
and#passages
elements interact, and reworked the @media queries. Additionally, the CSS has been split into several separate<style>
elements (one for each: init screen, fonts, structural, appearance, basic @media queries, narrow viewport @media queries), which will allow entire style groups to be removed or replaced by authors upon initialization.MenuStory
passage in transformed into the story menu. TheStoryMenu
passage is, temporarily, unaffected by this change. Basically, if you're using either passage as a dumping ground for non-menu content, you need to find someplace else for it (StoryCaption
might be a nice place)."\"You can't make me!\""
will now yield"You can't make me"
, just as it would in JavaScript).visited()
function to make it fully compatible with its vanilla counterpart.previous()
function to allow it to take an optional integer offset.lastVisited()
function, which returns the number of turns that have passed since the last instance of the given passage occurred within the story history or-1
if it does not exist.state.has()
method, which returns whether any states with the given title exist within the story history (e.g.state.has("Bar")
is equivalent tovisited("Bar") neq 0
, save thatstate.has()
returns immediately upon finding an instance of Bar whilevisited()
traverses the entire history to count all instances of Bar).link-visited
, which is configured via theconfig.addVisitedLinkClass
property (default:false
).You know who to call.