How to double use custom styles ? [SugarCube 2]

0 votes
asked Oct 9 by Seyru (560 points)

This evening has been full of wonders...

Does anybody knows how to double use custom styles ?
I'd love to do something like : 

 

@@#Processing; color:red; Processing...@@

 

So that what's in "#Processing" would be "Processing..." written in red ! 
But so far, I didn't manage to...

Thanks a lot for your help.

And have a good evening.

2 Answers

+1 vote
answered Oct 10 by TheMadExile (15,950 points)
selected Oct 10 by Seyru
 
Best answer

That should work.  You do not, generally, add spaces though.  For example: 

@@#Processing;color:red;Processing...@@

commented Oct 10 by Seyru (560 points)
Damn, you're right once again. The space was causing the issue.
Thanks a lot !
0 votes
answered Oct 10 by Chapel (27,570 points)
If you mean what I think you do, just move your style rules to your story Stylesheet.

For example (the toolbar isn't displaying for me, so I can't use the code tags):

#processing {
    color : red;
}

Then, in passage:

@@#processing;Processing...@@

Any text or element given the '#processing' id will now be red. Note that if you want multiple elements in the same passage to have red text, you'll need to use a class, which is prefixed by a dot rather than a hash:

.processing {} in css

@@.processing;@@ in passage
commented Oct 10 by Seyru (560 points)

That's interesting as well, I had no idea you could do that. 
But then, is it possible to change the content of the story stylesheet from within the story ? I was aiming to do something of that kind : 

 @@#Connect; color:red;Connecting...@@

<<timed 2s>>

        <<replace '#Connect'>>

@@color:green;Connected !@@ 

         <</replace>> 

<</timed>>


<<timed 4s>>

              <<remove '#Connect'>>

<</timed>>
 

commented Oct 10 by Chapel (27,570 points)
Well, what you should probably do is define classes for your styles then add and remove those as needed, rather than creating another span inside the original span just to change the text color.

That said, what you're doing works, to its probably not a big deal.

Anyway, I think I just misread the question, so ignore me if TME got you the answer you were looking for.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.
...