Help please!

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
Posts: 2
Joined: Sat Apr 07, 2012 6:07 am
Location: Philippines

Help please!

#1 Post by TenriSama » Wed Apr 11, 2012 7:13 am

Hi! I need help with something. How do I make it so that you have to finish certain tasks within a time period?

For example, you have to finish 6 tasks, each taking a day or two, within 3 weeks? (Not counting weekends)

I'm a total newbie at this, so some help would be greatly appreciated.

User avatar
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm

Time Constraints for Tasks

#2 Post by Valmoer » Wed Apr 11, 2012 12:22 pm

First, if I dare put a few words of advice in a friendly manner :
1) Be more precise in your title : "Help me" doesn't tell us what your problem is, and that's the important point of your help plea. Here, "Adding time constraints to tasks" would tell your would-be helpers what you need.

2) Be more precise, period. Your message gives us but the barest of facts, so it is complicated to know your precise needs. A code snippet of what you've done yet would help place your problem in its context (Plus, it would show without a doubt that you've tried)

3) Don't be afraid to read the quickstart manual, the Reference Manual, the Tutorials , and (after understanding the rest) the Cookbook. They're full of precious answers and useful tips!

Now, correct me if I'm wrong, but I've understood this from your message (capitals placed for emphasis):
*) The Player has Tasks to complete.
*) Each of these Tasks take Time (mesured in days) to complete.
**) You can't work on Weekends.
*) You want either to Check that, at a precise Date, all the tasks have been done.

Well, here is code that will do that. It is tested and works, but it is ugly in its design and you shouldn't copy it as is - just try to understand how it works and build your own solution from it.

Code: Select all

    $ task1_done = False
    $ task2_done = False
    $ task3_done = False
    $ task4_done = False
    $ task5_done = False
    $ task6_done = False
    $ days = 0
    $ is_slacking_off = False
    while (days < 21) :
        $ printedDays = days + 1
        if (days % 7 < 5) :
                "Day %(printedDays)s : What do you want to do ?"
                "I'll do task 1. (2 Days)" if not task1_done :
                    $ task1_done = True
                    $ day_to_work = 2
                "I'll do task 2. (1 Day)" if not task2_done :
                    $ task2_done = True
                    $ day_to_work = 1
                "I'll do task 3. (1 Day)" if not task3_done :
                    $ task3_done = True
                    $ day_to_work = 1
                "I'll do task 4. (2 Days)" if not task4_done :
                    $ task4_done = True
                    $ day_to_work = 2
                "I'll do task 5. (1 Day)" if not task5_done :
                    $ task5_done = True
                    $ day_to_work = 1
                "I'll do task 6. (1 Day)" if not task6_done :
                    $ task6_done = True
                    $ day_to_work = 1
                "I won't do anything" :
                    $ is_slacking_off = True
                    $ day_to_work = 0
            if day_to_work == 2 :
                if days % 7 == 4 :
                    "This task was long, so I had to split it between Friday and Monday, pausing during the weekend."
                    $ days += 4
                else :
                    "This task was so long, it took me two days!"
                    $ days += 2
            else :
                if is_slacking_off :
                    "Being lazy is awesome!"
                    $ is_slacking_off = False
                else :
                    "It took me a day to do... whatever I was doing."
                $ days += 1
        else :
            "It's the week end, I will take it easy."
            $ days +=2
    if task1_done and task2_done and task3_done and task4_done and task5_done and task6_done :
        "Yay! I done it all!"
    else :
        "Oh, no, I forgot to do something!"
Don't be afraid to ask for more help, though. Not for more code - I just wanted to put you on the correct path - but advice will always be given :wink:

Post Reply

Who is online

Users browsing this forum: Autumnotopia, HSelf, xxmissarichanxx