Run the equivalent of window hide / window auto from within a function

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
Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Run the equivalent of window hide / window auto from within a function

#1 Post by Errilhl »

Okay. So, I have the following function:

Code: Select all

init -100 python:
    def statschangeNotify(a,f,p=False):
        # a = attribute to change
        # f = negative or positive value representing the change
        # p = longer pause or not

        # This function have no reason to be used by anything else, so keep it internal to "statschangeNotify".
        def _generateText( what, who, f ):
            if f < 0:
                action = "deteriorated"
            else:
                action = "increased" if what in [ "dom", "aro", "cor", "att" ] else "improved"

            # Each variables in "format" by their order. So {0} = who, {1} = action, {2} = absolute value of "f".
            if what == "rel":
                return "Your relationship with {0} has {1} by {2}".format( who, action, abs( f ) )
            elif what == "dom":
                return "Your dominance over {0} has {1} by {2}".format( who, action, abs( f ) )
            elif what == "aro":
                return "{0}'s arousal has {1} by {2}".format( who, action, abs( f ) )
            elif what == "cor":
                return "{0}'s corruption has {1} by {2}".format( who, action, abs( f ) )
            elif what == "att":
                return "{0}'s attitude has {1} by {2}".format( who, action, abs( f ) )
            elif what == "anal":
                return "{0}'s acceptance of anal sex has {1} by {2}".format( who, action, abs( f ) )
            elif what == "pussy":
                return "{0}'s acceptance of regular sex has {1} by {2}".format( who, action, abs( f ) )
            elif what == "bj":
                return "{0}'s acceptance of giving blowjobs has {1} by {2}".format( who, action, abs( f ) )
            return "Oop's something really weird happen !"

        # A single line for all the possible variables, as well as both positive and negative values.
        if a == "mc_b":
            setattr( store, a, min(getattr( store, a) + f,store.mc_b_max))
        else:
            setattr( store, a, getattr( store, a ) + f )

        if a[:2] in [ "fM", "nK", "fS", "sN" ]:
            if a[:2] in [ "fM", "fS" ]:
                name = "yourshort"+a[:2]
                if a[3:] in [ "aro","cor","att","anal","pussy","bj" ]:
                    name = "yourshortCaps"+a[:2]
            else:
                name = a[:2]
            text = _generateText( a[3:], str( getattr( store, name ) ), f )
        elif a == "mc_b":
            if f < 0:
                text = "Your motorcycle build decreased by {0}".format( abs( f ) )
            else:
                text = "Your motorcycle build increased by {0}".format( abs( f ) )
        elif a == "punishment_late":
            text = "You've gotten a mark for being late. Current amount is {0}. If you get more than 5 marks, you will get in trouble".format( store.punishment_late )
        else:
            text = "Oop's something really weird happen !"

        if not "deteriorated" in text:
            renpy.notify((text))
        else:
            renpy.notify((text,"decrease"))

        if p:
            renpy.pause(.6)
        else:
            renpy.pause(.1)
It works perfectly, but due to... something, in Renpy, that for some reason shows an empty textbox with renpy.pause(), I need to be able to hide window sometimes. I figured

Code: Select all

window hide
renpy.pause(.6)
window auto
wouldn't work, so I tried

Code: Select all

Hide(window)
renpy.pause(.6)
Show(window)
Which, of course, didn't work either, because "window" isn't declared. Okay... so... how, exactly, do I do this from within a function?

The function is called in script.rpy like this:

Code: Select all

$ statschangeNotify("nK_aro",1.5)
Also - "window hide" works fine, but it hides the whole interface. If I only want to hide the textbox, nothing else...?
Currently working on: Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#2 Post by Remix »

I think you need to change config.window to the value wanted. It might be .preference or ._preference though.
Alternatively, maybe Show / Hide( "say" ) as the screen is called 'say'
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#3 Post by Errilhl »

Can I somehow do that in "regular" renpy as well? Ie in script.rpy? Hide specific parts of the window when / if needed? (well, I know I can, I was just wondering how I, for instance, can hide the textbox (and only the textbox) at specific times).
Currently working on: Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#4 Post by Remix »

From memory the say window is a bit of a pain to hide and show, simply because when you come to Show("say") it again after the hiding you have to pass the who and what again... so you would need to globally store the previous who and what ready for when you wanted them (yeah, they probably exist somewhere in the history, just I haven't delved far enough to see).

The easier alternative is using ShowMenu("screen_name") which pretty much hides everything and then have a button in screen_name that simply evokes the action Return(). If your overlay icons/things are held in an overlay screen, you could still use this method by just adding 'use overlay_screen_name' within the showmenu screen. $ renpy.hide_screen('say') should suffice to just hide the dialogue+name bit inline... just gets peskier trying to bring it back
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#5 Post by Errilhl »

Typical :)

These things, to me, are things that would be very nice to have default actions for in Ren'Py. It should not be hard, or demand otherwise "hacking" it to work - it should just be a simple switch. Maybe I'm weird, but I would think that
1. having an empty textbox showing during pause-execution is... not ideal
2. having access to other items on screen (like menus and such) would be common also during pause
3. hiding and showing the textbox should be a simple boolean switch (as it is for most other stuff, like character portraits and such)

Oh, well, I will figure out a working solution, but it's not on the top of my priority list atm :)
Currently working on: Image

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#6 Post by Errilhl »

Hm... I'm considering whether or not it would be doable to have a separate textbox for these instances, basically transparent (hence, hidden) and match that with an empty "what"... Need to test that out.
Currently working on: Image

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#7 Post by Remix »

You could also try dabbling with using self defined layers and omitting them from the config.menu_clear_layers setting. Should allow using ShowMenu and Return while still keeping an overlay... might need minor tweaks if the overlay needs hiding during real game menu though
Frameworks & Scriptlets:

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#8 Post by Errilhl »

Yeah, that might also be doable. I will have to look into the different ways of setting up this, because it will probably come in handy some time. Currenly, the way it is now works, for now, I can live with that for the alpha-phase of the game. Currently, I need more game-content, not fiddling with relatively unimportant game-caltrops :D
Currently working on: Image

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#9 Post by philat »

https://www.renpy.org/doc/html/dialogue ... management

_preferences.show_empty_window = False

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#10 Post by xela »

Like what we're doing? Support us at:
Image

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#11 Post by Errilhl »

philat wrote: Wed Nov 29, 2017 8:43 pm https://www.renpy.org/doc/html/dialogue ... management

_preferences.show_empty_window = False
That's not even mentioned anywhere in that link? Where does that statement go?
Currently working on: Image

philat
Eileen-Class Veteran
Posts: 1900
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#12 Post by philat »

Dialogue window management is subject to the "show empty window" Preference(). If the preference is disabled, the statements above have no effect.
Last line of the block I linked. It's a preference, just like any other. Just change it in your script anywhere.

Errilhl
Regular
Posts: 164
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS
Deviantart: studioerrilhl
Github: studioerrilhl
Contact:

Re: Run the equivalent of window hide / window auto from within a function

#13 Post by Errilhl »

Okay - that actually seems to be working. Works the same as my mediocre modification using a transparent text-box for those events (empty say)
Currently working on: Image

Post Reply

Who is online

Users browsing this forum: Google [Bot], piinkpuddiin