SKID'S PROFILE

Search

Filter

[SCRIPTING] [RMMV] Dynamic economy with RPG Maker MV

author=coelocanth
Skid, you want to use the "code" forum tag to quote code blocks (4th icon from the right,
).

To answer your question, $gameVariables is a global that is defined by one of the engine scripts. So you can reference it from any plugin (also the javascript console for debugging - press F8 or F12 in test mode).

All the core scripts are in the js folder with names starting with rpg_ for the game systems part.
Normally you want to override (patch / alias) the core classes with a plugin script rather than editing the original. But you will want to *read* the original scripts when writing plugins.

The way to patch objects in javascript is simply to set the member name to a new function.
Scene_Shop.prototype.sellingPrice = function() {
    return this._buyWindow.price(this._item);
};


Often you want to preserve the original function to base call it, you do that by assigning to a local variable


var MYPLUGIN_Scene_Shop_sellingPrice = Scene_Shop.prototype.sellingPrice;
Scene_Shop.prototype.sellingPrice = function() {
return MYPLUGIN_Scene_Shop_sellingPrice.call(this) * 2;
};


If you look at the source of existing plugins, you'll find lots of variations on the above.

The code you were asking about looks like a replacement for the shop processing event command from the 4th post.

So you'd need to patch Game_Interpreter.prototype.command302 with your own version.


I wasn't quite sure what you were talking about but I actually did figure it out, I put it like this.




 var goods = [     

[ 0, 4, 1, $gameVariables.value(0001) ],
[ 0, 3, 1, 10 ] ]

SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, false);]


The 0001 is the variable I created within RPGMaker itself, I can't believe it actually worked but it's working. I was basically just trying to add exactly what is above and I had no idea how to reference in-game variables but that thing you mentioned with the $GameVariables.value was PERFECT, did the trick totally. Thanks so much.

[SCRIPTING] [RMMV] Dynamic economy with RPG Maker MV

I'm trying to follow this but having trouble, I actually need to use the same sort of system where I have a variable that affects the prices of items.

I'm at this part
__________________________________________

Alright!

Solved my issue: I changed my unknown by:

$gameVariables.value(x)

so the codes looks like:


var goods =
{
{ 0, 1, 1, $gameVariables.value(1) },
{ 0, 2, 1, $gameVariables.value(2) }
}
SceneManager.push(Scene_Shop);
SceneManager.prepareNextScene(goods, false);

____________________________________________________

What is $gameVariables? Where and how do I define this?
I am not familiar with Javascript but I am with C# so it's familiar but I just can't figure it out exactly, any help would be wonderful. I had to change the brackets to {'s because it thinks it's forum formatting code and made the stuff between vanish.
Pages: 1