YEP Map Select Equip's Quirk With Chrono Engine [SOLVED]

Status
Not open for further replies.

TheKeeper

Veteran
Veteran
Joined
Dec 23, 2016
Messages
109
Reaction score
24
First Language
English
Primarily Uses
RMVXA
Heyla!

So, my game makes use of the Chrono Engine, which is great, except I really wanted there to be a quick menu you can access with button press that lets you quickly equip a weapon or armor piece. There's a button for items and skills, but not weapons and armor. So I decided to make this ability using the YEP Map Select Equip plugin and common events. Here's my setup:

1586130350683.png

Here's the event that gives me access to the common event:
1586130426886.png

Now, this setup almost works, except... When you choose the weapon, it doesn't register as equipped until you go into the quick menu again.

So, you go into the menu and select a weapon:

1586130563394.png

After selecting the dagger, you clearly see the weapon isn't equipped: 1586130602745.png

Once I go back into the menu, it equips the weapon: 1586130645424.png

And it does this every time I want to equip the weapon. So, I choose a weapon. It doesn't register as equipped, and I have to open the menu again to get it to register as equipped.

Well, as you can guess, this is super awkward. I'm hoping that someone might be able to figure out what's going on to fix this quirk?

Thanks so much for your help in advance!
TheKeeper
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
659
Reaction score
373
First Language
English
Primarily Uses
RMMV
Looks like your if statements are firing before the plugin command has a chance to set your variables. When you enter the menu the second time, it's using the values of the first time.

Try putting a wait command in between the plugin command and the first if statement. If that doesn't work, try putting a loop that checks if the variable is set (with an appropriate wait command to stop lag) and then breaks the loop when it detects the variable isn't undefined and then check the if statements.

Also, with that last thing, you'll probably also want something to handle if the player completely cancels the menu as well, as if he doesn't set a weapon at all, the loop would continue forever.
 

TheKeeper

Veteran
Veteran
Joined
Dec 23, 2016
Messages
109
Reaction score
24
First Language
English
Primarily Uses
RMVXA
Looks like your if statements are firing before the plugin command has a chance to set your variables. When you enter the menu the second time, it's using the values of the first time.

Try putting a wait command in between the plugin command and the first if statement. If that doesn't work, try putting a loop that checks if the variable is set (with an appropriate wait command to stop lag) and then breaks the loop when it detects the variable isn't undefined and then check the if statements.

Also, with that last thing, you'll probably also want something to handle if the player completely cancels the menu as well, as if he doesn't set a weapon at all, the loop would continue forever.
Heyla! Thanks for the reply! I tried your first suggestion, and that didn't work. Can you clarify the steps to implementing your second suggestion? I'm not sure how to go about checking to see if the variable is set. Thanks!
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
659
Reaction score
373
First Language
English
Primarily Uses
RMMV
Heyla! Thanks for the reply! I tried your first suggestion, and that didn't work. Can you clarify the steps to implementing your second suggestion? I'm not sure how to go about checking to see if the variable is set. Thanks!
So the first thing you should do it separate the plugin command if statement from the rest of it. The way your event is set up right now, whenever num5 is hit, it pops the plugin command but also immediately starts checking for whatever weapon the player selects. Because there's no wait, this check starts instantly, and only runs one time, most likely before a choice has been made.

After the initial check that opens the plugin commands, you need a separate if check to see when the variable has been set by the plugin command. By putting it into a loop (with a small wait) it will check for the change until it finds one, rather than only check once and not work correctly. I took a look at the plugin, and it appears that if the player backs out of the choice, it sets the variable to 0, so our loop needs to loop forever until the variable is set to either 0 or any other weapon Id. To accomplish this, I set the variable to -1 right before we call the plugin command, and reset it to -1 again at the end of the whole event (after all the change weapon commands would be put in).

When the plugin command is called, and a weapon is selected, it changes variable 41 to the Id of the weapon selected, when it was previously -1. The loop will then detect this as having changed, break the loop, and then use the variable to change equips just like your example. At the end, it sets the variable back to -1, so the next time it is called the same thing will happen again.

Code:
◆If:Script:Input.isTriggered('num5')
  ◆Control Variables:#0041 weapon = -1
  ◆Plugin Command:MapSelectEquip 41 weapon
  ◆
