Microsoft MakeCode

Protractor field limits to 180 degrees, doesn't accept fractions

I am trying to implement a turn block, so I hooked up the protractor…

image

It looks as if it limits to 180 degrees? I also can’t do decimals - any time someone types them in they get floored.

Is there any way I can use the blockly angle field? It is a bit closer to what I want - I need to turn a 3d shape by a specific amount.

Thanks!
Jfo

You can repro it here on the playground
https://makecode.com/playground#field-editors-protractor

Load up the protractor example
Add a turn block
Try to type 22.5
Result: floors to 22

Same thing happens with range example (but about half the time). If I type a number, then hit enter it floors. Not all the time - might have something to do with what element has focus.

The TSConfig was

    {
    "compilerOptions": {
        "target": "es5",
        "skipLibCheck": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "declaration": false,
        "out": "../built/fieldeditors.js",
        "rootDir": ".",
        "newLine": "LF",
        "sourceMap": false
    }
    }

Will not work if your typescript isn’t 3.5.1
Needed skipLibCheck otherwise it was digging into jquery and validating that.

Just following up.
Yes you can replace the fieldeditors by writing an extension.

How to replace field editors.

  • Make a folder called fieldeditors

  • Copy the tsconfig from this folder to your folder

  • Make sure your pxtarget.json has “extendFieldEditors”: “true”

  • The pxt cli will look for “fieldeditors” folder and build it

  • Fight typescript compile errors till it loves you back.

    • Upgrade your typescript to version 3, pxt-sample libs out of date.
    • Add a skipLibCheck to avoid jquery type errors
    • if you start with any of the ones from the base pxt, dont forget to update your path referencce to node_modules/pxt-core
/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts" />
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>

As regards to the fraction problem, it seems that there is a fieldOption called precision for the range slider which allows it to accept decimals. This is not working perfectly and I’ve had to call setConstraints with undefined precision to get it to behave properly…