pxt-microbit icon indicating copy to clipboard operation
pxt-microbit copied to clipboard

want to make global var default of a block, but compiler says no

Open tballmsft opened this issue 6 months ago • 1 comments

in microsoft/pxt-arcadeshield we have a global variable screen: Bitmap. I want screen to be the default variable used in blocks, which is accomplished using the bmap.defl line below

//% fixedInstances decompileIndirectFixedInstances
interface Bitmap {
    /**
     * Fill a rectangle
     */
    //% helper=imageFillRect blockNamespace="bitmaps" inlineInputMode="inline" group="Drawing"
    //% block="fill rectangle in %bmap=variables_get at x %x y %y width %w height %h %c=colorindexpicker"
    //% help=github:microsoft/pxt-arcadeshield/reference/bitmaps/bitmap/fill-rect
    //% bmap.defl=screen
    fillRect(x: number, y: number, w: number, h: number, c: color): void;

However, the compiler thinks I am trying to add a new variable screen and does renaming, so I get:

let screen2: Bitmap = null
screen2.fillRect(0, 0, 0, 0, 0)

instead of what I want

screen.fillRect(0, 0, 0, 0, 0)

tballmsft avatar Aug 24 '24 20:08 tballmsft