Extension works ok in extension builder but not in local mblock


#1

Hi
I’m developing an extension to call an http service. I’ve been looking at the source of the gsheet extension and I came up with a sprite extension and blocks having something like this in them:

var oReq = new XMLHttpRequest;
oReq.open("GET", "http://127.0.0.1:8001/land");
oReq.onreadystatechange = function () {
    if (4 == oReq.readyState && 200 == oReq.status)
        app.log("received: " + oReq.responseText);
}
oReq.send();

this works in the preview but if I download the mext and run it from mblock (mac) I get “TypeError: Cannot read property ‘remote’ of undefined”

I assume the reason might be in something wrong with the http request but what is the correct way to call an external service?

Regards
Virgilio


#2

I guest they have some sorts of limitation on using those services on PC app. Probably webWorker.


#3

Hi Virivigio,

Thanks for reach out to the community. At this moment, mBlock PC does limit normal user in testing their sprite extension due to some security reasons. But this is not a problem on mBlock Web. Please try your extension on Web, and publish it in extension builder with the “PC” unchecked in the “support platform” section.

mBlock Web is usually a few versions advanced than the mBlock PC, and it has more pioneer features. But we will also support running your own sprite extension locally in next version of mBlock PC in the coming month. Please be patient and enjoy coding.

Best,

Allen


#4

Thank you, I’ll give it a try asap!


#5

Dear @makeblock_product
I downloaded the extension as .mext and tried to upload on mblock web but the web page says the format is incorrect.
The same file is accepted by mblock pc (although I cannot use it because of the limitations you mentioned)
What is the correct procedure to run mblock web (https://ide.mblock.cc/) and add a custom extension? I cannot go with the publishing process unless I can test it :slight_smile:

Regards
Virgilio


#6

What did you select for “mblock version support” in the “Basic information” tab?


#8

Hi dai5_jp,

At this moment, please select ‘5.0.2’ and do not select “latest”. I know this might be confusing, we apologize for this inconvenience, and will remove this selection, and automatically fill out this option for our developers.

Best,

Allen


#9

Hi virivigio,

Downloading .mext file and dragging it into the IDE to load the extension is the method only valid on PC version. You cannot and don’t have to do this on Web IDE. To test your extension on web, you can just click the “Preview” button in your extension builder.


#10

Ok but in this way I cannot share extension with other people working with me. We all have to login with the same account and “test” the extension in order to have it working for everybody…
Is there any suggestion that comes to your mind?
I mean: I’m developing some http commands to command Tello Drone. This device is currently unsupported but I’ve got 3 drones to play with in my classroom. So I’d like to have three groups of people using Mbot + Tello in the same project (eg: when light sensor senses X then take off)
So I have multiple workstations with different and independent hardware
Please advice
thank you
Virgilio


#11

Hi Virivigio,

Since you want to share this extension with other people in the testing phase, there is a way to hack it. As you mentioned, you can ask people to login into your account in the extension builder. Then ask them to preview this extension or you can just send them the extension preview link after they login in. Don’t be afraid that you might be dropped out when they login in. We do support multiple users log into the same account at the same time.

We apologize for this inconvenience. As I’ve mentioned, we will support testing those extensions ( which have http request) locally on mBlock PC in the December (maybe in the end of November) new version release. Another thing is I once mentioned your extension is a sprite extension. I was wrong. I didn’t know you’re developing extension for tello with http request. Just to correct my words – it is still a device extension.

Hope you can test your extension successfully, and submit it for review soon!

Best,

Allen


#12

Thank you a lot
I’ll go with the way you suggested till next release

Thank you
Virgilio


#13

My pleasure virivigio! We’re excitedly waiting for your extension showing up in the review list! It sounds sooo cool.


#14

Hi Virivigio,
I just see an extension Tello appear on mBlock online.
I’m just wondering if you are the creator of this extension?
And if you are the creator I can purpose you to translate in french.
Would you be interested in a French translation?


#15

No, it wasn’t me :slight_smile:
thank you for pointing out, I’ll go have a look


#16

Hi cho7,

It’s published by one of our developers (but not in the official name). This extension is only in Chinese now. But since you’re interested, we will translate it in English first within a few days, and then invite you to join our translation group on a collaborative platform and translate it into French. How do you think? Please let me know your thoughts.

Best,

Allen


#17

Hi Allen,
I’ll be happy to translate your extension in french.

I’m wondering if you will add this extension on mBlock 5 offline version too?


#18

Hi cho7,

Thanks for your interest. I will let you know once our extension is ready for translation.

For the “offline version”, do you mean the mBlock5 PC? We will release the new PC version around January, and it will has this Tello extension. Please stay tuned.

Best,

Allen


#19

Ok, thank you :smiley:

Yes, I would say that. So It’s Ok, thanks a lot for this informations


#20

I can’t wait.


#21

Hi larajtekno,

Are u interested in translating the tello extension to French?

I’m happy to inform you that our Tello English translation is done. Now you could join our translation community from this link:
https://crowdin.com/translate/mblockpc/426/en-fr

Please register and request for joining the community.

After our approval, you will have the access to translate the translation. If you want to add translation for Tello blocks, you could just search it here and then click “everything”: