silly question

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
Matt_D
Regular
Posts: 77
Joined: Tue Oct 31, 2006 3:28 pm
Contact:

silly question

#1 Post by Matt_D » Fri Nov 10, 2006 12:12 pm

I'm sure this is either a: impossible (or just way to difficult for me to think about) or b: really easy and asked a million times.

However the search forum facility has given me little luck accursed beastie.

I don't like repeating myself, it's annoying and wasteful, I'll do it if needs must but if there is a way out ooo baby I wanna take it

I'm gonna be using this alot

Code: Select all

    show expression Text('-=1=-',size=50,yalign=0.5, xalign=0.5, drop_shadow=(2,2)) as text
    with dissolve
    with Pause(1)
    
    hide text
    with dissolve
except replace the '-=1=-' with any number of other short things.

is there a way I can just make a function to save my ctrl+c ctrl+v??

Adorya
Miko-Class Veteran
Posts: 541
Joined: Fri Aug 18, 2006 4:51 pm
Contact:

#2 Post by Adorya » Fri Nov 10, 2006 1:45 pm

Nvm misunderstood the question :p

You could try to declare an int then increment it, but it would still remain the same, you have to type the increment...or with third party software it is possible to create incremented text (Excel macro, etc...)

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: silly question

#3 Post by Jake » Fri Nov 10, 2006 4:24 pm

Matt_D wrote:I'm sure this is either a: impossible (or just way to difficult for me to think about) or b: really easy and asked a million times.
I'm possibly just missing something really obvious, but I don't think it's either of those, really. I think it's more likely c: possible, but requiring some understanding of i) how Ren'Py works past the ren'py-script and ii) Python. Maybe that comes under the first option...

My understanding of both of those things comes under the heading of 'working, but flawed', so I'm probably missing something really obvious that would make this easier, but I came up with the following which at least works...

Put this code inside an init block:

Code: Select all

    python:
        
        renpy.store.centreTextValue = "-"
        
        def centreText(st, at):
            return Text(renpy.store.centreTextValue,size=50,yalign=0.5, xalign=0.5, drop_shadow=(2,2)), None
    
        def showCentreText(text, pauseTime = 1.0):
            renpy.store.centreTextValue = text
            renpy.show('centreTextDisplayable')
            renpy.with(dissolve)
            renpy.pause(pauseTime)
            renpy.hide('centreTextDisplayable')
            renpy.with(dissolve)
        
    image centreTextDisplayable = DynamicDisplayable(centreText)
Then call it in your script like this:

Code: Select all

    e "Hey, let's have some text appearing right in the middle of the screen!"
    
    $ showCentreText("Some Text")

    e "Yeah, just like that!"
    
    $ showCentreText("Just Like That", 5.0)
    
    e "... Okay, that one lasted too long."
I'm sure I've directly 'show'ed a Displayable before, which would make this a lot simpler and less hacky, but I can't remember how...
Server error: user 'Jake' not found

Matt_D
Regular
Posts: 77
Joined: Tue Oct 31, 2006 3:28 pm
Contact:

#4 Post by Matt_D » Fri Nov 10, 2006 5:23 pm

Brilliant, and even better I see how and why it works woohoo. I don't mind if it's hacky it works just fine. Cheers.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#5 Post by PyTom » Fri Nov 10, 2006 6:11 pm

You can use the 'what' parameter to show to eliminate the need for a DynamicDisplayable:

Code: Select all

init:
  python:   
        def showCentreText(text, pauseTime = 1.0):
            renpy.show('centreTextDisplayable', what=Text(renpy.store.centreTextValue,size=50,yalign=0.5, xalign=0.5, drop_shadow=(2,2)))
            renpy.with(dissolve)
            renpy.pause(pauseTime)
            renpy.hide('centreTextDisplayable')
            renpy.with(dissolve)
Other then that, everything looks good.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#6 Post by Jake » Fri Nov 10, 2006 9:30 pm

PyTom wrote:You can use the 'what' parameter to show to eliminate the need for a DynamicDisplayable:

Code: Select all

...
You mean:

Code: Select all

       def showCentreText(text, pauseTime = 1.0): 
            renpy.show('centreTextDisplayable', what=Text(text,size=50,yalign=0.5, xalign=0.5, drop_shadow=(2,2))) 
            renpy.with(dissolve) 
            renpy.pause(pauseTime) 
            renpy.hide('centreTextDisplayable') 
            renpy.with(dissolve)
(renpy.store.centreTextValue isn't set; first param to Text() should be the param passed into the function)

But yeah, that seems to work. I could have sworn I'd tried exactly that earlier and been told "no image with the name 'centreTextDisplayable' could be found". I guess I must have been doing something wrong... I concluded from that that I'd need to have a labelled displayable to work with, hence using the DynamicDisplayable. Not having to pass the text via a global is certainly a lot less hacky! ;-)
Server error: user 'Jake' not found

Post Reply

Who is online

Users browsing this forum: No registered users