How to make a color picker block

Hello! :grin:

I tried adding a color picker block that lets you choose a color without having to input a number ...

Like this:

expectations

However, this is what I got:

reality

Here's my code ...
    /**
     * Color picker
     */
    //% shim=TD_ID
    //% blockId=fancy_text__colorPicker
    //% block="$color"
    //% color.shadow=colorindexpicker
    //% group=Create
    //% weight=0
    //% help=github:arcade-fancy-text/docs/set-color
    export function __colorPicker(color?: number): number {
        return color;
    }

I should mention that I’m using the “Fancy Text Sprite” extension as a template for this because I don’t want to make a brand new extension just for this block :sweat_smile:

2 Likes

:grin:

(Back up your code before trying to import this extension because last I remembered it caused a couple of issues for some reason even though it’s such a simple extension…no clue why…)


You can find more extensions like ColorBlock on https://awesome-arcade.vercel.app/ :grin: (shameless self promotion)

4 Likes

Thanks! Although funny thing, when I re-opened my project today my color block worked!
I think all I needed to do was close and re-open the project :sweat_smile:

The “Awesome arcade” website is handy though so I’ll be saving that :grin:

1 Like