Is it possible to make a label playable only once a day?

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
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Is it possible to make a label playable only once a day?

#1 Post by Nanahs »

I created a "special menu" on my game.
I was thinking of adding an option (button) called like "Read Today's luck", something like this.
When you clicked, you would play a label that would show you a message.
Something like "It's a good day to send flowers to Anna." I'd make many different labels and the game choose them randomly, so there would be different messages.

That's easy to make.

The thing is: I wanted this label playble only once a day.
When you tried clicking there again, a message like "You've already read today's luck. Come back tomorrow." would appear.

Only in the next day, after midnight, the person you be able to read another "luck message" by clicking there.

It is possible to make on Renpy?
I don't remember reading about a code like this at all.
This is just something that came to my mind now.

ps: for a newbie, I always want to to difficult things. Sorry :oops: :lol:

Thanks.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Is it possible to make a label playable only once a day?

#2 Post by Imperf3kt »

I am assuming you mean in real time?

While I don't have time to write the code, I have an idea about the logic.

Create a screen with the python date time module.
Assign the current day, month and year to a variable when the screen is shown.
Make a button in that screen that checks the time variable, sets a different time variable then checks if the two variables are the same.
If they aren't, give the player their reward, and increment the day variable by one


I had a better idea, but since I am writing this during my free moments at work, I got busy and lost thought of it.
Last edited by Imperf3kt on Mon Jan 21, 2019 9:49 pm, edited 1 time in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: Is it possible to make a label playable only once a day?

#3 Post by deltadidirac »

I'm completly new with renpy, but perhaps this example I create could give you an idea and you could write better than me.

general variable msg assignement:

Code: Select all

default readluckval = 0
variable day assignement:

Code: Select all

default dayval = 1  ##1= monday, 2= tuesday , ecc..
example of the engine msg

Code: Select all

label  engine_luck:
          if readluckval ==0 and dayval ==1:
               jump yourmsgengine  ### here you call your casual msg
          elif readreadluckval ==1 and dayval ==1
                jump messagereaded   ### here you call you msg that you have already read the day msg
          elif readluckval ==0 and dayval ==2:
          	jump yourmsgengine  ### here you call your casual msg
          elif readluckval ==1 and dayval ==2:
          	jump messagereaded   ### here you call you msg that you have already read the day msg
          elif ..... #### continue for all the 7 days
in your system engine timer, you must write at the end and change of every day
this operation to reset the readluckval:

Code: Select all

$ readluckval *=0
all this it's only a suggest, I'm sure all can be write better , perhaps using some screen and not labels

see you


User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to make a label playable only once a day?

#5 Post by Nanahs »

Thank you SO much guys! I'll give it a try :)

recreation
Regular
Posts: 52
Joined: Sun Jul 01, 2018 8:32 am
Contact:

Re: Is it possible to make a label playable only once a day?

#6 Post by recreation »

I'm not a pro but the simpliest thing I could think of if you DON'T want to make this depending on realtime, is you could simply add a variable that stores if the messages was read and reset it every day:

Code: Select all

if message_read==0:
	"Lucky Message"
	$ message_read = 1
else:
	"You've already read today's luck. Come back tomorrow."

label next_day:
	$ message_read = 0

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: Is it possible to make a label playable only once a day?

#7 Post by Nanahs »

recreation wrote: Wed Jan 23, 2019 8:12 am I'm not a pro but the simpliest thing I could think of if you DON'T want to make this depending on realtime, is you could simply add a variable that stores if the messages was read and reset it every day:

Code: Select all

if message_read==0:
	"Lucky Message"
	$ message_read = 1
else:
	"You've already read today's luck. Come back tomorrow."

label next_day:
	$ message_read = 0
I want to make it based on real time.
But I'm going to test this one too, to see what it would look like.
Thanks.

Post Reply

Who is online

Users browsing this forum: Google [Bot], piinkpuddiin