Switching Characters with A Button Simply Not Working

I'm using Yanfly's Button Common Events. So each character has a different Field Skill. Dropping Bombs (which I'll probably need help with in the future), Jumping, ect.

But it's annoying to keep going to formation to change the lead so instead I figured a common event that changes the lead would be better suited for the project.

Alas my attempts have been strangely futile. Every time I use the event Peggy the Maid just ends up in front.

Here is what I used, see if you can make heads and tails of it's problem. It should go
Peggy -> Brutus -> Marsha -> Cyrus -> Peggy

1.png
==, not =

But if you just want to take the leader and move them to the end, you can replace your entire event with this script call:

Code:
$gameParty._actors.push($gameParty._actors.shift());
$gamePlayer.refresh();
$gameMap.requestRefresh();

(I do suggest you at least copy your current event away into another slot just in case it doesn't work quite the way you are wanting though)
==, not =
Oh there is some confusion. The "Eval: $gameParty.leader().actorId()" is actually the name of a variable not a script. I don't understand how it works under the hood as I got it from someone a while back, but it makes the game read the ID of whose leading the party in the variable automatically.

In fact the same exact set up was copied from another common event (the ones where the party can activate their field skills) where it works perfectly.

Edit: Basically what's not working is removing party members and adding them - for some reason - Peggy always gets put in front.
If you just want to move the leader to the back of the line, I'd still just use the other method I gave you.


That's a long name for a variable 😀 Where exactly is the variable being set? I can't see it there anywhere. And what is the variable id? Any chance it's being used elsewhere (including in a plugin)?

If you want to continue troubleshooting, can you show the event where it does work and explain what it's doing?
That's a long name for a variable 😀 Where exactly is the variable being set? I can't see it there anywhere. And what is the variable id? Any chance it's being used elsewhere (including in a plugin)?
It's variable 1 which shares it's name, it's being used to tell the game who is in front of the party without me having to tell that game who is. This allows me and my brother to quickly set events to react based on the lead. I don't know how it works at all sadly, but it does work. Isn't that odd.
The variable is always just set to the same number as whoever is in front because of it's name. Not sure if it's because of a script or what. Still pretty cool I guess.

If you just want to move the leader to the back of the line, I'd still just use the other method I gave you.
That said, yer method worked perfectly.

I wish I understood why it worked through. I gotta learn how the script calls work and how to combine them together if I'm ever going to be able to this right. I'll never be a real professional if I can't do that... and just asking over and over isn't going to teach me anything.

Still I should be happy this problem is solved. Maybe YOU can point me in the right direction on where I'd learn this stuff.
I'm guessing you've got a plugin that allocates a script call to a variable. I wrote one, but I know of at least one other that's out there.
For learning, I'd just find some online sources to start learning programming in general, and Javascript in particular, for MV and MZ.

$gameParty._actors is an array - a list - that simply contains actor ids.
push(...) adds something to the end of an array
shift(...) removes something from the beginning of an array, returning what was removed
Both update the actual array, rather than just telling you what's there

So the above is adding an entry to the end of the actor list, and to determine what to add, it's removing what's at the start.
I'm guessing you've got a plugin that allocates a script call to a variable. I wrote one, but I know of at least one other that's out there.
I'd bet on it being one of my Yanfly Scripts.
For learning, I'd just find some online sources to start learning programming in general, and Javascript in particular, for MV and MZ.
Hmmmmm, okay then - I will make it my mission to try and find a place to learn Javascript. Until then, I suppose I must bother people. 😀
$gameParty._actors is an array - a list - that simply contains actor ids.
push(...) adds something to the end of an array
shift(...) removes something from the beginning of an array, returning what was removed
Both update the actual array, rather than just telling you what's there

So the above is adding an entry to the end of the actor list, and to determine what to add, it's removing what's at the start.
Hmmmm, that's pretty cool! I'm glad I understand that now.

I guess this topic can be closed now. Thank you so much~!
ok, i'm interested in the same concept so i'll help you bother people to help 😛

i uses Shaz's method omg, it works flawlessly THANK YOU!
Regarding learning Javascript, I found https://www.w3schools.com/js/default.asp to be very helpful. The lessons there are very brief and teach the basics of how things work.

My new favorite place to go is https://developer.mozilla.org/en-US/. It's harder to understand without JS knowledge. But, you can look up specific things you want to understand like Array.prototype.push(). MDN gives a more detailed description of how it works, sometimes why it doesn't work the why you think, and when you should use it.

Note, neither of these are RPG maker specific. But a general knowledge of JS will take you a long ways in understanding plugins and maker core.
Maybe YOU can point me in the right direction on where I'd learn this stuff.
I second autodidact's recommendation - I like w3schools for their interactive lessons. Incidentally, it's no great secret - it's the top result if you simply Google "JavaScript tutorial".
I will also use w3schools if I want to look up the correct syntax of a command. I like their simple explanations and examples.

Thread closed

Next time you're finished with a topic, you can just report it and ask for it to be closed. I'm reading the posts here because I've taken part in the thread, but other than that, there's no guarantee a mod will see a comment saying it can be closed.

Original thread: https://forums.rpgmakerweb.com/threads/switching-characters-with-a-button-simply-not-working.139509/