{code} A game for seven days

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
nclm
Newbie
Posts: 1
Joined: Sun Nov 03, 2013 4:42 pm
Contact:

{code} A game for seven days

#1 Post by nclm »

Hi :)

Last winter, I began learning Ren'Py and started a game I never continued since. While I still plan to go back to it one day, I ran into the folder today and thought the base script.rpy code may perhaps be interesting if someone wants to do a game using the same concept.

The idea for the game is: it takes place in one week. You have to play each day to complete it.

Maybe you have to get an item each day to build something, or meet one character every morning to reach the end of the story? There's a different scenario for each day of the week, and the player must play all of them (not necessarily in order, if you miss the Tuesday, you can play the following Tuesday).

My original story was about someone arriving in a new town, moving in an empty flat, and trying to find a piece of furniture each day to fill the apartment, meeting new people on the way — but I'm curious to see what other stories people can come up with using this principle.

Here is the base script.rpy without stories. Just a framework with date detection, completed/non-completed days switching, and place-holder sentences about “items”.

Code: Select all

## script.rpy for a game in seven days
## original base code by nicolas (probablement.net)

## TIME
init -1 python:
    import time
    time = time.localtime(time.time()).tm_wday
    days = ['Monday',    # 0
            'Tuesday',   # 1    
            'Wednesday', # 2
            'Thursday',  # 3
            'Friday',    # 4
            'Saturday',  # 5
            'Sunday']    # 6

## START
label start:
    
    # What time is it?
    $day = time
    $dayname = days[time]
    
    # Check if game already completed.
    if persistent.all_items:
        centered "I already got all the items."
        return
    
    # Shared beginning.
    centered "[dayname]"
    "I woke up."
    
    # First time explaination
    if not persistent.first_exp:
        "I need to get 7 items"
        $persistent.first_exp = True
        
    jump gotoday

## GO TO DAY
label gotoday:
    
    # Jump to daily script.
    if   day == 0:
        jump mon_start    
    elif day == 1:
        jump tue_start
    elif day == 2:
        jump wed_start
    elif day == 3:
        jump thu_start
    elif day == 4:
        jump fri_start
    elif day == 5:
        jump sat_start
    elif day == 6:
        jump sun_start
    else:
        "Out of time!"
        return

## 0 MONDAY
label mon_start:
    # Check past
    if   persistent.mon_item:
        "I already got the Monday item."
        jump closing
    elif persistent.mon_started:
        "Last Monday, I didn't found anything."

    # Flag day as started
    $persistent.mon_started = True
        
    "This Monday, I'll get the Monday item."
    
    menu:
        "Get Monday item":
            $persistent.mon_item = True
            "You got the Monday item!"
            jump closing
            
            
## 1 TUESDAY
label tue_start:
    # Check past
    if   persistent.tue_item:
        "I already got the Tuesday item."
        jump closing
    elif persistent.tue_started:
        "Last Tuesday, I didn't found anything."

    # Flag day as started
    $persistent.tue_started = True
        
    "This Tuesday, I'll get the Tuesday item."
    
    menu:
        "Get Tuesday item":
            $persistent.tue_item = True
            "You got the Tuesday item!"
            jump closing
            
            

## 2 WEDNESDAY
label wed_start:
    # Check past
    if   persistent.wed_item:
        "I already got the Wednesday item."
        jump closing
    elif persistent.wed_started:
        "Last Wednesday, I didn't found anything."

    # Flag day as started
    $persistent.wed_started = True
        
    "This Wednesday, I'll get the Wednesday item."
    
    menu:
        "Get Wednesday item":
            $persistent.wed_item = True
            "You got the Wednesday item!"
            jump closing
            
            

## 3 THURSDAY
label thu_start:
    # Check past
    if   persistent.thu_item:
        "I already got the Thurday item."
        jump closing
    elif persistent.thu_started:
        "Last Thurday, I didn't found anything."

    # Flag day as started
    $persistent.thu_started = True
        
    "This Thurday, I'll get the Thurday item."
    
    menu:
        "Get Thurday item":
            $persistent.thu_item = True
            "You got the Thurday item!"
            jump closing
            
            

## 4 FRIDAY
label fri_start:
    # Check past
    if   persistent.fri_item:
        "I already got the Friday item."
        jump closing
    elif persistent.fri_started:
        "Last Friday, I didn't found anything."

    # Flag day as started
    $persistent.fri_started = True
        
    "This Friday, I'll get the Friday item."
    
    menu:
        "Get Friday item":
            $persistent.fri_item = True
            "You got the Friday item!"
            jump closing
            
            

## 5 SATURDAY
label sat_start:
    # Check past
    if   persistent.sat_item:
        "I already got the Saturday item."
        jump closing
    elif persistent.sat_started:
        "Last Saturday, I didn't found anything."

    # Flag day as started
    $persistent.sat_started = True
        
    "This Saturday, I'll get the Saturday item."
    
    menu:
        "Get Saturday item":
            $persistent.sat_item = True
            "You got the Saturday item!"
            jump closing
            
            
    
## 6 SUNDAY
label sun_start:
    # Check past
    if   persistent.sun_item:
        "I already got the Sunday item."
        jump closing
    elif persistent.sun_started:
        "Last Sunday, I didn't found anything."

    # Flag day as started
    $persistent.sun_started = True
        
    "This Sunday, I'll get the Sunday item."
    
    menu:
        "Get Sunday item":
            $persistent.sun_item = True
            "You got the Sunday item!"
            jump closing


## END
label closing:
    
    if persistent.mon_item and persistent.tue_item and persistent.wed_item and persistent.thu_item and persistent.fri_item and persistent.sat_item and persistent.sun_item:
        $persistent.all_items = True
        centered "I got all the 7 items!"

    else:
        centered "See you tommorow!"
                  
    return

Have a nice evening :)

Best,
~ nicolas
Attachments
script-agameforsevendays.rpy
(5.08 KiB) Downloaded 364 times

User avatar
erinism
Regular
Posts: 51
Joined: Mon Apr 30, 2012 11:05 pm
Location: Perth Australia
Contact:

Re: {code} A game for seven days

#2 Post by erinism »

This is amazing.

Seriously, thank you.

User avatar
SilverSnow
Regular
Posts: 182
Joined: Tue Aug 27, 2013 6:28 am
Completed: Bus Stop, Before the Tale, White Book Complete Volume, See You, The Raven
Projects: Secrets...
Tumblr: stchematelier
itch: st-chem-atelier
Location: Edge of Black Hole
Discord: SHatsuyuki#1452
Contact:

Re: {code} A game for seven days

#3 Post by SilverSnow »

This could be very useful, thank you for sharing! ^^
Image

Post Reply

Who is online

Users browsing this forum: No registered users