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

**URL:** https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498
**Category:** PXT
**Created:** [November 19, 2020, 4:29am UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498 "2020-11-19T04:29:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [November 19, 2020, 4:29am UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/1 "2020-11-19T04:29:33Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8c8ee27ebd612f82ec7e03c9c07e253158648c55.png)

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.

> **[Angle fields  |  Blockly  |  Google Developers](https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/angle)**

Thanks!  
Jfo

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [November 19, 2020, 4:58am UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/2 "2020-11-19T04:58:16Z")

</div>

You can repro it here on the playground  
[https://makecode.com/playground#field-editors-protractor](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.

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [December 17, 2020, 7:03pm UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/3 "2020-12-17T19:03:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [December 17, 2020, 7:03pm UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/4 "2020-12-17T19:03:48Z")

</div>

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.

```auto
/// <reference path="../node_modules/pxt-core/localtypings/blockly.d.ts" />
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>

```

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [December 18, 2020, 4:29am UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/5 "2020-12-18T04:29:05Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![Fiona](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@Fiona](https://forum.makecode.com/u/Fiona)
#### Post date: [March 26, 2021, 3:28pm UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/6 "2021-03-26T15:28:35Z")

</div>

I am facing the same problem. And still finding a solution on google. Please anyone give me the correct answer.

---

<div class="post-metadata">

### Author: ![jfo8000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jfo8000/32/1038_2.png) [@jfo8000](https://forum.makecode.com/u/jfo8000)
#### Post date: [March 26, 2021, 9:47pm UTC](https://forum.makecode.com/t/protractor-field-limits-to-180-degrees-doesnt-accept-fractions/4498/7 "2021-03-26T21:47:34Z")

</div>

Hi Fiona -  
In the end I wound up extending my pxt and replacing the editor with my own copy  
The source code is here

> <https://github.com/Buildbee/makecode/blob/master/fieldeditors/FieldProtractorEditor.ts>

> <https://github.com/Buildbee/makecode/blob/master/fieldeditors/extension.ts>

> <https://github.com/Buildbee/makecode/blob/master/fieldeditors/tsconfig.json>

You can see how I hooked it up looking at turnAsync()

> <https://github.com/Buildbee/makecode/blob/master/sim/operators.ts>

And you can see it in action here

> **[BuildBee | MakeCode](https://makecode.buildbee.com)**
>
> Learn to code and 3D print your creation with BuildBee using the powerful Microsoft MakeCode Blocks / Javascript editor.

Grab out the turn block from operators.  
JFo
