Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

SugarCube releases

edited March 2014 in Chit-Chat
I figured that I might as well post a note that I've just published a new release of SugarCube for those of you using it.

Highlights:
  • Added dynamic updating to several of the page elements within the UI bar (sidebar) when passages are displayed, which is configured via the config.updatePageElements property (default: true). The affected elements are the story: banner, subtitle, author, caption, and menu. Note: Since SugarCube uses the story's title as the basis for the key used to store and load data used when playing the story and for saves, it is not included in updates and it is strongly recommended that you do not add any kind of dynamic code to it.
  • Added a seedable PRNG which integrates with the story history (incl. saves), which is configured via the History.initPRNG() static method.
  • Changed the saves menu so that the delete and purge buttons no longer close the menu. This should make it more convenient for players to reuse save slots, since they can now delete and then immediately save without having to reopen the menu.
  • Updated the <<if>> macro to emit an error if an expression is supplied to the <<else>> clause. This is primarily to flag improper <<else if>> usage for authors.
  • Updated the <<optionbar>> macro's output to reflect the changes to UISystem.
  • Updated UISystem:
    • Added the new static method UISystem.alert(), which opens a window.alert()-style message box.
    • Added the new static method UISystem.show(), which opens the UI dialog window and is now the basic method by which all dialogs are opened.
    • Made various improvements to UISystem.
    • Updated the UI CSS styles.
  • Updated the default CSS @media query for mobile devices.
  • Updated the feature detection logic a bit and the feature polyfills.
  • Updated the embedded jQuery library (to v2.1.0).
  • Embedded the seedrandom.js library.
  • Moved the history (un)marshaling code out of SaveSystem and into History. This was spurred on in large part by the integration of the seedable PRNG into History. This also necessitated save format changes.
  • Moved several internal utility functions into the Util object for namespacing.
«13456789

