Help with DSE GUI coding
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.
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.
Help with DSE GUI coding
I'm having trouble writing a GUI for the game i'm designing. If I can get past this, it should be okay.
I have figured out the basics I think, but still have some questions. For certain:
1. I found a thread for making a calander, which solves one question, but how does one keep track of days and display them as "June 6th" as opposed to "Day 23"
2. How can i force a particular part of day to be unchangable/unselectable on various days? FE: School in morning slot? Can it work both with existing choices normally available and choices not normally available?
3. Can you add/remove choices depending on circumstances as to what the player can chose?
4. Is it possible to bypass the gui on various days leaving the player with no choices, or have events that fire before the day begins (after night block fires)
5. Can you disable saving/loading except in the GUI menu?
Thanks.
I have figured out the basics I think, but still have some questions. For certain:
1. I found a thread for making a calander, which solves one question, but how does one keep track of days and display them as "June 6th" as opposed to "Day 23"
2. How can i force a particular part of day to be unchangable/unselectable on various days? FE: School in morning slot? Can it work both with existing choices normally available and choices not normally available?
3. Can you add/remove choices depending on circumstances as to what the player can chose?
4. Is it possible to bypass the gui on various days leaving the player with no choices, or have events that fire before the day begins (after night block fires)
5. Can you disable saving/loading except in the GUI menu?
Thanks.
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
- PyTom
- Ren'Py Creator
- Posts: 16097
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Help with DSE GUI coding
Yes, look at the code in main.rpy that is run for each period of the day. You can add more periods in a similar manner... and note that the day planner is more-or-less independent from the event_dispatcher.Jinnai wrote: 4. Is it possible to bypass the gui on various days leaving the player with no choices, or have events that fire before the day begins (after night block fires)
The rest of what you want is possible, but would require a rewrite of the day planner. I'd be willing to do that if you can show to me a mostly complete game, one that's likely to be finished.
Adding more periods is the only thing that needs to be done early in the development process, which is why I mention it here... ask if you have a problem getting it working.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: Help with DSE GUI coding
If you're not going to have a particularly large number of days, it's probably simplest to just type up the day number -> day name relations into a dictionary, such as:Jinnai wrote: 1. I found a thread for making a calander, which solves one question, but how does one keep track of days and display them as "June 6th" as opposed to "Day 23"
Code: Select all
$ daynamedict = {1:'May 15th', 2:'May 16th', 3:'May 17th }
Code: Select all
$ dayname = daynamedict[day]
"It's %(dayname)s."
Code: Select all
init:
python:
import datetime
def ordinalth(n): # from Simon Willison
t = 'th st nd rd th th th th th th'.split()
if n % 100 in (11,12,13):
return '%dth' % n
return str(n) + t[n % 10]
def getDate(day):
basedate = datetime.date(2006,5,14) # The day before day 1
adjdate = basedate + datetime.timedelta(days=day)
return adjdate.strftime("%B ") + ordinalth(adjdate.day)
Code: Select all
$ dayname = getDate(day)
"It's %(dayname)s."
Re: Help with DSE GUI coding
No, I don't think I need that. I don't intend as far as I can envision to change the number of periods available, just at certain points make certain choices unchangable in certain periods for the player, similar to what is done in True Love with going to school.PyTom wrote:Adding more periods is the only thing that needs to be done early in the development process, which is why I mention it here... ask if you have a problem getting it working.
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
Re: Help with DSE GUI coding
This is actually what I'm looking for moreof as I plan to make this an ongoing game without any defined end (probably). Ifso, how do you add a february 29 ever 4 years (since I don't have defined years I'd just be numbering Year 1, Year 2) or by the player's age.shaja wrote:Otherwise, a more general solution is to use the python datetime module.Jinnai wrote: 1. I found a thread for making a calander, which solves one question, but how does one keep track of days and display them as "June 6th" as opposed to "Day 23"Code: Select all
init: python: import datetime def ordinalth(n): # from Simon Willison t = 'th st nd rd th th th th th th'.split() if n % 100 in (11,12,13): return '%dth' % n return str(n) + t[n % 10] def getDate(day): basedate = datetime.date(2006,5,14) # The day before day 1 adjdate = basedate + datetime.timedelta(days=day) return adjdate.strftime("%B ") + ordinalth(adjdate.day)
Code: Select all
$ dayname = getDate(day) "It's %(dayname)s."
And actually while i'm at it...is it possible to make a code to have the character pick his age and use it ingame for an event?
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
Re: Help with DSE GUI coding
The datetime functions account for leap years automatically.Jinnai wrote:This is actually what I'm looking for moreof as I plan to make this an ongoing game without any defined end (probably). Ifso, how do you add a february 29 ever 4 years (since I don't have defined years I'd just be numbering Year 1, Year 2) or by the player's age.
It would also be easy to get a year to print, or to change the getDate function to return (for example) "June 12th, 2006".
As simple as putting menus up to pick year, month and day, I'd imagine.Jinnai wrote:And actually while i'm at it...is it possible to make a code to have the character pick his age and use it ingame for an event?
Regarding your wanting to have specific choices available on specific days, PyTom actually made it easy to add some code for that into his framework.
For example, in day_planner.rpy, rename the dp_period_acts dictionary to dp_period_default_acts, and add a new dictionary dp_period_special_acts like so:
Code: Select all
# A map from the period names to a list of the activities
# available for that period. This may be conputed before
# each call to day_planner. Each entry is a tuple, where
# the first element is the name shown to the user, and the
# second is the name assigned to the variable for that
# period.
# shaja: renamed dp_period_acts to dp_period_default_acts
dp_period_default_acts = {
'Morning': [
( 'Attend Class', "class" ),
( 'Cut Class', "cut"),
],
'Afternoon': [
( 'Study', "study" ),
( 'Hang Out', "hang" ),
],
'Evening' : [
( 'Exercise', "exercise" ),
( 'Play Games', "play" ),
],
}
dp_period_special_acts = {
# For day 3, require class in the morning
3: { 'Morning':[('School required', "class")],
'Afternoon':[( 'Study', "study" ), ( 'Hang Out', "hang" )],
'Evening':[( 'Exercise', "exercise" ), ( 'Play Games', "play" )]
}
}
Code: Select all
# Here, we want to set up some of the default values for the
# day planner. In a more complicated game, we would probably
# want to add and remove choices from the dp_ variables
# (especially dp_period_acts) to reflect the choices the
# user has available to him.
# shaja: get the daily planner acts for the day, use defaults if today's day
# number isn't in the dictionary
$ dp_period_acts = dp_period_special_acts.get(day, dp_period_default_acts)
$ morning_act = None
$ afternoon_act = None
$ evening_act = None
It's certainly possible to make the code more complex so that things work exactly as you envision them, but you get the idea, anyway.
Thanks. I think once I can get the GUI figured out overall the rest will be simple for me. I've done scripting for other games (Europa Universalis 2 and Crusader Kings if anyone knows them) so once I get a GUI done, the rest seems easy.
Except i'd need an artist or have all my images based on rips. I might be able to do backgrounds myself, but without a tablet...
Except i'd need an artist or have all my images based on rips. I might be able to do backgrounds myself, but without a tablet...
)'.'(
Power of Sqyishyness!!
Power of Sqyishyness!!
Who is online
Users browsing this forum: Bing [Bot], VictoriaCox