getting QueryParams in Addon

0 favourites
  • 2 posts
  • Hi, I have a plugin that sends logging data to our server that we use in all of our games. Now I want to add some data to the logs that is passed in through the query params on the game url. Since web workers don't have access to the window object (and hence query params), I have figured out how to do this in the editor by putting "Browser.QueryParam("my_query_param") into an action param... this can then get passed into my log.

    But 1) I would rather avoid having to paste this bit of javascript into every event action. and 2) I would also love to not depend on the Browser plugin.

    If anyone has thoughts on A) how to access the window object from anywhere in the plugin code or B) call a script that is included in the plugin file-list that could access the query params and store them on globalThis or C) call the Browser plugin from my plugin code... I would appreciate it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I found "initialValue" for params which I can use to pre-populate my action params with "Browser.QueryParam(\"teacher_email\")". And this works great on a new project where I add the Browser plugin before my own plugin.

    But.... if I have games with my plugin already added but without the browser plugin and I try to update, I cannot open my project. This seems very fragile.

    So I am trying to test if the Browser instance exists with - typeof(Browser) === "function" ? Browser.QueryParam("teacher_email") : "" ... and it seems I cannot put any logic operators in initialValue. Any thoughts on that would also be welcome.

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