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
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
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
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?
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
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.
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?
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