Modifying DSE for days of the week[SOLVED]

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
Orison
Newbie
Posts: 19
Joined: Sat Jul 20, 2013 9:32 pm
Projects: Dream No More
Location: Canada... eh.
Contact:

Modifying DSE for days of the week[SOLVED]

#1 Post by Orison »

Hello, I'm a bit new at coding with python/ren'py, so please bear with me >_<"

I modified the DSE framework a little so that it could accommodate days of the week, a week count and seasons. It seemed to work fine at first, but for some reason, Monday kept getting skipped over. Instead of going "Sunday -> Monday -> Tuesday" it just went "Sunday -> Sunday -> Tuesday". The second Sunday also manages to get the day planner even though it should jump to "label weekend" as well as move the week number up by one (so if it was week #0 on the first Sunday, it became week #1 on the second Sunday). All the other day transitions seem to work except for Sunday to Monday.

I'm not exactly sure what I'm doing wrong, so any help would be greatly appreciated c:

Code: Select all

# This is the entry point into the game.
label start:

    # Initialize the default values of some of the variables used in
    # the game.
    $ day = 0
    $ dayname = "undefined"
    $ weekcount = 0
    $ seasoncount = 1


    # Show a default background.
    scene black

    # The script here is run before any event.

    "...Blah blah blah..."

    # We jump to day to start the first day.
    jump day

# This is the label that is jumped to at the start of a day.
label day:

    # Increment the day it is.
    $ day += 1
    
    if day == 1:
        $ dayname = "Monday"
    if day == 2:
        $ dayname = "Tuesday"
    if day == 3:
        $ dayname = "Wednesday"
    if day == 4:
        $ dayname = "Thursday"
    if day == 5:
        $ dayname = "Friday"
    if day == 6:
        $ dayname = "Saturday"
    if (day == 7):
        $ dayname = "Sunday"
    if day == 8:
        $ weekcount += 1
        $ day == 1
    if weekcount == 8:
        $ seasoncount += 1
        $ weekcount == 0
        
    if seasoncount == 1:
        $ season = "Prevernal"
    if seasoncount == 2:
        $ season = "Vernal"
    if seasoncount == 3:
        $ season = "Estival"
    if seasoncount == 4:
        $ season = "Serotinal"    
    if seasoncount == 5:
        $ season = "Autumnal"
    if seasoncount == 6:
        $ season = "Hibernal"
    if seasoncount == 7:
        $ seasoncount == 1

    "It's [dayname]. This is week [weekcount] during the season [season]."

    # Now, we call the day planner, which may set the act variables
    # to new values. We call it with a list of periods that we want
    # to compute the values for.
    if (day == 6) or (day == 7):
        jump weekend
    else:
        call day_planner(["Morning", "Afternoon", "Evening"])

label weekend:
    "It's the weekend, I don't have anything to do! WHOOT!!!"
    call events_end_day
    jump day
Last edited by Orison on Fri Jul 26, 2013 3:50 am, edited 1 time in total.
deviantART[CC BY-SA] Voice Packs!!tumblr (blog)
"Where's the trick, don't have a clue?"
- JubyPhonic's English cover of Yobanashi Deceive

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Modifying DSE for days of the week

#2 Post by Elmiwisa »

Orison wrote:

Code: Select all

    if day == 8:
        $ weekcount += 1
        $ day == 1
This is the problem right here. You put this part of the code at the wrong location.
This code should go immediately after you increment the variable "day" by 1 at the start, so to make the variable "day" wrap around before the part of the code that depend on it being within value from 1 to 7.

User avatar
Orison
Newbie
Posts: 19
Joined: Sat Jul 20, 2013 9:32 pm
Projects: Dream No More
Location: Canada... eh.
Contact:

Re: Modifying DSE for days of the week

#3 Post by Orison »

Elmiwisa wrote:
Orison wrote:

Code: Select all

    if day == 8:
        $ weekcount += 1
        $ day == 1
This is the problem right here. You put this part of the code at the wrong location.
This code should go immediately after you increment the variable "day" by 1 at the start, so to make the variable "day" wrap around before the part of the code that depend on it being within value from 1 to 7.
I'm not sure if it's because it's 3am my time and my brain just made me paste that in the wrong spot or if it's the code itself but that, unfortunately, didn't work.

I tried it like this:

Code: Select all

    # Increment the day it is.
    $ day += 1
    if day == 8:
        $ weekcount += 1
        $ day == 1
And the same error that I was having problems with occurred.
I'm starting to think that Ren'py/Python codes hates me lol.
deviantART[CC BY-SA] Voice Packs!!tumblr (blog)
"Where's the trick, don't have a clue?"
- JubyPhonic's English cover of Yobanashi Deceive

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Modifying DSE for days of the week

#4 Post by Elmiwisa »

Oh right, you also got another problem. Yes that code is in the correct place now, but you made a small but disastrous typo:

This is your current code:
Orison wrote:

Code: Select all

    # Increment the day it is.
    $ day += 1
    if day == 8:
        $ weekcount += 1
        $ day == 1
It should be:

Code: Select all

    # Increment the day it is.
    $ day += 1
    if day == 8:
        $ weekcount += 1
        $ day = 1
Notice the difference yet? (It is the difference between = and ==)

User avatar
Orison
Newbie
Posts: 19
Joined: Sat Jul 20, 2013 9:32 pm
Projects: Dream No More
Location: Canada... eh.
Contact:

Re: Modifying DSE for days of the week

#5 Post by Orison »

Oh my goodness. It was just that equal sign XD

Regardless, thank you so much for your help!!!
deviantART[CC BY-SA] Voice Packs!!tumblr (blog)
"Where's the trick, don't have a clue?"
- JubyPhonic's English cover of Yobanashi Deceive

Post Reply

Who is online

Users browsing this forum: Google [Bot]