dropdown bool

ItsColdItsCold Posts: 21Member

hi, im trying to make some sort of document with optionbutton in it.
is there anyway, for example:

if i choose option A on dropdown 1, then dropdown 2 will provide option B, but if i choose option B on dropdown 1 instead, dropdown 2 will provide option C.

trying to add int value on each option doesnt seem to work

Comments

  • ItsColdItsCold Posts: 21Member
    edited January 2019

    hi.
    i uhh, not quite sure how to put it into words but so be it.
    i'm trying to make a dropdown with several choice, here's thecode

    extends Control
    
    export (NodePath) var dropdown_path
    onready var dropdown = get_node(dropdown_path)
    
    func _ready():
        #add items
        add_items()
    
    #add items to dropdown
    func add_items():
        dropdown.add_item("Subjugate")
        dropdown.add_item("Collect")
        dropdown.add_item("Escort")
        dropdown.add_item("Safe Guard")
        get_node(add_items()).print(add_items())
    

    what i want to ask is, i want a certain premade dropdown to appear based on player first choice.
    for example, if player choose to "collect", then a dropdown with a choice of item will appear, but if player choose to "subjugate", then a dropdown of list of enemies will appear instead.
    tried several ways to take the value, but something is amiss.
    Any insight is highly appreciated.
    thank yo.

  • MegalomaniakMegalomaniak Posts: 2,504Admin
    edited May 2019

    Create multiple variants of dropdown 2 and switch them according to selection in dropdown 1?

  • ItsColdItsCold Posts: 21Member

    @Megalomaniak said:
    Create multiple variants of dropdown 2 and switch them according to selection in dropdown 1?

    yes, for example if i want to make a gender lock job on an RPG,
    i tried it to get the id then disable those who arent meet the requirement.
    but i can't use the if inside on_item_selected(id).

  • MegalomaniakMegalomaniak Posts: 2,504Admin

    Care to post your script for an example so we can take a look?

  • ItsColdItsCold Posts: 21Member
    edited May 2019

    was stuck here:

    extends Control
    
    export (NodePath) var dropdownrank_path
    onready var dropdownrank = get_node(dropdownrank_path)
    
    #rank array
    var rank_array = ["A", "B", "C", "D", "E"]
    
    func _ready():
        #connect drodown
        dropdownrank.connect("item_selected", self, "on_item_selected")
    
        #add rank array
        add_rank_items()
    
    func add_rank_items():
        for item in rank_array:
            dropdownrank.add_item("Rank " + item)
    
    func on_item_selected(ID):
        #print(str(dropdownrank.get_item_text(1))) 
        if on_item_selected((1):
            get_item_
    

    someone told me(he's joking but viable i think) that i can instead make the dropdown myself. basically bunch of nodes with label, add variable for each option then set it to true when clicked/called

  • MegalomaniakMegalomaniak Posts: 2,504Admin

    Yes, basically construct your own with a basic state machine to track and switch the item visibility. That is certainly one way to go. The way I have gone in the past.

  • ItsColdItsCold Posts: 21Member

    @Megalomaniak said:
    Yes, basically construct your own with a basic state machine to track and switch the item visibility. That is certainly one way to go. The way I have gone in the past.

    i'd try that, as long as it works =)
    big love sir :3

  • MegalomaniakMegalomaniak Posts: 2,504Admin
    edited August 2019

    Got a flag about duplicate posts/topics, I assume since the other topic was showing up among unanswered questions. Seemed to make sense to merge them. Hope you don't mind.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file