Generate random strings of letters and numbers

I Want To Make a Variable Called Species Name For A Cell Evo Game SO Every Cell Can Be Diffrent And I Want Letters And Number In It So Its Less Chance To Have Same And Should Look Like This: Random Number: 2J3oR2uYYn So I need How to do it :pleading_face:

3 Likes

First, make a global variable and set its data type to string. I’ve named mine tempString in this case. Then, in every script where you create a cell unit, set tempString to blank, and repeat 10 times setting tempString to itself concatenated with an element at a random index between 0 and 61 of "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". Afterward, you can set the last created unit’s name to tempString. Here’s the example script:

Raw JSON
{
     "triggers": [],
     "conditions": [
          {
               "operator": "==",
               "operandType": "boolean"
          },
          true,
          true
     ],
     "actions": [
          {
               "type": "setVariable",
               "value": "",
               "variableName": "tempString"
          },
          {
               "type": "repeat",
               "count": 10,
               "actions": [
                    {
                         "type": "setVariable",
                         "value": {
                              "function": "concat",
                              "textA": {
                                   "function": "getVariable",
                                   "variableName": "tempString"
                              },
                              "textB": {
                                   "function": "getStringArrayElement",
                                   "number": {
                                        "function": "getRandomNumberBetween",
                                        "min": 0,
                                        "max": 61
                                   },
                                   "string": "\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\""
                              }
                         },
                         "variableName": "tempString",
                         "comment": ""
                    }
               ]
          },
          {
               "type": "setUnitNameLabel",
               "unit": {
                    "function": "getLastCreatedUnit"
               },
               "name": {
                    "function": "getVariable",
                    "variableName": "tempString"
               }
          }
     ],
     "name": "New Script",
     "parent": null,
     "key": "cpELNb0BPB",
     "order": 80
}
1 Like

Thanks! That Is Very Usefull!

1 Like

Oh hi there, I just got unbanned