Deleting choices automatically after they have been chosen
Posted: Wed Jan 16, 2019 7:51 am
I tried to find a solution for my dating sim -style game project that features a conversation system. In the game the player can move around freely and they can return to talk to a character whenever. I wanted the engine to delete choices that have already been selected so that each conversation can only be done once. I couldn't find a working solution anywhere so I came up with my own.
Modify your choice screen like this:
The idea is that you create a list called chosen_choices (or whatever you want to name it):
default chosen_choices = []
Then you check if a choice is in there and if it is, it won't show up in your choice menu. When you make a choice, that choice is added to the chosen_choices list, so the next time you access the conversation menu it'll be deleted.
The problem with this was that if there's a "leave" choice it shouldn't disappear. So the solution is that the game checks if a certain image is included in the choice caption. The image in question is a 10x10 pixels empty square (but you could make it an arrow or something if you want to).
Example of how you would use the menus:
So you just include the image in every choice that you want to never be deleted. It's a bit of a weird solution but it's really simple and works perfectly.
Modify your choice screen like this:
Code: Select all
screen choice(items):
style_prefix "choice"
#using vpgrid ensures there won't be a problem with a varying number of choices; it adds a scroll bar
vpgrid:
cols 1
spacing 10
draggable True
mousewheel True
ymaximum 500
xmaximum 1300
scrollbars "vertical"
side_xalign 0.5
yalign 0.5
#Check if the item caption is in a list you created and if it is, don't show it
for i in items:
if i.caption not in chosen_choices or "{image=images/empty.png}" in i.caption:
if "{image=images/empty.png}" in i.caption:
textbutton i.caption action i.action
else:
textbutton i.caption action i.action, AddToSet(chosen_choices, i.caption)
default chosen_choices = []
Then you check if a choice is in there and if it is, it won't show up in your choice menu. When you make a choice, that choice is added to the chosen_choices list, so the next time you access the conversation menu it'll be deleted.
The problem with this was that if there's a "leave" choice it shouldn't disappear. So the solution is that the game checks if a certain image is included in the choice caption. The image in question is a 10x10 pixels empty square (but you could make it an arrow or something if you want to).
Example of how you would use the menus:
Code: Select all
menu:
"The devil stands next to his hellfire grill."
"Greet him.":
jump greet_satan
"Flirt.":
jump flirt_satan
"Leave {image=images/empty.png}":
"Jumping back to satan station choice"
jump satan_station