Javascript - A Souls Game Mechanic - how to script get gold/money turn into exp?

Hi, I'm trying to create a souls-like game but I can not figure out how to use gold (souls) to become exp so you can level up?
You posted in MZ, but your profile says you use MV - which game are you looking for?

The answer could affect whether there are any relevant plugins to recommend to you. However, at a basic level, the answer is the same. In an event, do Contol Variables -> Game Data -> Other -> Gold

Then do Change EXP -> Increase -> Variable -> Variable you chose in the first step.

Then Change Gold -> set it to 0. Or Decrease by that Variable, whichever.
This should do it, for MV. Probably rather similar on MZ though.
JavaScript:
Game_Party.prototype.gainGold = function(amount) {
    //this._gold = (this._gold + amount).clamp(0, this.maxGold()); //Original
    
    //If you want to SPLIT the gold between the members, remove the "//" from before the next line.
    //amount /= Math.floor($gameParty._actors.length); //Divides gained "gold" as "exp" between party.
    for (var i = 0; i < $gameParty._actors.length; i++) {
        $gameActors.actor(i+1).gainExp(amount);
    }
};

Game_Actor.prototype.gainExp = function(exp) {
    var newExp = this.currentExp() + Math.round(exp * this.finalExpRate());
    this.changeExp(newExp, this.shouldDisplayLevelUp());
};
Hy, this is not a script but should do the trick as well:
1637939516043.png
You would need more ifs for different levels otherwise it would always cost 50 or whatever you want.
Thx Everyone, I will test all of these and see how they work.
Somebody fixed this for me right now.

Original thread: https://forums.rpgmakerweb.com/threads/javascript-a-souls-game-mechanic-how-to-script-get-gold-money-turn-into-exp.142486/