I though a bit more about your specific problem and I inderstood that if i could find where the party order is stored doing what u want would have been really easy
So, i came up with a working easy solution but to earn at least you have to understad how it works
1. the party order
Party order is stored inside the
$gameParty Object (which is an istance of the class
Game_Party, basically
Game_Party is like a blueprint while
$gameParty is the proptotype build and which "lives" when you run the game, so since
Game_Party is just a blueprint you can't use it directly (at least not in this case) but instead you have to use the prototype because it can actually do things). The party order is a propery of
$gameParty named
_actors and is an array (a list of variables),
We can access it by typing
in the console for example (to open it press F8 while running the game, try it maybe)
2. cicling the party order
So we found where the party order is stored, now we have to find a way to rotate the members.
EXAMPLE: from
[char1, char2, char3] to
[char2, char3, char1]
Luckily for us the order is an Array type Object and in Javascript this class is already plenty of usefull methods and tools because is one of the more used. You can look them up in the internet o like here
ARRAY_METHODS, i program a lot but i consult the internet constantly.
We will be using 2 these array methods:
push() and
shift()
push() add an element at the end of an array, an undefined one if not specified what should be added
READ_EXAMPLE_HERE
shift() removes the first element of an array and returns it, so it like gives you this removed element to store it somewhere if you want
So to what we can do is:
$gameParty._actors.push($gameParty._actors.shift());
This is a little bit tricky to understand...
$gameParty._actors.shift() remove the first element and it returns it as a value, this value is given directly to
.push(value to add at the end of the array) so is given specificately to
$gameParty._actors.push().
Conclusions this line right here is what you where looking for, it cicles the party characters, you just have to add
$gamePlayer.refresh(); to make the change effective (don't ask me why i don't know every in and out of the source code). So it becomes:
$gameParty._actors.push($gameParty._actors.shift());
$gamePlayer.refresh();
3. Making the code accessible
Now we just have to make the code more accessible/clean.
If you want to modify other things later i suggest you to create you own plugin using
sublime text 3 or
notepad++
Make sure you save it as ".js" and store it in
game_folder \js \plugins
If you want to know how to add description, guide and parametner to plugin i suggest you to look up a tutoria in internet or download a template but for now you dont' need to do that it work nevertheless, so you have just to add it in rpg maker and enable it.
If you dove everythign i said you should have your plugin named as u want, whith a .js extention sitting in
game_folder \js \plugins
and added+enabled in the project editor
Now we get to tranforming the 2 lines of code we created in a usefull tool. We will store these line in a function, a chunk of code which upon calling does things and or gives back a value.
Example of a function who takes a argument (an input value) and returns a value
// returns the given value elevated to the power of 2
power_of_2 = function(value) {
return value * value;
};
In our case though we don't need to have a value back or to give an input value either, we just need the function to cicle the party upon calling. The struction for this "simple" kind of fucntions is:
Funtion_Name = function() {
//code to execute
};
now we put the 2 lines inside
Funtion_Name = function() {
$gameParty._actors.push($gameParty._actors.shift());
$gamePlayer.refresh();
};
At this point the function already works, you can just save the plugin and typing in the console or in a script of an event this
Funciton_Name();
Is not very beautiful though.. and it still doesnt' have a proper name.
Let's start with the name, i would call it
rotateParty (or cicleParty if you rpefer, but to cicle has kinda a different meaning in programing, anyway you can call it how you want just be sure there isn't another function with the same name or you will override it)
rotateParty = function() {
$gameParty._actors.push($gameParty._actors.shift());
$gamePlayer.refresh();
};
Already better, but usually every
function is sorted inside big containers called
classes (classes are collection of properties (variables) and funcitons/methods).
Since we are modifiyng values reguarding the class
Game_Party i think we should store the function in there
Game_Party.prototype.rotateParty = function() {
$gameParty._actors.push($gameParty._actors.shift());
$gamePlayer.refresh();
};
If you are wondering what
prototype is it basically means that this fucntion exists only on a protoype of the class (
$gameParty in our case) and not on the blue print
Game_Party
(basically we can call
$gameParty.rotateParty() but not
Game_Party.rotateParty() which would be useless for us 'cause it doens't store the party order)
Anyway the code as we have it for now will give error, because we are calling
$gameParty._actors from within
$gameParty and the code thinks we are trying to call a different class since we are specifying the name of the class. He's like inside a care calle $gameParty and looking around for a car named $gameParty but he can't find it because he's inside it.
In these cases we have to use
this, which automatically refers to class the code is into at the moment.
So we finally get:
Game_Party.prototype.rotateParty = function() {
this._actors.push($gameParty._actors.shift());
this.refresh();
};
3. Putting the code to use
We just need to call the code when we want it.
The line we have to use is
$gameParty.rotateParty();
the brackets say the code to run the funciton otherwise it just gives back all the code inside the function.
You can call this as i already said in the console (F8 during test run) for testing, or putting it into the event command
"Script"
That's it, i hope it's all clear
Read it patiently
