hi. nuublet here.

`let x = “PerchanceListA”

[x]`

how do i have it retrieve PerchanceListA instead of a list named x?

I bet it’s something simple like some evaluateScript thing but i don’t know because I’m a noob :)

  • VioneTM
    link
    English
    2
    edit-2
    3 months ago

    It should retrieve the list directly with:

    // Perchance
    PerchanceListA
      a
      b
      c
    ---
    // HTML
    <script>
    let x = PerchanceListA
    // if you want a more 'understandable code'
    // let x = root.PerchanceListA // since all Perchance lists are under the 'root' variable.
    // also with this, you would overwrite the value of list 'x' if you have one.
    </script>
    [x]
    
    • alloOP
      link
      English
      1
      edit-2
      3 months ago

      ty tho maybe i missexplained.

      let xx = "Bright"; alert(root[xx])

      in normal javascript, this would access root.Bright. (interesting about ‘root’. didnt kno that)

      The above is what I’m trying to do. I have the word for the name of the list on a variable. Hao access list from variable?

      I have the variable xx storing the string “Bright”. Hao maek alert say a list item from the list named “Bright”?

      • VioneTM
        link
        English
        23 months ago

        For example on the /minimal generator we have the list:

        listnames
          animal
          adjective
          verb
          location
        

        then on the javascript:

        let x = listnames; // you can also use listnames.selectOne, if you only want it to have a single item and you have to reload the page to randomize it again.
        // This would get a 'random' value from the `listnames`.
        alert((y = x.selectOne) + ':' + root[y]);
        // would give a random item from any of the list 
        
        • alloOP
          link
          English
          13 months ago

          Thank you! the root thing worked. turns out i had a capital letter where there shouldnt have been one and that’s why my list wasn’t being translated from the string correctly. silly and my fault and nothing about language. thanks for the help tho!