Greetings!
I am looking to compile a "Status Report" after a mission in my game. I have an image with a notepad with various choices, and each of them has a square to check next to it.
I wanted to make sure that the game remembers which checks the user wrote, by raising the appropriate variable linked to it.
Example:
GENDER:
[X] M
[] F
[] N
In this case I want the game to know the user checked the "M" option
Any idea on how to achieve this both visually (to show the actual check) and technically (by remembering the variable).
Thanks!
[SOLVED] How to create interactive checkbox form?
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.
- Bruni Multimedia
- Regular
- Posts: 114
- Joined: Mon May 15, 2017 12:23 pm
- Projects: Yomi Alliance
- Organization: Bruni Multimedia
- itch: brunimultimedia
- Contact:
[SOLVED] How to create interactive checkbox form?
Last edited by Bruni Multimedia on Fri Oct 08, 2021 12:32 pm, edited 1 time in total.
- Ocelot
- Lemma-Class Veteran
- Posts: 2445
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to create interactive checkbox form?
Create an imagebutton with normal idle image being unchecked, and selected being checked. Then use SetVariable as your action. For example, for first button you will use SetVariable("gender", 'm'), second — SetVariable("gender", 'f'), etc.
If variable which is being set already contains that value, then 'selected' image for that button will be shown.
If variable which is being set already contains that value, then 'selected' image for that button will be shown.
< < insert Rick Cook quote here > >
- Bruni Multimedia
- Regular
- Posts: 114
- Joined: Mon May 15, 2017 12:23 pm
- Projects: Yomi Alliance
- Organization: Bruni Multimedia
- itch: brunimultimedia
- Contact:
Re: How to create interactive checkbox form?
Hmm, it doesn't seem to work.
I tried both imagebutton and hotspot (which I would prefer), but it doesn't happen anything when I click upon, and not even if I use the SetVariable directly in in put in the console.
I tried both imagebutton and hotspot (which I would prefer), but it doesn't happen anything when I click upon, and not even if I use the SetVariable directly in in put in the console.
Code: Select all
screen report_1_screen():
imagemap:
ground "gui/exam_screen/medreport_1_unselected.png"
idle "gui/exam_screen/medreport_1_unselected.png"
hover "gui/exam_screen/medreport_1_selected.png"
selected_idle "gui/exam_screen/medreport_1_unselected.png"
selected_hover "gui/exam_screen/medreport_1_selected.png"
hotspot (428, 182, 16, 16) action [SetVariable("rep_abdominal_pain", True)]
imagebutton idle "gui/exam_screen/medreport_1_selected.png" hover "gui/exam_screen/medreport_1_unselected.png" xpos 428 ypos 182 action [SetVariable("rep_abdominal_pain", True), SelectedIf(rep_abdominal_pain== True)]
- Bruni Multimedia
- Regular
- Posts: 114
- Joined: Mon May 15, 2017 12:23 pm
- Projects: Yomi Alliance
- Organization: Bruni Multimedia
- itch: brunimultimedia
- Contact:
Re: How to create interactive checkbox form?
Ok, figured it out with ToggleVariable instead.
This way it works.
Thank you!
Code: Select all
imagemap:
ground "gui/exam_screen/medreport_1_unselected.png"
idle "gui/exam_screen/medreport_1_unselected.png"
hover "gui/exam_screen/medreport_1_selected.png"
selected_idle "gui/exam_screen/medreport_1_selected.png"
selected_hover "gui/exam_screen/medreport_1_unselected.png"
hotspot (428, 182, 16, 16) action ToggleVariable("rep_bloodpress", True, False)
hotspot (568, 182, 17, 16) action ToggleVariable("rep_pulse", True, False)
Thank you!
Re: How to create interactive checkbox form?
Hovered button means you have put the mouse/pointer over it.Bruni Multimedia wrote: ↑Fri Oct 08, 2021 11:48 am Hmm, it doesn't seem to work.
I tried both imagebutton and hotspot (which I would prefer), but it doesn't happen anything when I click upon, and not even if I use the SetVariable directly in in put in the console.
Code: Select all
screen report_1_screen(): imagemap: ground "gui/exam_screen/medreport_1_unselected.png" idle "gui/exam_screen/medreport_1_unselected.png" hover "gui/exam_screen/medreport_1_selected.png" selected_idle "gui/exam_screen/medreport_1_unselected.png" selected_hover "gui/exam_screen/medreport_1_selected.png" hotspot (428, 182, 16, 16) action [SetVariable("rep_abdominal_pain", True)] imagebutton idle "gui/exam_screen/medreport_1_selected.png" hover "gui/exam_screen/medreport_1_unselected.png" xpos 428 ypos 182 action [SetVariable("rep_abdominal_pain", True), SelectedIf(rep_abdominal_pain== True)]
It has nothing to do with "selected". (In this case, "selected" means the variable it sets currently has the same value that the button sets.)
There can be some confusion because when you use only 2 pictures ("idle" and "hover"), hovered image is used for "selected". But it doesn't mean that selected is the same as hovered.
As Ocelot said, you should use
* "selected" picture as the checked checkbox,
* and "not selected" picture as empty checkbox.
But in your imagemap code selected gets "medreport_1_unselected" which is probably wrong.
And hovered idle gets "medreport_1_selected", which is probably wrong too.
Hovered pictures should be highlighted versions of the idle pictures, i.e. not selected as empty checkboxes; selected as checked.
Use 4 pictures (or if two pics then hovered should be the same as idle, but that's less convenient for users).
Likewise, your imagebutton has strange "selected" picture as idle and "unselected" as hover. Correct that and add "selected" with appropriate pictures.
If the problem is solved, please edit the original post and add [SOLVED] to the title.
Who is online
Users browsing this forum: Google [Bot]