How do I Use Custom Variable at index.html and use it ?

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello fellow construct 2 user,

    so the idea is, im selling my games into some arcade,

    usually on my past game, im using a variable on index.html (example: BACK_URL) and then

    on the game over screen i just load that variable and send player last score to their arcade store back url (using javascript windows.location).

    with this method, buyer can easily changes only index.html, without touching sources.

    problem is, how do i achieve this with construct 2 ?

    any kind of suggestion is appreciated

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This score is saved in a database? If Database is a bit more complicated.

    If only locally then you should use storage location.

    You can use variables to determine the name of the storage location of the score.

    So users can change easily.

    https://www.scirra.com/manual/188/local-storage

  • This score is saved in a database? If Database is a bit more complicated.

    If only locally then you should use storage location.

    You can use variables to determine the name of the storage location of the score.

    So users can change easily.

    https://www.scirra.com/manual/188/local-storage

    hi martdsam, thanks for your reply

    the thing is, the score database is in their server, and no way i get access to it, im selling my games to different arcades owner, so it should be more flexible way.

  • You can inject parameters in the index.html file into the C2 application using TextBox injection. You create TextBox objects and specify unique ID and call that ID in a JavaScript function grafted into the index.html file script section like:

    function doIt()
    {
    document.getElementById("getDisplayName").value = "";
    document.getElementById("getUserID").value = "-1";
    document.getElementById("getFT").value = "1";
    document.getElementById("serverIP").value = "www.stormforgedproductions.com";
    document.getElementById("saltBox").value = "eab5f675c24ebec8b745c8aa90096852f54ac10ce7f2f6638ccbf26248f480360fb8103977581838b28aa73b10f2ed731f7b544b736453e3bcf3a5446042d321";
    document.getElementById("errorBox").value = "";
    document.getElementById("playerServers").value = "{}";
    document.getElementById("direct").value = "";
    document.getElementById("tester").value = "false";
    document.getElementById("playerCapId").value = "-1";
    } [/code:1a411otx]
    
    I called out function doIt(), but you can call it whatever you want.  Then when your layout starts you call a custom JS script using the browser object and simply call the doIt() function and it will transfer the values from your HTML into the appropriate TextBoxes according to their IDs.
    
    If you look at the HTML source for our homepage, you can see this in action.
  • Thank you gumshoe2029

  • crizon Browser object has expressions QueryParam and QueryString, you don't need JavaScript to use them. For example:

    Browser.QueryParam("PlayerName")

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