I’m trying to create a character generator, and I’m currently stuck on an issue. I’m trying to assign s to a single value picked from the list of possible species, so I can then use that value later for the species displayed and for some species-specific traits. I feel like this should be possible, but I’m also not super knowledgeable in perchance

  • BluePower
    link
    fedilink
    English
    arrow-up
    2
    ·
    14 days ago

    You can use the shorthand exp ? if_true : if_false notation chained together instead of the if ... else notations. It’s specially used for conditional inline value returns.

    [s == "Wolf" ? wolf_gene : s == "Cat" ? cat_gene : s == "Fox" ? fox_gene : ""]
    

    You can also do like this as well:

    [({"Wolf": wolf_gene, "Cat": cat_gene, "Fox": fox_gene})[s]]