How to make a Simple Form?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AlpphaMonkey

Hello, a total Noob to Godot, but it was incredibly easy to pick, a Lil bit stuck… I need help, I have a form, Two line edits (Nickname and Name), a drop down (Male or female) , and an OK button to continue to the next scene, how do I go about saving the data entered in the lineEdit and Drop down into a String Variable so I can use it anywhere, an example :

Func ok_button_pressed():
If dropdown == male:
 setbbcode("hello man" + Name + "you have a cool name")
Elif dropdown == female :
 Setbbcode("hello girl" + Name + "you have a cool name")
:bust_in_silhouette: Reply From: Bartosz

for line edits you use property text e.g. nickname = nickname_line_edit.text
for drop downs if you’re using OptionButton first get selected item id gender_option_button.get_selected_id() and retrieve its index inside popup menu e.g. gender_option_butten.get_popup().get_item_index(item_id) and finally retrieve its text e.g. gender_option_butten.get_popup().get_item_text(item_index)

Thanks for your reply. Should I add this to an auto load so I can access them based on a condition any where in my project? And how do I go about adding it, give me a sample if you were the one making such form. I am Very new to gdscript. It’s a text based game, if that helps.

AlpphaMonkey | 2018-03-27 20:17

You could add it to AutoLoad or you could create separate node for storing player information and gameplay progress as a top scene. I’ve created specially for your simple demo showing how you could generate and parse simple forms.(It was a little to big to post it here)

Bartosz | 2018-03-27 22:21

I am using Godot 2.1.5… I hate to be of bother, thanks for taking your time to do that, I am very sure it would be of help to someone. Sigh. I’ll just try to wrap my head around your comment and see how far I go. I’ll try to figure it out. Thanks a lot.

AlpphaMonkey | 2018-03-28 15:40

I just checked the codes In the file. They are really helpful. Thanks again. Yay!

AlpphaMonkey | 2018-03-28 15:42