:End
◆Loop
  ◆If:weapon ≠ -1
    ◆Break Loop
    ◆
  :End
  ◆Wait:15 frames
  ◆
:Repeat Above
◆If:weapon = 1
  ◆If:Script:$gameParty.leader()._actorId === 1
    ◆Comment:change weapon
    ◆
  :End
  ◆If:Script:$gameParty.leader()._actorId === 5
    ◆Comment:change weapon
    ◆
  :End
  ◆
:End
◆Comment:reset the variable at the end
◆Control Variables:#0041 weapon = -1
 

TheKeeper

Veteran
Veteran
Joined
Dec 23, 2016
Messages
109
Reaction score
24
First Language
English
Primarily Uses
RMVXA
So the first thing you should do it separate the plugin command if statement from the rest of it. The way your event is set up right now, whenever num5 is hit, it pops the plugin command but also immediately starts checking for whatever weapon the player selects. Because there's no wait, this check starts instantly, and only runs one time, most likely before a choice has been made.

After the initial check that opens the plugin commands, you need a separate if check to see when the variable has been set by the plugin command. By putting it into a loop (with a small wait) it will check for the change until it finds one, rather than only check once and not work correctly. I took a look at the plugin, and it appears that if the player backs out of the choice, it sets the variable to 0, so our loop needs to loop forever until the variable is set to either 0 or any other weapon Id. To accomplish this, I set the variable to -1 right before we call the plugin command, and reset it to -1 again at the end of the whole event (after all the change weapon commands would be put in).

When the plugin command is called, and a weapon is selected, it changes variable 41 to the Id of the weapon selected, when it was previously -1. The loop will then detect this as having changed, break the loop, and then use the variable to change equips just like your example. At the end, it sets the variable back to -1, so the next time it is called the same thing will happen again.

Code:
◆If:Script:Input.isTriggered('num5')
  ◆Control Variables:#0041 weapon = -1
  ◆Plugin Command:MapSelectEquip 41 weapon
  ◆
:End
◆Loop
  ◆If:weapon ≠ -1
    ◆Break Loop
    ◆
  :End
  ◆Wait:15 frames
  ◆
:Repeat Above
◆If:weapon = 1
  ◆If:Script:$gameParty.leader()._actorId === 1
    ◆Comment:change weapon
    ◆
  :End
  ◆If:Script:$gameParty.leader()._actorId === 5
    ◆Comment:change weapon
    ◆
  :End
  ◆
:End
◆Comment:reset the variable at the end
◆Control Variables:#0041 weapon = -1
So I had to tweak your suggestion so that everything is in the initial conditional branch:

Code:
◆If:Script:Input.isTriggered('num5')
  ◆Control Variables:#0041 weapon = -1
  ◆Plugin Command:MapSelectEquip 41 weapon
  ◆
◆Loop
  ◆If:weapon ≠ -1
    ◆Break Loop
    ◆
  :End
  ◆Wait:15 frames
  ◆
:Repeat Above
◆If:weapon = 1
  ◆If:Script:$gameParty.leader()._actorId === 1
    ◆Comment:change weapon
    ◆
  :End
  ◆If:Script:$gameParty.leader()._actorId === 5
    ◆Comment:change weapon
    ◆
  :End
  ◆
:End
◆Comment:reset the variable at the end
◆Control Variables:#0041 weapon = -1
:End
And when I did it this way, it WORKED! It finally WORKED! Thank you, so much! I really appreciate your help!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,483
Reaction score
4,402
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I based this on the armor of Actor 1_7 of the RTP. Hair is from Derex and Sythian Bard.
Stream will be live shortly! Going to do another art stream tonight so that I can finish my Fauna Focus piece~ Feel free to drop by!
Humans are fallible creatures, we all know that. It's when we're forced to look at ourselves that we start to disagree. :p
Expectation: Working on boss battle.
Reality: "Look at how awful are these code and database organization. Let me clean this mess", *yet, casually adding more modules that I have no idea if I would use it later*
Trying to learn to read Japanese so I read my manga. I like to buy them without all the edits made during translation.

Forum statistics

Threads
97,864
Messages
947,444
Members
129,086
Latest member
mikeymastermind
Top