0 Favourites

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

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy 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.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)