Capitalization Always On Text

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Capitalization Always On Text

#1 Post by Obscura »

If I want to use the capitalized/upper-case version of a font, is there a way to do that in Renpy?

For example, if I have this bit of code:

Code: Select all

$ timestamp = Character (None,
        what_font="fonts/specialfont.ttf",
        what_size=50,
        what_xalign=0.5,
        window_xalign=0.5,
        window_yalign=0.60,
        )
Every time I want the day of a week to show up on the center of the screen (i.e., Saturday), I use:

Code: Select all

timestamp ("SATURDAY")
The goal: I'd like the screen to show "SATURDAY" regardless of whether I used timestamp ("Saturday") or timestamp ("SATURDAY").

The reason for this convoluted question? I switch around fonts fairly often, and I'd like to be able to use caps automatically for certain fonts when I need to do so, instead of changing every instance of timestamp in .rpy.

Thanks for any assistance!
Coming Out On Top - An Adult Gay Dating Sim
website

Crazy Li
Regular
Posts: 113
Joined: Fri Jan 03, 2014 3:35 pm
Contact:

Re: Capitalization Always On Text

#2 Post by Crazy Li »

Maybe timestamp.upper() ?

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Capitalization Always On Text

#3 Post by Obscura »

Hmmm. I tried putting that in, and got:

Code: Select all

While running game code:
  File "game/script.rpy", line 850, in script
AttributeError: 'ADVCharacter' object has no attribute 'upper'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Program Files\renpy-6.15.7-sdk\renpy\execution.py", line 288, in run
    node.execute()
  File "C:\Program Files\renpy-6.15.7-sdk\renpy\ast.py", line 433, in execute
    who = renpy.python.py_eval(self.who)
  File "C:\Program Files\renpy-6.15.7-sdk\renpy\python.py", line 1331, in py_eval
    return eval(py_compile(source, 'eval'), globals, locals)
  File "<none>", line 1, in <module>
AttributeError: 'ADVCharacter' object has no attribute 'upper'

Windows-7-6.1.7601-SP1
Ren'Py 6.15.7.374
Thanks for the suggestion, though!
Coming Out On Top - An Adult Gay Dating Sim
website

Unin
Regular
Posts: 54
Joined: Wed Sep 01, 2010 8:08 pm
Location: Florida
Contact:

Re: Capitalization Always On Text

#4 Post by Unin »

This is a rather inelegant way of doing it, but if this issue is having it capitalize for certain fonts, couldn't you just make a copy of your fonts, suffix them specialfontCaps.ttf, and edit the font file so that both cases use the capital lettering?


Edit: as for upper(), timestamp is a character, while upper() is a function for strings. depending on how characters hand strings, you could make a function within character to take an input string and output thatstring.upper()
maybe see http://stackoverflow.com/questions/3524 ... e-a-string

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Capitalization Always On Text

#5 Post by nyaatrap »

Code: Select all

screen say:
  text what.upper()
An object "what" is string, so you can manipulate it like the above.
You can't use text tags when you do this bacause {w} becomes {W}, e.t.c.

Post Reply

Who is online

Users browsing this forum: piinkpuddiin, Rhapsy