RMMV How would I make a plug in call to change a variable? (I guess)

deus69xxx

Ultima Ratio Regum
Veteran
Joined
Oct 13, 2013
Messages
108
Reaction score
53
First Language
English
Primarily Uses
RMMV
I'm actually not sure how I should have asked this. Simple in theory, but I don't quite get plugin making, so here it goes:

I would like to be able to make a call that changes a variable. Not a game variable, but one in a 'plugin.' I would like to change it so that if that variable is a particular thing, then when it would run this particular function...

Sprite_Actor.prototype.setActorHome = function(index)

it would instead run an identical one with some alterations.

closer to specifics: when an event happens, the entire party changes to (essentially) an inanimate object with multiple parts placed specifically. so, i'd want it to be running my copy of setActorHome instead of the game's when i have it set to "external" for instance.

so i'm not sure how to separate my copy from the original until i set a variable to something, or it's not that something. help x.x
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,693
Reaction score
9,863
First Language
German
Primarily Uses
RMMV
you completely misunderstood what a plugin command is.

a plugin command in its basic is nothing but a text line that is handed to the plugin for the plugin to decide what to do with it.
as a result it can only do the specific things that the plugin programmer wanted it to do, absolutely nothing else.

What you want to do - if possible at all - has to be done by script command.
only with scripts you have direct access to plugin data.

and then it depends on the specific plugin if what you want is even possible.
some plugins protect their data, and in other cases specific changes need to be done on new game for them to work and a few more limitations.

I suggest you make a new post describing specifically what you want to do with which plugin, linking to the website of the plugin and giving much more detail.
then we can tell you if that is possible and if yes, how to do it.
 

deus69xxx

Ultima Ratio Regum
Veteran
Joined
Oct 13, 2013
Messages
108
Reaction score
53
First Language
English
Primarily Uses
RMMV
it's not a plugin of anyone else's. and yeah, now i feel dumb, that would definitely be a script call. got a location here where i'd post for assistance with that? xD

seems simple, having a "plugin" of my own that's basically a replacement of what i mentioned that i can turn on and off at will.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,693
Reaction score
9,863
First Language
German
Primarily Uses
RMMV
If it is a plugin you're programming yourself, you actually CAN implement a command to use a plugin command to change values. It depends on how you want future users of your plugin to access that feature.

And in that case, there is a forum for learning javascript where you can ask how to implement something - you just need to give a lot more details because no one can read your mind and in programming, the details are important.
 

deus69xxx

Ultima Ratio Regum
Veteran
Joined
Oct 13, 2013
Messages
108
Reaction score
53
First Language
English
Primarily Uses
RMMV
well, since this happens to be IN the learning javascript section...

my plan is to use an event to alter a number of things at once, and i'm just trying to get down how to get it there.

so, here are some things. i use events to change this variable,

$dataItems[27].occasion=3;

when i'm disabling the use of an item in certain areas. what i'm trying to do is "essentially" use that methodology to implement a temporary change to actors before going to a different map. not to re-hash what i already said, but LITERALLY

Sprite_Actor.prototype.setActorHome = function(index)

that function in rpg_sprites.js. i know the easiest way to overwrite, which is to copy that and place it in a new .js file in plugins and activate it. what i'm not sure about is how to implement an on/off switch precisely for that function in a .js file.

i'm not sure how to make that much clearer than how i already explained it.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,971
Reaction score
3,157
First Language
English
Primarily Uses
RMMV
what i'm not sure about is how to implement an on/off switch precisely for that function in a .js file.
I'm not going to get on your case too much, because as you say, this is the Learning JavaScript forum :wink:

But you may want to continue working through tutorials before trying to implement anything significant in your game, because conditional statements are really basic coding concepts.

Also, you seem to not understand some of how the engine works:
so, here are some things. i use events to change this variable,

$dataItems[27].occasion=3;
That is not going to work properly. The $data arrays are read directly from your game's JSON database files. Adding or changing variables on their elements will not be saved in your game, so trying to look at that variable again later isn't going to produce reliable results. You should use the game variables instead.

