A button that randomly chooses a label is pretty straightforward. Paste this as the button’s “click” handler:
on click do
# Different texts the button might show
texts:"Click me!","Poke","Nudge","Boop"
# Remove the button's current text from the list,
# so we don't show the same label twice
texts:me.text drop texts
# Pick a random text and apply it to the button.
me.text:random[texts]
end
Cycling through texts is a little more complicated, because we have to figure out where we currently are in the list of options, and what to do when we reach the end:
on click do
# Different texts the button might show
texts:"5","4","3","2","1","Boom!"
# Search through texts looking for
# the one that matches the old button text
oldindex:-1
each t i in texts
# If we have found the old text,
# save its index number as the old index
if me.text=t oldindex:i end
end
# If the old index was the last text...
if oldindex = (count texts)-1
# ...restart the cycle
me.text:first texts
# (you might choose to do something else,
# like go to the next card)
# If the current text wasn't found...
elseif oldindex = -1
# ...start from the beginning
me.text:first texts
# Otherwise just pick the next text.
else
me.text:texts[oldindex+1]
end
end
(A compact and cryptic way to calculate oldindex might be sum (me.text = texts) * range count texts, I don’t know if there’s an even more compact way)