Simple Day/Time System?

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
CellHG
Regular
Posts: 61
Joined: Fri May 05, 2017 3:01 pm
Contact:

Simple Day/Time System?

#1 Post by CellHG »

I'm in need of a little help with something.

I'm by no means an expert with Renpy or Python, I'm very new and still learning the basic's.

iv got a grip on GUI customisation, image maps, money/inventory system and what not, but I don't have a clue how to do this.

I'm basically looking for a day/time system that can be displayed at the top of the screen.

Not IRL day/time, but in-game :P

So, basically it would be on screen and would say like "Tuesday" in 1 box and "16:00" in another, maybe there could be an imagebutton that you click to make time skip 1 hour & also only certain events are triggered at a certain time/day.

Iv searched about but can't really find anything, anyone know of anything in the cookbook?

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Simple Day/Time System?

#2 Post by Milkymalk »

Rough step by step:
1. Make tuples consisting of the days of the week and month names with their respective lengths in days.
2. Make a class with the variables hours, minutes, day, month and year, initiate it with any date.
3. Make a method inside that class, passtime(minutes, hours, days), that advances the date. Make the method check for rollover, i.e. minutes > 59, hours > 23, more days than the month has, months > 12, in that order. If that happens, deduct the maximum number (= roll over) and increase the next higher unit by 1.

I assume since you understand how to make an inventory system (did you see my cookbook entry? ;) ) you should be able to make a time system by following these steps. It's not really difficult once you have a rough idea about the framework.

If you have specific questions, feel free to ask.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Simple Day/Time System?

#3 Post by Remix »

This is a not so simple time/date/event/menu system that allows you to register each event label as you write it.

It might give you an idea of which direction to take.
Frameworks & Scriptlets:

CellHG
Regular
Posts: 61
Joined: Fri May 05, 2017 3:01 pm
Contact:

Re: Simple Day/Time System?

#4 Post by CellHG »

Is there anything like this

https://www.renpy.org/wiki/renpy/doc/co ... ney_System

But for a day and time system?

I'm trying to use this but change it to a day & time system but I'm not quite getting it :P

All I need is days ( Monday to Sunday ) and a time ( 07:00 - 23:00 ) displayed at the top of the screen & when someone clicks something, it changes the time & at a certain time ( 23:00 ) the character has to go to bed.

Iv tried this:

Code: Select all

screen hud: ##displays stuff for the player during normal gameplay
    $day_name = "Sunday"
    if (day%7) == 0:
        $day_name = "Sunday"
    elif (day%7 == 1):
        $day_name = "Monday"
    elif (day%7 == 2):
        $day_name = "Tuesday"
    elif (day%7 == 3):
        $day_name = "Wednesday"
    elif (day%7 == 4):
        $day_name = "Thursday"
    elif (day%7 == 5):
        $day_name = "Friday"
    elif (day%7 == 6):
        $day_name = "Saturday"
        
    $time_name = "Morning"
    if dayTime == 0:
        $time_name = "Morning"
    elif dayTime == 1:
        $time_name = "Afternoon"
    elif dayTime == 2:
        $time_name = "Night"
Which I found on the internet, but I don't know how to display it xD

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Simple Day/Time System?

#5 Post by Milkymalk »

You display a screen with "show screen NAME" and hide it with "hide screen NAME". But that screen you posted shows nothing at all, it just changes some variables. Also, it's a very crude way to do what it does.

I'm all for showing new creators how to do stuff and helping them with things they don't understand, but what you are asking is REALLY easy to do if you follow the steps I gave you earlier and it will greatly benefit you if you at least try to do it yourself. It shouldn't take more than an hour of reading if you are starting from absolute zero and what you learn there is an integral part of coding that you will use again and again.
https://docs.python.org/3/tutorial/classes.html

Give it a try. I feel much better helping someone who at least tried to do something and gets stuck than just giving someone who has no idea a finished script he doesn't understand. It's the thing about giving someone a fish and teaching someone to fish.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

CellHG
Regular
Posts: 61
Joined: Fri May 05, 2017 3:01 pm
Contact:

Re: Simple Day/Time System?

#6 Post by CellHG »

Milkymalk wrote: Thu Jul 27, 2017 3:52 pm You display a screen with "show screen NAME" and hide it with "hide screen NAME". But that screen you posted shows nothing at all, it just changes some variables. Also, it's a very crude way to do what it does.

I'm all for showing new creators how to do stuff and helping them with things they don't understand, but what you are asking is REALLY easy to do if you follow the steps I gave you earlier and it will greatly benefit you if you at least try to do it yourself. It shouldn't take more than an hour of reading if you are starting from absolute zero and what you learn there is an integral part of coding that you will use again and again.
https://docs.python.org/3/tutorial/classes.html

Give it a try. I feel much better helping someone who at least tried to do something and gets stuck than just giving someone who has no idea a finished script he doesn't understand. It's the thing about giving someone a fish and teaching someone to fish.
I'll give it a good go but can't promise out, If I do try and show that iv tried but fail, will you help again? iv got a rough idea on how to do it, but iv no clue what the terminology is, like booleans, class, tumples ect, iv tried searching but I find written things hard to understand, I work better with vocals or diagrams that show an output :P

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Simple Day/Time System?

#7 Post by Milkymalk »

If you find pure docs hard to understand, you can take a look at the cookbook inventory system I mentioned:
viewtopic.php?f=51&t=44730
I explain the use of classes and methods there and give an overview about data structures (which tuples belong to). I was told it was very good, so I can recommend it I guess.

Yes, that's what I meant :) Give it a good try, and once you have a framework that looks like you have a rough idea what you want to do we can work on your misconceptions and correct them.
I think in general, it's better to learn from your own mistakes than from perfect examples. Mostly because your mistakes occupy you for longer :D
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

Post Reply

Who is online

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