Howdy, Stranger!

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

Twine 2.0.6, SugarCube 2.0, UI Bar and stats

I am trying to put stats into the now-stowable UI Bar of SugarCube 2 (for Twine 2).
Does anyone know how I can do that in such a way that it retracts when the bar retracts?

As for the stats themselves I am just setting variables at different parts of the story and reflecting them there. Nothing too fancy.

Any thoughts on the subject would be appreciated.

Thank you all.

Comments

  • I have semi-solved it with a pop-up box that has all the info, but obviously it would be smoother in the UI Bar.
  • Something as simple as the following?
    :: StoryInit
    <<set $name to "Bob">>
    <<set $hp to 100>>
    <<set $mp to 67>>
    
    :: StoryCaption
    Name: $name
    HP: $hp
    MP: $mp
    
    :: Start
    Bob's HP should be 100
    [[Next Passage]]
    
    :: Next Passage
    <<set $hp to 50>>\
    Bob's HP should be 50
    
  • Yeah doesn't StoryCaption retract with the bar?
  • Yes, the element which is populated from the StoryCaption special passage, #story-caption, does stow properly.

    @Sage: I'll reiterate that you should probably be using StoryCaption. However, now that you gotten me interested, what were you trying before that wasn't working?
  • edited June 2015
    The first thing I tried was using the dot syntax from your UI-API that you wrote up on your site.... with okay results... I say "okay results" because I put it into a character sheet pop-up (as you suggested on MotoSlave, and it worked well... but I had my heart set on it being in the UI Bar and not being in a pop-up box or a Javascript alert), so then I also tried CSS layered placement and then finally (which worked okay) was the "itinerary" code that (I think GreyElf had posted to help out someone else) that I found in the forums.

    Story-caption is what I SHOULD have been using all along.

    Thanks everyone, for the code and the answers... it works great!

    But to answer your actual question, it was the pop-up box UI API answer on your site that was good advice, yes, because it worked... but not exactly how I wanted.
    http://www.motoslave.net/sugarcube/2/docs/api-ui.html
    
  • Ah, okay. When you said "how I can do that in such a way that it retracts when the bar retracts", I thought you meant that you already had it in the UI bar, but it wasn't stowing properly. Mea culpa.
  • greyelf wrote: »
    Something as simple as the following?
    :: StoryInit
    <<set $name to "Bob">>
    <<set $hp to 100>>
    <<set $mp to 67>>
    
    :: StoryCaption
    Name: $name
    HP: $hp
    MP: $mp
    
    :: Start
    Bob's HP should be 100
    [[Next Passage]]
    
    :: Next Passage
    <<set $hp to 50>>\
    Bob's HP should be 50
    

    I tried following this in SugarCube 2.0, and in Chrome I get a JavaScript error saying this:
    Javascript Alert

    Apologies! A technical problem has occurred. You may be able to continue, but some parts may not work properly.

    Error: Script error...

    The HTML file is attached.

    It works fine in Firefox.
  • edited June 2015
    It (your example file, specifically) works just fine in Chrome for me (Chrome 43.0.2357.124 m on Win7).

    According to the data in the file you seem to be using Twine 2.0.5? Are you running the non-NW.js version of Twine 2 in Chrome? If so, did you get the error from a Test or Play? If so, did you try the published file in Chrome?

    Note: Twine 2.0.5 contains bugs which negatively impact Test and Play. Twine 2.0.6 does as well, though not nearly as severe.
  • It (your example file, specifically) works just fine in Chrome for me (Chrome 43.0.2357.124 m on Win7).

    According to the data in the file you seem to be using Twine 2.0.5? Are you running the non-NW.js version of Twine 2 in Chrome? If so, did you get the error from a Test or Play? If so, did you try the published file in Chrome?

    Note: Twine 2.0.5 contains bugs which negatively impact Test and Play. Twine 2.0.6 does as well, though not nearly as severe.

    Hi @TheMadExile, you are right. The bug only occurs in Test and Play, not once the file is published. And yes, I am suing the html version of Twine 2.0.5. I haven't yet upgraded to 2.0.6.

    But since this is a known issue, and since it only affects Test and Play, i guess that's fine.

    Thanks. (I'll have to spend time now learning SugarCube code, as I got fairly used to Harlowe!)

Sign In or Register to comment.