How do I set path variables for loading files and AJAX

0 favourites
  • 3 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • Hello - I am working with someone who has made a game using Construct2. We want to publish it on a webpage - but the URL of the page is not the same as the URL to the JavaScript files that Construct2 imports. We are putting it on a WordPress site, so the page URL is /games/foo, but the URL of the scripts is /wp-content/plugins/foo-game/scripts

    Specifically, the game is trying to load "data.js", but can't find it.

    Is there a configuration setting that we can use to pass the path as a JavaScript variable to Construct2 for loading the file?

    On a related note, can we also pass the "endpoint" URL to the game, so that we can set up a variable that our AJAX calls can use to save data.

    Jamie

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can pass data in URL parameters.

    website .com/mygame.html?mypath=~wp-content~plugins~foo-game~scripts

    Then use Browser.QueryParam("mypath") to retrieve this parameter and replace "~" symbol with "/"

    There may be other ways too, but this is the only one I know.

  • dop2000 thank you for your reply. Very useful!

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