The issue is this line in your lists editor:
s = [mob.selectOne]
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).
Here's a fixed example: https://perchance.org/ylx7fmwpql#edit
(This issue has unfortunately been the source of a lot of problems for newbies learning Perchance, so you're not alone in being confused by this!)