Forcing a label call in screen

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
Norezza
Newbie
Posts: 19
Joined: Tue Oct 17, 2017 7:51 pm
Contact:

Forcing a label call in screen

#1 Post by Norezza »

Hi guys! I'm trying to force people to go back to the room when the time passes 23:00.

What I've been doing so far is to have an imagebutton covering the entire screen at that time, but it's incredibly buggy.

I've tried adding $renpy.jump('tooLate'), $renpy.call('tooLate'), but none of it is working.
Of course, a simple jump (label) would not work, as it's a screen.

Is there a handy way of forcing a label jump at a certain position inside a screen? I'm using my quick menu screen to do it.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Forcing a label call in screen

#2 Post by Imperf3kt »

I think (without seeing how you are doing what you are doing) you may want to use a timer.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Forcing a label call in screen

#3 Post by trooper6 »

What sort of clock are you using to keep time? How are you adding time to the clock?
Depending on the answers to those questions, you may not need some giant screen at all, by the way.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Norezza
Newbie
Posts: 19
Joined: Tue Oct 17, 2017 7:51 pm
Contact:

Re: Forcing a label call in screen

#4 Post by Norezza »

It's a simple variable that I'm using. I increment the "tod" variable when I do certain things as the character

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Forcing a label call in screen

#5 Post by trooper6 »

That is pretty easily done with a callback function. I have to go to work and won’t be back home until late tonight, but when I get home I’ll put up some code for you. Quick question, when you get the time out do you want to jump to the label (you aren’t coming back), or call the label (you return after the scene)?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Norezza
Newbie
Posts: 19
Joined: Tue Oct 17, 2017 7:51 pm
Contact:

Re: Forcing a label call in screen

#6 Post by Norezza »

I want it to stay there, the label is small, and jumps to the room.

Code: Select all

label tooLate:
    $loc = "room"
    c "{i}It's getting late. I should get back to my room{/i}"
    jump room
is the label I want to jump to.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Forcing a label call in screen

#7 Post by Enchant00 »

trooper6 wrote: Mon Mar 26, 2018 8:23 am That is pretty easily done with a callback function. I have to go to work and won’t be back home until late tonight, but when I get home I’ll put up some code for you. Quick question, when you get the time out do you want to jump to the label (you aren’t coming back), or call the label (you return after the scene)?
As trooper6 said what you are looking for can be achieved through callback. Put this code somewhere at the start of your script or wherever.

Code: Select all


default tod = 0  #seconds

init python:
    time_check = False
    
    def late_call:
        if time_check and tod >= 82800 # roughly translates to 23 hours:
            time_check = False
            renpy.jump('Toolate') 
            
    config.python_callbacks.append(late_call)
    
label start:
    # Day start
    time_check = True
    # things player does as time increments
    #sample : player eats dinner
    $ tod += 82800

label tooLate:  # Should auto jump to this when the tod reaches 23 hours
    $loc = "room"
    c "{i}It's getting late. I should get back to my room{/i}"
    jump room
        	    
The thing is though this is rather a crude way of writing it. Ideally if I knew how your clock time functions then I could adjust this program to work since chances are it might not even function correctly. At the moment, I just assumed you were using a seconds based increment system. If you are using an hour based system then change the callback to as such

Code: Select all


default tod = 0  #hours

init python:
    time_check = False
    
    def late_callback:
        if time_check and tod >= 23 # in hours:
            time_check = False
            renpy.jump('Toolate') 
            
    config.python_callbacks.append(late_call)

Norezza
Newbie
Posts: 19
Joined: Tue Oct 17, 2017 7:51 pm
Contact:

Re: Forcing a label call in screen

#8 Post by Norezza »

I can show how the clock works, it's extremely simple, basically just a variable that gets incremented on certain events. It's only whole hour increments.

Code: Select all

        "Relax":
            "You relax in the common area for an hour."
            $tod += 1
            jump hall2
On every load of scene this is called

Code: Select all

screen quick_menu():
    zorder 100
    $timeLoc()
    $timeandDay()
    $whichDay()
timeLoc is simply a function to place someone at the correct spot (a ton of if statements)
timeAndDay is this

Code: Select all

    def timeandDay():
        global tod, day, dayNr
        if tod  ==  24:
            tod = 0
            reset()
            day+=1
            dayNr+=1
            if day > 6:
                day = 0
        return

Code: Select all

    def whichDay():
        global week, today, day
        today = week[day]
        return
I have a feeling that this isn't a very smart way of making the encounters and time work, but for now it works, at least.


It seems as though the deciding factor, so to speak, is the line
"config.python_callbacks.append(late_call)"

Which I believe would fix this?

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Forcing a label call in screen

#9 Post by Enchant00 »

Yeah more or less what's important is that your functions work :lol: There are some timebased scripts in the cookbook likewise the daily planner or dse I believe also has the same mechanic and maybe someone here could help better optimize your code. As for callback the config.python_callbacks.append(late_call) is the line in order to add events or callback functions so that renpy could recognize your callback. Assuming I haven't screwed up anywhere in my code then the hour based callback should work for you. Just don't forget to set the time_check before start of the day else it would return an error. If you have any problems just msg up.

Post Reply

Who is online

Users browsing this forum: Google [Bot], voluorem