#is there a way i can detect button selection regardless of the order?

1 messages · Page 1 of 1 (latest)

fair hawk
#

You would need a array with the possible values, then loop over that array to add the buttons

#

Then you can do```js
const trail = arr[response.selection];

rain lodge
#
function trai(player) {
    const actions = [] 
    const trailsa = new ActionFormData()
        .title("§eTrails")
        .body("All trails bought will appear here.");

    if (trails.trail0 === 1) {
        trailsa.button("§cFire Trail");
        actions.push(() => {
           player.sendMessage("§dFire Trail was equipped.");
           player.playSound("armor.equip_diamond")
           trailequip = 1;
        }) 
    }

    if (trails.trail1 === 1) {
        trailsa.button("§gTotem Trail");
         actions.push(() => {
            player.sendMessage("§aTotem Trail was equipped.");
            trailequip = 2;
         }) 
    }

    trailsa.show(player).then(data => {
        if (data.canceled) return;
        actions[data.selection]();
    });
}