looping/automatic if statement

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
the0warrior
Newbie
Posts: 8
Joined: Mon Nov 05, 2018 9:41 am
Contact:

looping/automatic if statement

#1 Post by the0warrior »

Hi,

I'm trying to get the game to jump to another label once reach a score by pressing a button

In the screen section, it's done automatically but in any place outside I need to jump to it again to activate

the code

Code: Select all

default rcount = 3

screen e_g:

imagebutton idle "Games/kz.png" xpos 1166 ypos 645 action SetVariable("rcount", rcount - 1)

if rcount == 0:
        image "Games/0.png" xpos 50 ypos 600
        
label eg1:

    if rcount == 0:
        jump worldmap
    scene bg
    with fade
    call screen e_g

When i click on the imagebutton and the counter reach zero the 0.png apper but it dosen't jump to the worldmap I have to re-enter it again to activate

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: looping/automatic if statement

#2 Post by Remix »

Code: Select all


default oxygen = 10

init python:

    def monitor_oxygen():

        if hasattr(store, 'oxygen'):

            if getattr(store, 'oxygen') <= 0.0:

                renpy.jump("asphyxiate")

    # this tells Ren'Py to run the named function whenever a python line is processed 
    config.python_callbacks.append( monitor_oxygen )

label start:

    "... gasp"
    $ oxygen -= 5
    "... gasp"
    $ oxygen -= 5

    "... we never get here"

label asphyxiate:

    "dead"
Frameworks & Scriptlets:

User avatar
the0warrior
Newbie
Posts: 8
Joined: Mon Nov 05, 2018 9:41 am
Contact:

Re: looping/automatic if statement

#3 Post by the0warrior »

Thanks for the fast reply, however it doesn't work

Code: Select all

default rcount = 3

init python:
    def loop():
        if hasattr(store, 'rcount'):

            if getattr(store, 'rcount') <= 0.0:

                renpy.jump("worldmap")

    config.python_callbacks.append( loop )

screen e_g:

imagebutton idle "Games/kz.png" xpos 1166 ypos 645 action SetVariable("rcount", rcount - 1)

if rcount == 0:
        image "Games/0.png" xpos 50 ypos 600
        
label eg1:

    scene bg
    with fade
    call screen e_g
Isn't action SetVariable("rcount", rcount - 1) should work as $ rcount -= 1 ?

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, Ocelot