Custom Save Path in Documents/namegame/gamesave

Discussion in 'Javascript/Plugin Support' started by Lakaroth, May 29, 2019.

  1. Lakaroth

    Lakaroth Veteran Veteran

    Messages:
    272
    Likes Received:
    127
    First Language:
    English
    Hello there, i have a problem with a deplyed MAC or PC (in enigma toolbox) compiled version.
    Save won't work.
    Reading around i have find some plugins for custom game save path but they won't work too, is a permission problems
    and i have also try to change CHMOD to 777 but nothing.

    My game is rpg_core.js v1.5.1

    For now the only solution that i find is this plugin:

    Code:
    StorageManager.localFileDirectoryPath = function() {
        var path = require('path');
    
        var base = path.dirname(process.mainModule.filename);
     
      var previousFolders = 4;
        for(var i = 0; i < previousFolders; i++){
          base = path.dirname(base);
      }     
     
     
      return path.join(base, 'gamesave/');
    };
    
    This move gamesave folder outside the game.app but it works only if you put the app in the desktop.
    There's a way to change this plugin to absolute path like (documents/username/gamename/gamesave) for MAC and PC?
    Thank you
     
    #1
  2. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,864
    Likes Received:
    9,711
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    Code:
    var os = require("os");
    var fs = require("fs");
    var homedir = os.homedir();
    if (homedir.readdirSync().indexOf("gamesaves") < 0) fs.mkdirSync(homedir + "gamesaves");
    return homedir + "gamesaves/";
    
    However, by default game files, on newer windows platforms, are saved into C:\Users\Username\Appdata\Roaming\ if I remember correctly. You can just hard input it there. For example:

    Code:
    var fs = require ("fs");
    var saveText = "jjdijsmikekdijmdkdjnekkd";
    fs.writeFileSync ("C:/testFile.txt", saveText);
    
    writes the save text directly in your C directory. Where the game's directory is located, is irrelevant.

    On Linux it would be
    Code:
    fs.writeFileSync ("~/Documents/testFile.txt, saveText) instead, because on linux ~ means user's home directory.
     
    Last edited: May 29, 2019
    #2
    Lakaroth likes this.
  3. Lakaroth

    Lakaroth Veteran Veteran

    Messages:
    272
    Likes Received:
    127
    First Language:
    English
    thank you @Poryg anyway i think the main problem of a compiled MAC OS app, is just the permissions.
    Without any plugin i got the attacched error.
    How to set a CHMOD 777 to entire game app and subfolders?
    On mac usually there's the option on file info to do that, but it can't let me set subfolders.
    Thanks, i just want to understand this issue.
     

    Attached Files:

    #3
  4. Poryg

    Poryg Pixie of the Emvee kingdom, Ham of a Hamster Veteran

    Messages:
    3,864
    Likes Received:
    9,711
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    #4
  5. Lakaroth

    Lakaroth Veteran Veteran

    Messages:
    272
    Likes Received:
    127
    First Language:
    English
    thanks
     
    #5

Share This Page