Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(+1)

If you have an enum contraption named "enum1" and a button intended for randomizing it, you could give the button a script something like the following:

on click do
 enum1.value:random["\n" split enum1.options]
end

reading the "options" attribute of an enum contraption returns a newline-delimited string of options which can be cracked into a list of options with "split". Given a list, the random[] function will pick a random element, and the enum contraption also permits having its value written via the "value" attribute (automatically constraining writes to within the valid set of options).

If you're doing this sort of thing in many places, you could modify the enum prototype to expose a method for randomizing it, adding a function something like the following to the prototype script:

on get_randomize do
 on randomize do
  set_value[random["\n" split get_options[]]]
 end
end

And then simplify the button script above to

on click do
 enum1.randomize[]
end

Make sense?

This helps so much! thank you! it works, but not...quite!

I tried the solution given, and (splitting the options) it did work! but for some reason *reading* the chosen random has problems?

Here's what I got:

  • A button that goes
on click do
    generate[]
    enum1.value:random["\n" split enum1.options]
end
  • enum1, with a bunch of options, and 
  • A field, called teste1
  • Another field, called StoryFin
  • And the Card script that goes
on generate do
    teste1.text:enum1.value
    StoryFin .text:  teste1.text, "-continued with a lot of other text and stuff"
end

But what's happening on the button click:

Enum1 picks a random option just fine, but DIFFERENT from teste1 and StoryFin. teste1 and stdryfin has the Same text, but always different from enum1

Modifying the prototype also don't quite work. I don't know how to fix this so I'm reaching out again >< hope this isn't a stupid question! The og answer is already such a big help

(1 edit)

in your "on click..." script, you're calling generate[] before you choose a new random value for enum1.

(+1)

ahh thank you!