[Extension] Array Stats extension

so I showed this and my other extensions on I need help with this but I thought it needed its own topic like a couple other of my extensions so…

NEW EXTENSION ARRAY STATS

for stuff like pokemon

like what you start with is the create stat block fill it will say a string a image and a number (like pokemon name image and start level) and name it (the list input) like Pokemon the change block will change what’s in a stat the get stats from stat with name block will grab what’s in a stat name NOT the category name like Pokemon the stat it self like say Pikachu Bulbasaur Charizard it will return the whole thing like Pokemon|Pikachu|[object object] (the image cant really be put into text) |13

for

or

this will grab the stats of a random entry the plus at index 1 will grab the name or just the first thing in the array 0 gives the category/list name aka pokemon

9 Likes

any thing you guys whatching want to see?

like in a way you have to kinda first put a name as the stat name

update log:

July 18 2026:

there are now

1.better name working

2.you can have more than 3 things

3.and create and change round blocks for variables

2 Likes

update Log:

July 19 2026:

added values category with

1.length of stats with name block that gives back the number (starting at 1) of inputs on that stats array

2.length of list with name block that gives back the length (starting at 1) of the stats in a list

image

3.added a get stat from last random picked stat block that grabs the last stat that the random block picked and grabs whatever is at the index

3 Likes

Wow! This extension is sooooooooo cool! This might seem like an obvious question, but how would I use it in like a RPG game?

do you want a exzample and also do you mean code wise or whats the point of this because

take this for exzample

1.the create stat with name block for list fill the array with whatever you want say how fast they are threre image and there level fill the name of it with that ones name like Pikachu and make the list be like the category like pokemon

2.the get stats from stat with name from list block fill it wit the name of your stat/Pokemon and the list its in like Pokemon it will return the full list something like

Pokemon|Pikachu|fast|{}|13|

or the {} might be [object object] it gets weird with the images

this is

1.length of stat with name for list gives how many things are in the orange array part so most of I have it would give back 3

2.the length of list with name gives back the number of stats in the Pokemon array like so if I had 15 Pokemon with the Pokemon list it would say 15

image

this grabs the last stat that was random picked like if the random block gave back the Pikachu one and you set it to 0 it would be

Pokemon|Pikachu|fast|{}|13|

it would say Pokemon because the whole thing gets split up by the |

so in this case

0 = Pokemon

1 = Pikachu

2 = fast

3 = (the image)

4 = 13

5 = " "

or something like that 5 might be a blank because of the extra | but its fine

let me know if this helps a bit

Yes, can I please get an example (maybe with all the blocks included?)! Also, does anything happen if you create a stat with strength, image, and speed, set it to a list (let’s say, Enemy), and create another stat but with strength, image, speed, and defense and set it to that same list?

uhh i think the way the code works i think it might be fine

1 Like

Update Log:

July 21 2026:

added

1.Amount of stats created it will return the number of stats made to kinda check have a made enough enemy’s and players or whatever

2.Every single stat it will return every single stat in this exzample it would return 1,2,3,4 kinda for saving or debuging or loading

Note though both of these blocks were made because I wanted something to do so if you guys think they are dumb or not needed or you like them let me know

1 Like

anything you @CodaKnight want to see

I think it already covers the basics pretty well! The only things I can think of that would make it even more useful are:

  • A delete/remove stat block.
  • Another delete/remove stat block for removing arrays.
  • A clear all stats block that clears all stats from all arrays or a single array.
  • A check if a stat exists block that returns true/false.
  • A check if a list exists block that returns true/false.
  • Maybe a rename list or rename stat block without having to recreate it or having to change other stats.
  • A block to get all stat names from a list.
  • A get stat count in list block (pretty much my length_of_stats block just with a more descriptive name).
  • An add value to stat block. (Ex: add 100 to stat “Player1”)
  • A set value at index block. (Ex: set index “2” of stat “Player1” to 50)
  • A remove value at index block. (Ex: remove index “3” from stat “Player1”)
  • An insert value at index block. (Ex: insert “25” at index 1 of stat “Player1”)
  • A find stat by value block. (Ex: find stat in list “Players” containing 100)
  • An index of stat block. (Ex: index of stat “Player1” in list “Players”)
  • A remove random stat from list block.
  • A shuffle list block.

Advanced Blocks

  • A copy stat to list block. (Ex: copy stat “Player1” to list “Backup”)
  • A move stat from list to list block (Ex: move stat “Sword” from “Inventory” to “Chest”)
  • A duplicate stat block. (Ex: duplicate stat “Player1” as “Player2”)

Also, I had an implementation idea. In one of my extensions, I ended up using a helper function to find and parse the data once, and then all the other functions reused it. It helped remove a lot of duplicated code and made it easier to maintain. It might be a neat approach here too if you’re interested.

For example, you can do something like:

/**
 * get the stat
*/
//% blockId=findStat
//% block="$name"
//% blockHidden=true shim=TD_ID
//% name.fieldEditor="autocomplete"
//% name.fieldOptions.decompileLiterals=true
//% name.fieldOptions.key="statName"
//% blockHidden=true
export function findStat(list: string, name: string): any[] {
    for (let i = 0; i < StatsArray.length; i++) {
        let row = StatsArray[i]
        let parts = (row[0] as string).split("|")

        if (parts[0] == list && parts[1] == name) {
            return row
        }
    }
    return undefined
}

Then the other blocks can just reuse it instead of looping through StatsArray every time. For example:

//...other annotations for block here
export function length_of_stats(name: string, list: string): number {
    const row = findStat(list, name)
    if (!row) return 0

    const parts = (row[0] as string).split("|")
    return parts.length - 3
}

Then get, change, length, etc. could all just call findStat(...) instead of each looping through

Other than that, I think it’s in a really good place. Nice work! If you need help on understanding further, just ask me.

Side Note: In your Every single Stat in " " list, you spelled list wrong: lsit.

ok then

Update Log:

July 26 2026:

image

ok done added some of the easy-ish ones

they should all work but the two remove and rename I was not sure 100% about but they seem to work so… yeah

Alright thanks. Also, you don’t have to (because I know I gave you a lot of blocks), but are you going to add any other blocks from the ideas I gave you?

maybe depends do you want ot need any more

also @CodaKnight because you like this so much I was wondering do thing any of these blocks are dumb just cause I made some of these and could not think of any use for some of these

Update Log:

July 27 2026:

I changed the get every stat name from list to

image

get every stat from list X at index X so you can grab every of X in the list instead of only grabbing the name

I also removed the other blocks from here and put them in

and also put the rename blocks into

Update Log:

July 27 2026:

image

added a check if list contains stat block

1 Like

Update Log:

July 28 2026:

image

added this find stat block it grabs the first time whatever you put inside the 2 input appears its not perfect but It does kinda work

You honestly don’t have to add all of them, but I think that all those blocks would be helpful.

(Obviously some blocks more helpful than others.)