Howdy, Stranger!

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

CSS newbie question

Hi there,

I really think I'm a fool for asking this, but I just can't seem to solve this puzzle no matter what I try and where I've looked.

I'd like to use recurring custom named styles in my (Harlowe) project, and I've been doing so with code snippets like this:
(set: $robotrumble to (font: "Courier New") + (text-style: "rumble"))
and text entries like this:
The robot says $robotrumble[Intruder Alert!]

I'd like to use stylesheets to avoid the need to cut/paste every new text style into every passage and ensure they're all global and identical, but I can't make it work. I've tried making a new passage, setting the name and tag to 'stylesheet' (no quote marks), I've tried using HTML type tags, I've tried many many permutations and I can't get the styles to be applied universally to all passages. I've tried accessing the Stylesheet via the "Edit Story Stylesheet" menu item in the popup next to the project name, but to no avail.

All of the tutorials I can find seem focussed on editing the style for existing styles like body and passage, not creating your own new ones.

I feel like this should be really simple, but I'm just missing something!

Any pointers?

Comments

  • edited June 2015
    Have you tried:
    <span class="robot">Intruder Alert!</span>
    

    Where in the Story Stylesheet you write:
    .robot {
    font-family: "Courier New";
    }
    
  • edited June 2015
    That did work, thank you, but I was hoping to find a way to achieve the styling without opening and closing span tags. They break the text up and make it much harder to write and proof. The $stylename[content] syntax is so much more neat and concise.

    However, if there's no way to achieve something like that, then the span tags will have to do, I suppose?

    Edited to add: Is there anywhere that has the HTML/CSS code for special effects text like rumble, blur, blurrier, etc.?
  • The Twine 2 documentation says your original method is supposed to persist across the whole story. If it's not, something is going on.
  • Okay, I'll have another look tomorrow when I'm back on my PC. Thanks!
  • When @Claretta says it should persist across the whole story they mean that the $variable you assigned your style to is available in every passage viewed after the one the one you did the original assignment in.

    note: the following example is using Twee Notation, lines starting with a double colon indicate a new passage, the text on the same line as the double colon is the new passage's name and the lines directly after the line with the double colon is the new passage's contents.
    :: First
    (set: $robotrumble to (font: "Courier New") + (text-style: "rumble"))
    
    The robot says $robotrumble[Intruder Alert!]
    
    [[Next->Second]]
    
    :: Second
    The robot says $robotrumble[This should still be styled like the First passage!]
    
    [[Next->Third]]
    
    :: Third
    The robot says $robotrumble[Still the same styling as the First and Second passage!]
    
  • Okay, back on my PC and I can't get the style to propagate across passages.

    Greyelf, I copied your code above, and broke it into three passages named FIRST, SECOND and THIRD, and ensured that they linked through to each other as per your -> codes.

    I ensured that the first had the $robotrumble style set, and it did not propagate to the subsequent passages. All I would get would be something like this:

    The robot says 0This should still be styled like the First passage!

    So I was extremely frustrated, and dug further! I made a new story with only those passages, in case there was junk code elsewhere in my original story that was messing things up. Still no luck.

    I then tried clicking through the links... and the styles in the second and third passages worked! It was then that I made the realisation that I'd been checking text styles in individual passages using the Debug button. When I followed the links through, the styles worked, but when I accessed a passage directly using Debug, the styles failed.

    So thanks to both Claretta and Greyelf for assistance and helping me come to this realisation! I guess this means that all $styles need to be implemented in the root/origin passage, or they won't work in subsequent passages. Is this a known facet of this kind of style?

    Thanks again!
  • edited June 2015
    star_boy wrote: »
    So thanks to both Claretta and Greyelf for assistance and helping me come to this realisation! I guess this means that all $styles need to be implemented in the root/origin passage, or they won't work in subsequent passages. Is this a known facet of this kind of style?

    It's a thing with variables in general. They must be set first. If they're not set, they don't exist.

    Because you were starting from the specific passages that came after the initial setting, your story never set those variables.
  • Yeah, I get that now. I didn't realise that the story effectively activates code as it goes, rather than those codes just being implicit across the story once they're set.

    Thanks again for your help!
  • edited June 2015
    That sort of thing wouldn't work because you wouldn't be able to change variables mid story if all variables got applied at story start.
Sign In or Register to comment.