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

Get help using Construct 2

Post » Mon Sep 19, 2016 9:21 am

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
B
15
S
2
Posts: 9
Reputation: 695

Post » Mon Sep 19, 2016 10:59 am

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 I am Samuel :)

My google play
B
42
S
10
G
1
Posts: 126
Reputation: 3,278

Post » Tue Sep 20, 2016 1:14 am

martdsam wrote: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.
B
15
S
2
Posts: 9
Reputation: 695

Post » Tue Sep 20, 2016 4:03 pm

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:
Code: Select all
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";
}


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.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: dop2000, KefiRocK, matriax, Syazanie Amirin and 10 guests