Howdy, Stranger!

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

Two very basic Sugarcube Questions

Hello all. Very new to Twine, and enjoying learning the system. I have had lots of success so far using variables, links, and other fairly basic tools.

I've now upgraded from sugarcane to Sugarcube and have two questions that seem simple. Haven't been able to find a clear answer so far:

1) What is the best way to change the background color for the entire story? I have tried using a stylesheet but can't get it to work, and haven't found a clear explanation for this thus far.

2) I had lots of variables working when I used sugarcan. I then converted over to Sugarcube and they seem to all have been broken. Is there something obvious that I need to update when making that switch?

Thank you very much.

Comments

  • No idea about SugarCube, but to change the background it's not "body {background-color:whatever}"?
  • Hm, not sure but that doesn't seem to work for me. I have tried using that with a stylesheet with no luck. Again, my goal for that issue is to change the background for all passages in the entire story.

    I feel like I am missing something obvious on both issues.

    Thanks!
  • Upload a TWS file.

    EDIT: I'll do the same, actually. Attached.
  • Hiya, regarding 2) I had the same problem when transferring a story. In Sugarcane uninitialised variables are treated as 0, but in Sugarcube they have to be initialised manually.

    So, if you have a variable that will always be set before it is checked (say it's set in the start passage and not checked until afterwards), it'll work fine. But if a variable can be checked before it is set you'll have to initialise it yourself at the start of the story by setting it to 0.
  • madisonx wrote:

    1) What is the best way to change the background color for the entire story? I have tried using a stylesheet but can't get it to work, and haven't found a clear explanation for this thus far.


    Put this in a stylesheet passage:
    body { background-color: <COLOR>; }
    Where <COLOR> is any valid CSS color value.

    For example, all of these set the background color to white: (this is not an exhaustive reference, see the CSS color value link for more information)

    /* using a color keyword */
    body { background-color: white; }

    /* using a hexadecimal value (full six-digit notation) */
    body { background-color: #ffffff; }

    /* using a hexadecimal value (short three-digit notation) */
    body { background-color: #fff; }

    /* using rgb() function notation */
    body { background-color: rgb(255,255,255); }

    madisonx wrote:

    2) I had lots of variables working when I used sugarcan. I then converted over to Sugarcube and they seem to all have been broken. Is there something obvious that I need to update when making that switch?


    Use the StoryInit special passage and the <<set>> macro to initialize any $variables that may be used prior to being set normally.
  • Thanks for all the helpful replies!

    So in my case using Sugarcube, I have lots of variables that need to start at different values. Trying to use the StoryInit passage but not having much luck.

    1) I create a StoryInit special passage and put all the variables there using standard <<set>> macro, same as was working in Sugarcane.
    2) I start all the variables at 0.
    3) In the Start passage, I set all the variables to their initial values.

    What am I missing?

  • Hmmm. Any variables you were setting at the start in Sugarcane should still work fine in Sugarcube, it's just the ones that you weren't setting before that should give you a problem.

    Also, you should only have to set the variables in either Start OR StoryInit, not both (use StoryInit because TheMadExile knows better than I do!). And if you want a variable to be set to 2 at the start, there's no need to set it to 0 first.

    Can you post some example code you are using? I imagine it's a simple problem.
  • mostly useless has the right of it.

    I will add one more thing, however, in your <<if>> macros be sure that you do not include a space between the "else" and the "if" in <<elseif>> clauses.  For example:

    <<if $a>>

    <<elseif $b>>

    <<else>>

    <</if>>
    The next release of SugarCube will issue a warning about that, but the current release doesn't, so that could be tripping you up as well.

    Honestly, it would be better if the wiki docs here didn't push <<else if>> and barely mention <<elseif>> as a footnote.
  • Hm...

    When using Sugarcube and creating a special passage like StoryInit, should that passage's banner change color similar to when I create a special passage like StoryMenu? Because my StoryInit is still colored like a normal passage.

    As far as code, here is an example of what I had under Sugarcane, working perfect, that seems to be not working properly in Sugarcube:

    <<silently>>
    <<set $day = "Monday">>
    <<set $month = "September">>
    <<set $day_number = "1">>
    <<set $time = "Early Morning">>
    <<end silently>>
  • madisonx wrote:

    When using Sugarcube and creating a special passage like StoryInit, should that passage's banner change color similar to when I create a special passage like StoryMenu? Because my StoryInit is still colored like a normal passage.


    Probably not, no.  Twine would have to know that StoryInit is special.  Hopefully, the hooks implemented by the next version of Twine will allow for things like that.

    madisonx wrote:

    As far as code, here is an example of what I had under Sugarcane, working perfect, that seems to be not working properly in Sugarcube:

    <<silently>>
    <<set $day = "Monday">>
    <<set $month = "September">>
    <<set $day_number = "1">>
    <<set $time = "Early Morning">>
    <<end silently>>


    1. You have a space between "end" and "silently", it should be one word (unless something has changed, that's not even allowed in the vanilla headers).

    2. What version of SugarCube are you using?  Because that should have thrown a error complaining about not being able to find a closing tag for macro <<silently>>.

    3. The StoryInit special passage is already silent (save for errors), so <<silently>> is superfluous and can be removed.  For example:

    <<set $day = "Monday">>
    <<set $month = "September">>
    <<set $day_number = "1">>
    <<set $time = "Early Morning">>
    Also, if $day_number is supposed to be an actual number, rather than a numeric string, don't quote it.  For example:

    <<set $day = "Monday">>
    <<set $month = "September">>
    <<set $day_number = 1>>
    <<set $time = "Early Morning">>
  • Ok so I happened to be using a version of Sugarcube that I downloaded last week. I downloaded the latest version, and now all my variables seem to be working properly!

    Thank you to everyone for taking the time to assist a new user. Much appreciated!
Sign In or Register to comment.