Way to check amount of space/characters?

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
Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Way to check amount of space/characters?

#1 Post by Melkoshi »

So i'm making my battle ui

I have name plates with only a set amount of Text room. What I am looking for is a character count type function. so that instead of the letters going off the space. it'll go "..." at the end of the character limit i set.
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Way to check amount of space/characters?

#2 Post by Aleema »

So easy you'll kick yourself:

Code: Select all

        if len(name) > 25:
            name = name[:20] + "..."
Checks for the length of the string Name, if greater than 25 chars, reduce it to 20 chars and add an ellipsis. W's and other characters are pretty wide, so account for three of the widest characters when choosing your short length.

This is pure Python, so you should familiarize yourself with string operations.

Melkoshi
Regular
Posts: 156
Joined: Tue Jun 02, 2009 8:56 pm
Projects: Jewels of Sytinane
Location: U.s.a.
Contact:

Re: Way to check amount of space/characters?

#3 Post by Melkoshi »

knew I should of looked on the python bit. XD

thanks <3 that was too easy.
--- My DeviantArt.
Game in Progress for demo-teaser:
story(script) = 45%
sprites = 100%
programming(interface) = 35%
CGs = 0%
Backgrounds = 5%
Music/sound = 0%

Post Reply

Who is online

Users browsing this forum: No registered users