[Solved] Value won't change until the game restarts

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
bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

[Solved] Value won't change until the game restarts

#1 Post by bitgraphic »

Hey guys. I'd like to disable Quit confirm at the beggining and turn it back at the main game.
Here is my code.

Code: Select all

init python:
    if not persistent.chose_lang:
        config.quit_action = Quit(confirm=False)
    if persistent.chose_lang:
        config.quit_action = Quit(confirm=True)

init:
    $ persistent.chose_lang = False  

###INTRODUCTION OF THE GAME###

init:
    $ persistent.chose_lang = True

###MAIN GAME###


The code is working, only after the game restarts.
without restarting, the game won't re-configure the quit action.

If anybody knows how to enhance the setting without restarting, please give us your hand.
Last edited by bitgraphic on Mon Nov 11, 2013 10:18 pm, edited 1 time in total.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Value won't change until the game restarts

#2 Post by xavimat »

All the init blocks are executed before the game starts, it doesn't matter where you put them in your code.

The quit action can be done with a button on the screens (Main and Navigation; in the Main Menu the confirm is already disabled, you can configure them in screens.rpy); and with the "close" button of the window (that uses the config.quit_action).

Btw, why do you want to do this? In your code it seems that has something to do with the lang chosen. What do you want to achieve?
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

Re: Value won't change until the game restarts

#3 Post by bitgraphic »

@xavimat
it's kinda complicated.
At the beginning of my game, there is a language and screen resolution picking screen.
at that part, if player clicks x (close widows) it will show up yesno quit prompt that is bigger.

After I tried several method, I found out disabling yesno quit prompt at the beginning and turn it back at the main game is the easiest.

I hope this makes sense

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Value won't change until the game restarts

#4 Post by xavimat »

If I understand correctly, this only is used when somebody opens your game and immediately closes it with the X button (really improbable). Once one language is chosen, there is no problem. How much do you want to work only for this?

Maybe you can simply modify the yesno screen to present a message in all languages only in case of "persistent.chose_lang is None"
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

Re: Value won't change until the game restarts

#5 Post by bitgraphic »

@xavimat
exactly. only it's the language and the screen resolution.
i've already spent hours modifying yesno screen and couldn't make it work.
so if i can't turn off "quit confirm" at the beginning and turn it back at the main game, i can't help but i'd turn it off the entire game.

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Value won't change until the game restarts

#6 Post by Tsapas »

How about that way

Code: Select all

init python:
    quit_trigger = True
    config.quit_action = Quit(confirm=quit_trigger) # maybe (confirm=eval(quit_trigger)) is needed, not tested it. 

label start:
    $ quit_trigger = False  

###INTRODUCTION OF THE GAME###

    $ quit_trigger = True

###MAIN GAME###
You still declare config_quit.action only in init, and attach it's property to a True variable, which only becomes false while in into. No need for persistent flags or anything.

Edit: Not working indeed. Flawed logic on my part.
Last edited by Tsapas on Mon Nov 11, 2013 8:54 am, edited 1 time in total.

bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

Re: Value won't change until the game restarts

#7 Post by bitgraphic »

@Tsapas
I appreciate the code you gave me.
Unfortunately, it doesn't seems to be working on my game.

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: Value won't change until the game restarts

#8 Post by Tsapas »

Alright, I think I found a decent way.

Inside <..>/renpy/common/00gamemenu.rpy it states:

Code: Select all

label _confirm_quit:

    if renpy.has_label("confirm_quit"):
        jump expression "confirm_quit"
    elif renpy.has_label("_compat_confirm_quit"):
        jump expression "_compat_confirm_quit"
    else:
        jump expression "_quit_prompt"
So you can put somewhere in your code

Code: Select all

label confirm_quit:
    if quit_trigger:
        jump expression "_quit_prompt"
    else:
        $ renpy.quit()
and then

Code: Select all

init python:
    quit_trigger = True

label start:
    $ quit_trigger = False  # If false, the game will quit without prompt.

###INTRODUCTION OF THE GAME###

    $ quit_trigger = True # If true, when hitting "X" you'll get a prompt.

###MAIN GAME###
Tested, and working as intended.

bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

Re: Value won't change until the game restarts

#9 Post by bitgraphic »

@Tsapas
It's working!
Thanks buddy, you are awesome.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], trailsiderice