Comments

  • Awesome! Congratulations :)
  • Nice! Thank you so much for providing this to the community. <3
  • I really like the new seedable PRNG. However, it is not ideal yet as an anti-cheat device: if you reload the page, your progress in the story is preserved, but the PRNG is re-seeded. It works fine though across save/load and when using the back button.
  • Ah, thanks.  I'll check into that.
  • The visitedTag macro does not work. I was swapping between Sugarcane and Sugarcube in the same game, works in Sugarcane, not Sugarcube.
  • Pixie, the macros that SugarCube supports are here:

    http://www.motoslave.net/sugarcube/docs/#macros
    http://www.motoslave.net/sugarcube/ (Extras section)
  • Okay, that accounts for why it does not work. A shame; I find visitedTag an easy way to track state.
  • I assume visitedTag is a function, similar to visited()?
  • It checks if the player has visited any pages with that tag (and counts how many times). I like it because you can have the same effect from different passages (say the player can be injured on five passages, tag each page "injured", and you can quick check if the player is hurt).

    Also, you can create test pages that link to proper pages, and tag them; then start your run through from a test page, to mimic the player having visited those places (have an "injured" tag on the test page, then play from there to see how the game responds).
  • Just published a new SugarCube release fixing the two reported regressions in -3000/-3001 and some other stuff.

    Highlights:
    • Fixed the document title not being set to the story title.
    • Fixed the new feature detection logic crashing in IE.
    • Changed the wikitext link and image formatters to be more strict about substitution.
    • Removed special CSS styling for the <<actions>> macro's unordered list.
    • Increased cross-compatibility with Twine/Twee 1.4+ vanilla-headers:
      • Added the visitedTags() function, which returns an integer count of how many passages within the story history are tagged with all of the given tags.
      • Added the tags() function, which returns a new array consisting of all of the tags of the given passages.
      • Added compatibility shims for the either() and visitedTag() functions.
  • Does SugarCube support radio buttons? I could find no sign of it in the documentation, and the "standard" syntax is not accepted.
  • I assume you mean a radio button macro of some sort.  If so, then no.  It's something I can add, but there's currently no macro for that.
  • It would be helpful for me. At the moment I am using Sugarcane, and I think this is the only thing holding me back from Sugarcube, which does have some nice features (you can initialise variables in a script passage because state.active.variables exists before then, for example).
  • This has my interest. I use all sorts of HTML input, such as text input and radio buttons.

    I haven't made the switch yet, but SugarCube's save feature is a big deal for me so I'd like to check it out.
  • I've gone ahead and added some new interactive macros.  They'll be in the next release.
    • Added the <<button>> macro, which is a <button> element version of <<click>>.
    • Added the <<checkbox>> & <<radiobutton>> macros.
    • Modified the <<textbox>> macro, so that it's argument list is consistent with <<checkbox>> & <<radiobutton>>.  Specifically, it gained a required default value argument and no longer pulls its default value from the referenced storage $variable.
  • Just published a new SugarCube release.  Get your radio buttons on.

    Highlights:
    • Removed the text "Story" from the loading screen message.
    • Updated History to maintain the seed of the integrated PRNG even through page reloads (while, hopefully, not introducing any bugs in the process).
    • Added a polyfill for window.history.state to browsers which lack it (notably some versions of Safari/iOS).
    • Added new interactive macros:
      • Added the <<button>> macro, which is a <button> element version of <<click>>.
      • Added the <<checkbox>> & <<radiobutton>> macros.
      • Modified the <<textbox>> macro, so that its argument list is consistent with <<checkbox>> & <<radiobutton>>.  Specifically, it gained a required default value argument and no longer pulls its default value from the referenced storage $variable.
  • Awesome, thanks as always! I'm hoping that this will get things working on Safari 5.1 (where I have no developer console on the testing machine)...I'll let you know!
  • Erik wrote:

    Awesome, thanks as always! I'm hoping that this will get things working on Safari 5.1 (where I have no developer console on the testing machine)...I'll let you know!


    I didn't think you could get Safari without the developer tools (they're generally built in).  I had to enable the developer menu from the preferences menu, advanced tab, because it was disabled by default.  Maybe it's just disabled in your version as well?
  • Yeah, I think that's right--but the machine I have available to me for 5.1 is in some kind of managed kiosk mode... (My main machine has v7).
  • TheMadExile wrote:

    Just published a new SugarCube release.  Get your radio buttons on.

    Thanks. Impressed how fast you knock these out.
  • TheMadExile wrote:
    • Updated History to maintain the seed of the integrated PRNG even through page reloads (while, hopefully, not introducing any bugs in the process).


    At first it didn't work in my code, but it turns out that the PRNG expects the init call to be in StoryInit, while I had it in the link used to go from the title page (Start) to the first actual story passage. It would be worth mentioning this in the API docs.

    For other programmers, here is some example code for using the PRNG in SugarCube:

    :: StoryTitle
    SugarCube Seeded Random Test

    :: StoryInit
    <<script>>History.initPRNG();<</script>>

    :: Start
    [[The road to adventure.|Adventure]]

    :: Adventure
    Your lucky number: <<print random(1, 1000)>>.

    Refresh this page or use the back button; the number won't change unless you restart the game.
    Thanks for adding and improving this feature! I'm using it in my "23" game, which I'm still working on (despite the deadline being two weeks ago).
  • Thanks very much for 3025! I am happy to say that my story now works in Safari 5.1.3 on Mac--and it now also works in Android (phone, tablet, and Kindle Fire).

    The only sticking point I've found is that the saves function does not work in iOS 7 Safari (it didn't work with 3010, either). I get an Apologies dialog mentioning that the saves function is either not supported or disabled, or to try HTTP. I am looking at my story on the Web, not locally. I also tried flipping some settings switches in iOS Safari's prefs, but that didn't help.

    But if that's the only thing that doesn't work at this point, I don't mind--I'm thrilled otherwise.
  • mth wrote:

    At first it didn't work in my code, but it turns out that the PRNG expects the init call to be in StoryInit, while I had it in the link used to go from the title page (Start) to the first actual story passage. It would be worth mentioning this in the API docs.


    Actually, I intended it to be used in a script passage (probably along with any config settings you might have).  Although, calling it in StoryInit works too, just as long as it's done at story initialization.

    I'm honestly kind of surprised that needed to be spelled out, but I'll look into clarifying that point.  Thanks.

  • TEYV wrote:

    The only sticking point I've found is that the saves function does not work in iOS 7 Safari (it didn't work with 3010, either). I get an Apologies dialog mentioning that the saves function is either not supported or disabled, or to try HTTP. I am looking at my story on the Web, not locally. I also tried flipping some settings switches in iOS Safari's prefs, but that didn't help.


    About the only way that could happen is if iOS 7 Safari broke support for localStorage.  A quick Google shows that initial versions of iOS 7 Safari are pretty buggy.  What's the full version (7.x.x) of yours?
  • I'm using iOS 7.0.6 on an iPad 2. (I think I updated it to iOS 7 only about three weeks ago, for work purposes.)
  • Hmm.  I would have figured that any breakage would have been fixed by 7.0.6, then again who knows.  I suppose it could also be some daft setting.  I don't really know.
  • Probable a silly question but are you running Safari on your iPad in private browsing mode?

    There is also this vague post on the apple forums.
  • I can't get radio buttons to work as radio buttons. I'm probably doing something very wrong.

    I used the following example code from the Sugarcube docs:
    What's your favorite pie?
    * Blueberry? <<radiobutton "$pie" "blueberry">>
    * Cherry? <<radiobutton "$pie" "cherry">>
    * Coconut cream? <<radiobutton "$pie" "coconut cream">>
    When I set the radio button and go to another passage using a link I can see that $pie gets set to "blueberry", "cherry" or "coconut cream" correctly. But while I click around on the three 'radio' buttons they can all be set on or all be set off (the initial state).
    Edit: I can't switch radio buttons off again.
    That's not what I expect for a set of radio buttons, only one button at a time should be settable, the other radio button should turn off automatically.

    Like I said, it's probably me. I'm actually using -3030. Any clues?
  • I had not noticed, but yes, I get that too.

  • I've found the problem with the radio buttons myself:

    The code is setting the radio button id, it should be setting the name.

    el.type = this.name === "checkbox" ? "checkbox" : "radio";
    el.id = this.name + "-" + varId;
    el.value = this.args[1];
    If 'el.id' is replaced with 'el.name', it should work better. I just quickly patched it directly in header.html and tested that it's working.

    Is there going to be a way to set the default radio button for a group (and the default states of check boxes)?
Sign In or Register to comment.