Hello! I’m newb in coding and I don’t know if my question and explanation will make sense but here we go.. (sorry for my bad english btw ; u ; )
I'm using toggleVariable button, which acts like a scheduler. You select what you want to do that day and it will remember and do something according to what you selected. My problem is, how do I code it to do it like that? (If you have different way of coding that produce same result and easier to understand let me know too ; u ; I just use toggleViarable since I can toggle the selection off/on ahahaha)
For example, if I select [Hunt], I’ll go hunt but the outcome will be random, either I get a deer, a rabbit or nothing. If left unselected, it will only say that 'you didn’t hunt that day'. Points will also be deducted from hunger points if you selected it.
Then on the next screen it will tell the result if I get a deer, a rabbit or nothing or I didn’t hunt that day. Then the same thing repeat the next day.
Here’s a drawing since I don’t know how to code it ; 7 ;
Here, I select [Hunt(-2hp)] and [Travel(-2hp)], leaving [Scavage] unselected.
Here's the result of my choice. +2 for food if you caught an animal. +1hp and +1 day at the end of the day.
Then it will repeat again, with points and days updated.
I also what to know if it’s possible to trigger an event on certain day; like if you reached [DAY 10] a wild bear will try to break-in to your house. Then the game goes on until you encounter another day-event or ending.
How to make toggleVariable work?
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.
How to make toggleVariable work?
Last edited by akio93 on Sat Sep 12, 2020 11:40 am, edited 2 times in total.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: How to make toggleVariable work?
I kinda don't understand what's the question in this. The title says it yeah, but the thread content just explains the things that you did already so I don't know how to help about it since you got it working already. You can always refer to the actions doc about the ToggleVariable action to learn more about it. https://www.renpy.org/doc/html/screen_a ... leVariable
I think I can help with this one. For cases like this, where the player is given a lot of options and you'll produce a certain action from that event, then it might be better to use a list and store all the options picked by the player.(If you have different way of coding that produce same result and easier to understand let me know too ; u ; I just use toggleViarable since I can toggle the selection off/on ahahaha)
Code: Select all
default picked_activities = []
default activities = ("Hunt", "Scavenge", "Travel")
screen activity_selector():
vbox:
for activity in activities:
textbutton activity:
action If(
activity in picked_activities,
Function(picked_activities.remove, activity), # true action
Function(picked_activities.append, activity) # false action
)
selected (activity in picked_activities)
textbutton "DONE" action Return()
label start:
call activity_selector
return
label activity_selector:
call screen activity_selector
if "Hunt" in picked_activities:
call hunt
if "Scavenge" in picked_activities:
call scavenge
if "travel" in picked_activities:
call travel
return
label hunt:
"I'm hunting now"
return
label scavenge:
"I'm scavenging now"
return
label travel:
"I'm travelling now"
return
I think you can try to make if checks / conditions in the label that dictates the new day and jump into event label that you made like if day == 10 etc.I also what to know if it’s possible to trigger an event on certain day; like if you reached [DAY 10] a wild bear will try to break-in to your house. Then the game goes on until you encounter another day-event or ending.
Re: How to make toggleVariable work?
Hello! thank you very much for showing me another coding option, I'll try to study it and make it work
oh I think I forgot to write my question..
Basically, I was asking how to code it, I can make the buttons but making the buttons do something(like the picture above) stumped me ahaha
sorry for not explaining it clearly.. orz
Who is online
Users browsing this forum: Majestic-12 [Bot], piinkpuddiin, snotwurm