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
This means that every time you use s it'll select a new random item from mob. The reason for that is because you've made s equal to [mob.selectOne] instead of mob.selectOne. The square brackets around it effectively make it "dynamically fetched" each time you access s.
(Aside: Also note that the lists editor isn't "executed" each time you click your generate button. It's not a list of instructions which get executed line-by-line. The square blocks in the HTML editor on the other hand do get executed line-by-line each time you click the generate button. Think of the code in your list editor as a "static" structure which can be used by the square blocks in your HTML editor.)
So you need to add [s = mob.selectOne, ""] in a place where it'll get "executed" with every generate button click, so a new s is generated with each click, but it stays the same when executing all of the other square blocks that come after it.
So you could add this line before [output] in your HTML editor:
[s = mob.selectOne, ""]
Each time your "Generate" button is clicked, the update() function is called, and that causes all the square blocks in the HTML code to be executed from top to bottom. So it ensures that we've randomly selected a mob item and put it in the s variable before the output list is executed (which uses the s variable).
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 : ""]