How Can I Change Display Values returned by attached javascript file?

1 favourites
  • 2 posts
From the Asset Store
Convert multiple Excel files into JSON files and import them into construct3.
  • I have a .js file included in the files folder and it is loaded in runtime. How would I go about changing the return values in the following function to local or global variables in my event sheet?

    function getGoogleTransactionInfo() {
     return {
     displayItems: [
     {
     label: "Subtotal",
     type: "SUBTOTAL",
     price: "11.00",
     },
     {
     label: "Tax",
     type: "TAX",
     price: "1.00",
     }
     ],
     countryCode: 'US',
     currencyCode: "USD",
     totalPriceStatus: "FINAL",
     totalPrice: "12.00",
     totalPriceLabel: "Total"
     };
    }
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just did something similar yesterday, I think. Please see the attached images. I create a grid of people, and set the sprite frames and text labels based on a JavaScript object, similar to yours. I wrote a "parser" function to grab the data from the JS object.

    What I was struggling with is the type of variables. You must make sure your event function is set to receive the proper return type and also the proper argument types, as the C3 runtime does not seem to do the coercion the same way as JavaScript does. I resorted to using strings only for the communication between JavaScript and C3 runtime and convert them to numbers in the C3 actions where needed.

    Check out the "Integrating events with scrips" demo projedct to learn how to set local and global variables.

    Hope this helps.

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