Last night, I decided to make a city name generator because another website I would frequently visit got knocked offline. However, once I add {import:78435dca8c2d1750fe1affd02ef2886f} (78435dca8c2d1750fe1affd02ef2886f is the file name) to the [list] folder of the code it outputs a message in the bottom right corner (see image), and it does nothing else. It lets me tap on the green box but it doesn’t do anything. Just putting all entries in will just give me an error saying the code is too big. The problem may be that all of the name entries take up six megabytes, but I really don’t know at this point. Any help appreciated.

  • @spottieOP
    link
    English
    15 days ago

    I see where you’re going, as what I meant to upload was https://user-uploads.perchance.org/file/78435dca8c2d1750fe1affd02ef2886f.txt. Not that experienced at code, and I have no idea on how to modify the [list] section so that it makes the importer download from the file on the uploads site.

    • VioneTM
      link
      English
      2
      edit-2
      5 days ago

      You can add this function on the lists editor:

      url = https://user-uploads.perchance.org/file/78435dca8c2d1750fe1affd02ef2886f.txt
      
      list
        [getTxtList(url)]
      
      getTxtList(url) =>
        if (!url.endsWith('.txt')) return;
        let fileName = url.split('/file/')[1].replace('.txt', '');
        if (!root[fileName]) {
          const request = new XMLHttpRequest();
          request.open("GET", url, false);
          request.send(null);
          let list = request.responseText
          list = list.split(/[\n\r]/).filter(a => a)
          root[fileName] = list
        }
        return root[fileName]
      
      • @spottieOP
        link
        English
        3
        edit-2
        5 days ago

        Thanks for all of the help, I’ve got it to run smooth now.

        • VioneTM
          link
          English
          24 days ago

          Glad to help!

        • VioneTM
          link
          English
          14 days ago

          Btw, it seems to load/hang a little bit each time the button to randomize is clicked, so I’ve made an adjustment with the code, so it loads and selects an item faster, so just change the following lines:

          getTxtList(url) =>
            if (!url.endsWith('.txt')) return;
            let fileName = url.split('/file/')[1].replace('.txt', '');
            if (!root[fileName]) {
              const request = new XMLHttpRequest();
              request.open("GET", url, false);
              request.send(null);
              let list = request.responseText
              list = list.split(/[\n\r]/).filter(a => a)
              // changes
              root[fileName] = {}
              let maxPerSubset = 5000
              for(i = 0; i < Math.ceil(list.length / maxPerSubset); i++) {
                root[fileName][i] = [... list.slice((0 + i) * maxPerSubset, (1 + i) * maxPerSubset)]
              }
            }
            return root[fileName][Object.keys(root[fileName]).selectOne] // change