Regardless, as far as your question goes, you'd simply copy the existing setActorHome function and add a conditional to it:
Code:
Sprite_Actor.prototype.setActorHome = function(index) {
if (/*my variable is not the value I'm looking for*/)
    this.setHome(600 + index * 32, 280 + index * 48);
else
    // do whatever alternate code you want
};
 

deus69xxx

Ultima Ratio Regum
Veteran
Joined
Oct 13, 2013
Messages
108
Reaction score
53
First Language
English
Primarily Uses
RMMV
actually, the thing with $dataItems[27].occasion=3;

does work precisely how i want it to, i'm using it in another game, it's how i make "tents" useable on the world map and at save points. i change the occasion to 2 when entering a no tent area, or stepping off a save point. or maybe the numbers are reversed. regardless, works on a deployed game.

as for the rest of that, i apparently need to get back in to learning my coding, because i have no clue why i didn't think of that. thanks!
 
Last edited:

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
730
Reaction score
701
First Language
german
Primarily Uses
RMMZ
that function in rpg_sprites.js. i know the easiest way to overwrite, which is to copy that and place it in a new .js file in plugins and activate it. what i'm not sure about is how to implement an on/off switch precisely for that function in a .js file.
We usually don't copy-paste and override functions, as it may raise incompatibilities and backfires. Extending @ATT_Turan 's code, I suggest to write something like this:

Code:
const alias = Sprite_Actor.prototype.setActorHome;
Sprite_Actor.prototype.setActorHome = function(index) {
  if (YOUR CONDITION) {
    // do alternative code
  } else {
    alias.call(this, index)
  }
}

This way, the origin function is called smoothly without needing it to copy-paste.
 

deus69xxx

Ultima Ratio Regum
Veteran
Joined
Oct 13, 2013
Messages
108
Reaction score
53
First Language
English
Primarily Uses
RMMV
i understand what everyone else usually does, however, i don't make plugins for others, i specifically alter the things i need for my game :)

there are certain things that i use outside plugins for, and some things i just go into the source and alter what i need. for instance, i will go in and change the party members number to 5 or 6, and then alter their home designations. i generally don't need a plugin for that, and it doesn't affect anything that other plugins i DO use, use (so far lol). and in this particular one, i can't really even think of any plugins i'd use aside from cosmetic o_O

i literally had a gigantic brain fart, and didn't even think of using a game switch or variable INSIDE the function to determine an if/else state, because i'm human, and am infinitely capable of being a baddie. xD

Code:
//--------------------------------------------------------
Game_Party.prototype.maxBattleMembers = function() {
    if($gameSwitches.value(1)==true){
    return 6;
    }
    else{
    return 4;
    }
};
//--------------------------------------------------------
Sprite_Actor.prototype.setActorHome = function(index) {
    if($gameSwitches.value(1)==true){
    if (index == 0){this.setHome(600, 280);}
    if (index == 1){this.setHome(615, 270);}  
    if (index == 2){this.setHome(620, 290);}
    if (index == 3){this.setHome(625, 310);}
    if (index == 4){this.setHome(630, 260);}
    if (index == 5){this.setHome(640, 280);}
    }
    else{
    this.setHome(600 + index * 32, 280 + index * 48);
    }
};

just that. the numbers are not perfected, but the idea is that. this works just how i want it with an event that changes party members and changes switch 1. it gives me the two different battle setups i need. then i'll locate the function that makes the character move forward and back, and disable those while the switch is on. easy peasy lemon squeezy!
 

Latest Threads

Latest Posts

Latest Profile Posts

Can you recognize where this area is from? :kaocry:
Mq9QM3h.png
For those with up to 9 elements of magic; how do you structure your database. By element? Or by what is offensive vs supportive spells?
would anyone here be interested in rough concept art for the main protagonist of my game that might get changed later? :kaoswt2:
I guess I have no idea how to properly upload a custom font lmao. The menu fonts are too damn small.

Font_Size.PNG

Forum statistics

Threads
124,437
Messages
1,163,651
Members
163,255
Latest member
Bohnez
Top