In-game time and a couple more questions.

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
Ingword
Newbie
Posts: 20
Joined: Tue May 23, 2017 2:16 pm
Contact:

In-game time and a couple more questions.

#1 Post by Ingword »

Hello! I started my acquaintance with Ren'Py immediately on a real project, but since I do not have any development experience, so many questions arise.

1. How can I create in-game time? I need to get a display of the in-game time at the top of the screen in the center in the format 00:00 (the day of the in-game week), and when you click on the "Wait" button the time increased by 1 hour, and inside the game, there were certain events (about them later).

2. How to tie certain events to the in-game time? For example, the characters have a daily routine: 7:00 - goes to school, 12:00 lunch, 18:00 watching TV. Accordingly, this character should be in the location where the action takes place (7:00 - own room, 12:00 - dining room, 18:00 - living room). And when we move between these locations, we must meet these characters.

3. How to make the game expect the player to act as a click on a specific place in the image or select an action in the menu? Now when you click on any place (except the menu), the game continues the narrative of the story that I wrote.

4. How correctly to issue the code (to develop structure) for repetitive actions? For example, if the player does not influence the plot in any way (not to choose any action), then the game will take hours, days, weeks, and the characters will perform their usual actions (breakfast, lunch, training, leisure, sleep).

Thank you!

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: In-game time and a couple more questions.

#2 Post by xavimat »

Lots of questions that can be adressed in many ways. It's difficult to answer.

Pleasse check the cookbook section. this thread has some things that you are asking: viewtopic.php?f=51&t=22393
I'm asuming you have read carefully the quickstart doc: http://www.renpy.org/doc/html/quickstart.html

Some quick answers (that will make no sense before knowing some renpy basics):

1. You need variables and screens with buttons for that
2. Use variables (time, locations) and "if/elif/else" statements
3. again, screens. You can have a big transparent button that fills the entire screen behind the other buttons
4. Use variables and if/elif/else to detect what to do. And then, use jump or call to labels
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)

Ingword
Newbie
Posts: 20
Joined: Tue May 23, 2017 2:16 pm
Contact:

Re: In-game time and a couple more questions.

#3 Post by Ingword »

Hi, xavimat! Thank you for attention! I want to clarify...

1. I set some variables for time:

Code: Select all

$ hours = ["00:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"]
How do I go from the variable "00:00" to "06:00", for example?

2. Am I moving in the right direction?

Code: Select all

$ time = "00:00"
$ day = "Monday"
$ location = "My room"

label my_room:
    player "What do we do?"
    call moving
   
label moving:
    menu:
        "Go to sister's room"
            jump sisters_room
        "Relax..."
            pass

label sisters_room:
    $ location = "Sister's room"
    if $ time == "07:00" and $ day == "Monday" and $ location == "Sister's room":
        show sister
        sis "I need go to school. Have some question?"

    elif $ time == "12:00" and $ day == "Monday" and $ location == "Sister's room":
        show empty room
        player "Hmm... Sister probably in school."
        call moving

    elif $ time == "18:00" and $ day == "Monday" and $ location == "Sister's room":
        show empty room
        player "My sister is having supper, I can find her in the living room."
        call moving

    else:
        show empty room
        player "Wait... Where's my sister?"
3. So... I need to create a transparent button with a size in the resolution of the game, clicking on it will not cause anything, but on top of it, there are buttons that will bring up dialog boxes, etc.?

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: In-game time and a couple more questions.

#4 Post by xavimat »

1. Many ways to do it. This could be a solution:

Code: Select all

default hours = ["00:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"]
default hour = "06:00"
default tim = 1  # <-- don't use a variable named 'time' because could be a name already used in python
default day = 1

label start:
    show screen show_time
    "click 1"
    call pass_time
    "click 2"
    call pass_time(3)
    "click 3"
    call pass_time(87)
    "click 4"
    call pass_time
    "click 5"
    return

screen show_time():
    vbox:
        align (1.0, 0.0)
        text hour
        text str(day)

label pass_time(hh=1):
    $ tim += hh
    while tim > 18:
        $ tim -= 18
        $ day += 1
    $ hour = hours[tim]
    return
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)

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: In-game time and a couple more questions.

#5 Post by xavimat »

2. Some issues here. Let's start with the minor ones:
- Don't use $ outside labels or screens, use default instead to initialize the variables before a game starts:

Code: Select all

default tim = "00:00"
default day = "Monday"
default location = "My room"
- don't use $ inside the if/elif statements:

Code: Select all

if time == "07:00" and day == "Monday" and location == "Sister's room":
The $ doesn't belong to the name of the variable (it's not php), but tells Ren'Py that there is a one-line python code. So use it only inside labels or screens to manipulate variables or other python stuff.
- There is no need to check if location == "Sister's room" the line after you have told Ren'Py that $ location = "Sister's room"

And now the major issue: you need to study carefully the flow of your code. It's all wrong.
- There are some call moving but there is no return in that label, so, the calls will stack one over another and never be returned.
- The label moving offers a menu with two options, one is ok (jumps to sisters_room) the other does nothing (pass), so, where do you thing the flow of your code will go next? To the following lines, that is: label sisters_room: you need a return at the end of label moving (or inside the second menu option, instead of pass)

If you want a central label from where go to the other labels and always return to it, use "call" in the central label (in your example it would be "label moving") and use return instead of calling it again when the other labels have finished. I hope i make sense.
You can study the part of the doc about it: https://www.renpy.org/doc/html/label.html
Last edited by xavimat on Sat May 27, 2017 3:32 am, edited 1 time in total.
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)

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: In-game time and a couple more questions.

#6 Post by xavimat »

3. It depends if you call or show your screen.
call screen screenname: presents the screen and waits for the player to do something with it. If the screen has no action Return(), it will be stuck forever. When the screen Returns(), it disappears.
show screen screenname: presents the screen but doesn't stop the flow of your code. It can be useful to present some info to the player, but usually you don't expect to interact with it. This screen will never disappear if you don't tell it to (hide screen screenname).

So, in your example, I'd call a screen with buttons in it, and the main transparent button will have an action Return().
But, again, there are many ways of doing the same thing, it depends on how you want your game to be.
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)

Ingword
Newbie
Posts: 20
Joined: Tue May 23, 2017 2:16 pm
Contact:

Re: In-game time and a couple more questions.

#7 Post by Ingword »

xavimat, thank you so much! Before your answer, I found some other solutions that are very similar to yours. But I took the use of the 'if/else', rather than 'while' in my functions :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]