Update: Figure out how to do everything except for making a list of conditions that must be met for the button to show. Specifically for True/False and int values. I don't use strings, but could.
Could I use a function perhaps?
-----------------------
I'm thinking this is a challenge for those with more experience in coding. My initial thought was to create a Python Class that can be access with for loop on a screen. It would create the buttons only if the conditions of the buttons were met, and assign them appropriate number key value. Is this possible? Anyone have an idea of what it might look like?
This is my typical button:
Code: Select all
if settime.now in range (5,17): #settime.now is a python class that determines the time of day. The conditional determines if the time is right to have the button..
textbutton "Rest":# I use a textbutton so the self-voicing can do it's job.
idle_background "gui/task/sleep_idle.png" #A pretty image Custom to each button that is the background
hover_background "gui/task/sleep_hover.png" # A pretty image custom to each button that is the hover_background
action Jump("rest") # The act or action that the button takes.
Code: Select all
if potion_recipes != []: #Conditions checks to see if you have any recipes in your cook book. No time restraints.
textbutton "Cookbook":
idle_background "gui/task/grimoire_idle.png"
hover_background "gui/task/grimoire_hover.png"
action Jump("craft_recipe")
Code: Select all
if unlocked_clinic == True and settime.now in range(6,18): #Checks the time and if the clinic is unlocked.
frame:
textbutton "Clinic" action Jump("clinic")
Code: Select all
if day == 21 or day == 7:
if unlocked_market:
if settime.now > 5 and settime.now < 15:
if WentMarketSell == False:
textbutton "Market":
idle_background "gui/task/market_idle.png"
hover_background "gui/task/market_hover.png"
action Jump("market")
name = name
conditions = conditions
act = act
page = page
I think I can get away with the idle_background and hover_backgrounds if I use something like this:
Code: Select all
hover_background "gui/task/[item.name]_hover.png"
Am I on the right track? I'd figure I put them into a list when I create the buttons. They'd all be created at the beginning of the game behind the scenes. I'm just curious if Ren'py would know what to do with the information if I wrote it something like this:
Code: Select all
for buttons in main_menu_list:
textbutton buttons.name:
idle_background "gui/task/[buttons.name].png"
hover_background "gui/task/[buttons.name].png"
key str(i) action buttons.act
key "K_KP" + str(i) action buttons.act
for n, i in enumerate(items, 1): # n would be the number starting from 1
if n<10:
key "K_KP" + str(n) action i.action
key str(n) action i.action