Code of CoC2

Necrorifter

Active Member
Jul 28, 2020
29
2
26
It has come to my attention that you guys code your CoC 2 with javascript. My question is do you guys have any sources that you can point me at for learning how to save and load work in a text-based RPG game? I learn that it is not possible to use javascript/jquery to load a file due to it be used as "hack" so it was blocked and that is only possible through server means but it does not seem that you guys actually use server beyond cloud saving but even then you have the whole save to file system. Where do I go to learn it? most that I find seem to point at reading from HTML... I may or may not have taken some coding "inspiration" from your free source file for the original CoC 1. Granted, I change it into my version as Flash programming is different from javascript, and you guy using Flash only Object as means to save, where I cannot find Javascript version of this.
 

Upcast Drake

Well-Known Member
Moderator
May 27, 2017
2,584
2,045
Southeast USA
Code:
let uploader = document.createElement('input');
uploader.type = 'file';
uploader.onchange = () => {
    let files = uploader.files;
    if (files.length <= 0) {
        return false;
    }
    let fr = new FileReader();
    fr.onload = (e) => {
        const data = e.target.result;

        // Do your thing with data here

        uploader.remove();
    };
    fr.readAsText(files.item(0));
};

uploader.dispatchEvent(new MouseEvent(`click`, {bubbles: true, cancelable: true, view: window}));
 

Necrorifter

Active Member
Jul 28, 2020
29
2
26
Oh Thanks!, i honestly did not expect that you will bring some of code from Coc2 to show it with how strict you guys are with source code, but I will see about learning each of those term and how to apply it to my version. Thanks once again.