Downloadable Files On clicking

I want to know how to make a Game where you can Download A File, and no I’m not using this for Malicious attempts Because I’m making a game where you download A Launcher to Play it for example like Runescape Or Roblox.

well, @Hamzah_Alani made a flappy bird project here where the game can take a screenshot and prompt a download. maybe he can show you how he did it?

Flappy.wick (1.9 MB)

He Used the Function

Screenshot();

I kind of want a HTML downloadable

i think in his code, screenShot() is a function that me made (not a built-in function). i’m pretty sure the download prompting is there. (that’s just the download part. the other part is actually making an html to give the user…)

Oh, I will try that

@Johan_Sipili sorry for the late reply, baron is correct screenShot is a function I created to capture the canvas element and download it as an image file.
This function is also a part of my version of the vcam that I created, you can download the latest version of my vcam (0.4.1) over here


Or if you just want to use the screenshot function without the vcam, you can copy-paste this code below inside of a default script in your project:

window.screenShot = function(name){
    var dl = document.createElement('a');
    dl.download = name;
    try{
        try{
            dl.href = document.getElementById('view-3').toDataURL();
        }catch(err){
            dl.href = document.getElementById('view-2').toDataURL();
        }
        console.warn("Taking screenshot inside Editor");
    }catch(e){
        dl.href = document.getElementById('view-1').toDataURL();
        console.info("HTML version");
    }
    dl.click();
    return dl.href;
};

With this code in a default script, you can write screenShot('fileName.png') anywhere in your project to take a screenshot!
Btw, the screenshot code in my vcam is a bit more different in that it allows you to “hide” some objects from appearing in the screenshot. If that’s to your interest, feel free to read more about it under that thread.

Also, for downloading HTML files… here’s a code that does that.

var blob = document.createElement('a');
blob.href = 'data:text/plain;charset=utf-8,' + TxtCode;
blob.download= 'filename.html'; // File name goes here
blob.click();

^ Set TxtCode to the HTML code of the file (string), and change filename with the file’s name.
If the file code is too long and you’d rather use a link for it, set blob.href to that link instead.

1 Like

“Thanks!”

-Famous last words from @Johan_Sipili

1 Like