GetPluginSettings -> Unexcepted token

0 favourites
  • 7 posts
From the Asset Store
Various Bell Sounds (from small to huge) / 35 Unique Clips / 2:46 minutes of audio
  • Although my JavaScript skills are rusty, but what's the difference?

    function GetPluginSettings()
    {
         return
              {
              "name":               "Demo",
              "id":               "Demo",
              "description":     "Demo description.",
              "author":          "Demo",
              "help url":          "http://demo.com",
              "category":          "Demo",
              "type":               "object", // not in layout
              "rotatable":     false,
              "flags":          pf_singleglobal
         };
    };
    

    VS

    function GetPluginSettings()
    {
         return {
              "name":               "Demo",
              "id":               "Demo",
              "description":     "Demo description.",
              "author":          "Demo",
              "help url":          "http://demo.com",
              "category":          "Demo",
              "type":               "object", // not in layout
              "rotatable":     false,
              "flags":          pf_singleglobal
         };
    };

    For me, everything is valid but Construct interpreted it differently.

    ---------------------------

    HTML5 exporter

    ---------------------------

    Unable to load plugin in 'C:\Daten\Tools\Construct 2\exporters\html5\plugins\demo\': Javascript exception in file 'edittime.js' line 5: SyntaxError: Unexpected token :

    Code line:

              "name":               "Demo",

    Stack trace:

    SyntaxError: Unexpected token :

    This plugin will not be available in the editor.

    ---------------------------

    OK   

    ---------------------------

  • Your 'id:' should be "demo" or your folder's name should be "Demo".

  • Javascript automatic semicolon insertion

    The code

    eturn

    {

    is parsed as

    eturn;

    {

    which means 'return undefined;' followed by a chunk of JSON which is then ignored. The solution is to use

    eturn {

    all on one line, then it won't insert a semicolon for you.

    Yep, Javascript is mad.

  • Thank you for the explanation. I already thought I'm stupid <img src="smileys/smiley8.gif" border="0" align="middle" />

  • Indeed pure madness.

    The style

    if()

    {

    }

    is incorrect in javascript, and must be written as

    if(){

    }

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is it? The entire javascript runtime is written in the style

    if ()

    {

    }

    It works just fine. I think the semicolon insertion rules don't break that.

  • Actually I was wrong, it works for if() and functions, but breaks for returns:

    Check 30:40

    Subscribe to Construct videos now

    Maybe ECMAScript 5 strict mode is fixing it, I don't know, but it certainly breaks things in conventional javascript in some occasions.

    I prefer the curly braces below the statement too, but what can I do? :(

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)