[SOLVED] Negative/Minus Gold amount

Hi Guys,


This may sound like a very strange request, but I need a plugin or a snippet of code that I can add to my game to allow my players gold to go into a minus figure. for example -$200. I've had a play around with the default JS files but had no luck. Can anyone tell me how I can do this?


Edit: Nevermind I figured it out. For those of you who want to know how this is done, here's how I did it:


1. Open "rpg_objects.js" in some form of javascript editor.


2. Search for "Game_Party.prototype.gainGold = function(amount) {" It's around line 4910


3. Change it to this code:


Game_Party.prototype.gainGold = function(amount) {
this._gold = (this._gold + amount).clamp(this.minGold(), this.maxGold());
};


4. Below that you will find this: (Don't edit this part)


Game_Party.prototype.maxGold = function() {
return 99999999;
};


5. Just below this bit of code add this line so it looks like this:


Game_Party.prototype.maxGold = function() {
return 99999999;
};

Game_Party.prototype.minGold = function() {
return -99999999;
};


And there you have it, your gold will now go into a Minus Integer / Negative Value... This is really good for anyone who has a game where you start off in debt with a loan shark or something like that and you have to pay off the debt 😉


Hope this helps.
DO NOT!


Seriously, @Coopziana, do NOT change the core files. Copy the parts you want to edit into a new file, edit them, then save them in the "plugins" folder under yournamehere.js (you can choose the yournamehere, but the .js is a must). Then add the new plugin through the plugin editor.


Preferably, use an alias for when it it a simple change, but sometimes you can't. It is a good thing to try though.


The reason I say this is that, if something goes wrong, you can't deactivate changes in the core.
DO NOT!


Seriously, @Coopziana, do NOT change the core files. Copy the parts you want to edit into a new file, edit them, then save them in the "plugins" folder under yournamehere.js (you can choose the yournamehere, but the .js is a must). Then add the new plugin through the plugin editor.


Preferably, use an alias for when it it a simple change, but sometimes you can't. It is a good thing to try though.


The reason I say this is that, if something goes wrong, you can't deactivate changes in the core.

Naturally if it was a groundbreaking change to the game then yes of course I would make a separate JS file for it, but as this is such a minor tweak to the code itself, I do not think it will cause any issues, and if it does... well I can just revert the changes I have made, or simply copy a version of the original file from a new project.
Maybe it is acceptable in this case, but it is a bad practice. You may develop a bad habit and not notice. And then, if something goes wrong, you won't know if it is from a plugin or something you did, or even a plugin incompatible with something you did.
I'm sorry to necro this thread, but this is EXACTLY what I was searching for and I'm really glad you solved this for me! 🙂

I have one "small" request (actually, I don't know if it's small because I don't have any JS experience).

Can you make it work for shops, too? Actually, it's ony working if you decrease the gold per event. But it would be cool to be able go shopping as well 😉 (of course only as long as you don't reach the limit, let's say -1,000 or so)

@Zion, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


The OP hasn't been online for a year. I suggest you just make a new thread with what you're trying to do.

Original thread: https://forums.rpgmakerweb.com/threads/solved-negative-minus-gold-amount.68860/