How can you use the OR in the conditional branch?

an_bit

Villager
Member
Joined
Jul 22, 2021
Messages
9
Reaction score
1
First Language
Vietnamese
Primarily Uses
RMMV
I want to make the player open their inventory and use their item to trigger an common event. But I want them to be able to use it from all 4 directions, so I tried to do it by using if and else, but only the position 15 12 works, when I used item on the other 3 positions, nothing happened. Is there anyway to use OR in rpg maker? Thank you.


or condition.pngcodes.png
 

Tea's Jams

I'm human
Global Mod
Joined
Mar 28, 2017
Messages
1,183
Reaction score
2,815
First Language
English
Primarily Uses
RMMZ
You have all the later conditionals nested in the first one, so only if the first one is true will the next one be run. You would make 4 different conditional statements, one for each direction. A script call would do it in one, I don't know what it would be off hand though.

**Ninja'd by @Pots Talos There's the script call :D
 

an_bit

Villager
Member
Joined
Jul 22, 2021
Messages
9
Reaction score
1
First Language
Vietnamese
Primarily Uses
RMMV
You have all the later conditionals nested in the first one, so only if the first one is true will the next one be run. You would make 4 different conditional statements, one for each direction. A script call would do it in one, I don't know what it would be off hand though.

**Ninja'd by @Pots Talos There's the script call :D

Ahhh I see, omg thats too long, guess Im gonna try to use script call.
 

an_bit

Villager
Member
Joined
Jul 22, 2021
Messages
9
Reaction score
1
First Language
Vietnamese
Primarily Uses
RMMV
You can use a script call in the conditional branch for this.
$gameVariables.value(1) == 15 || $gameVariables.value(1) == 13

The || is OR
Ah, I found it, thanks you very much. It works perfectly.
 

Pots Talos

Veteran
Veteran
Joined
Jun 28, 2012
Messages
175
Reaction score
173
First Language
English
Primarily Uses
RMMV
@minhanthongminh
You could also add AND (&&) into script call too.
So using your above screen shot I don't know what the variable number is for the X and Y so in this script I just used 1 for X and 2 for Y

($gameVariables.value(1) == 15 && $gameVariables.value(2) == 12) || ($gameVariables.value(1) == 13 && $gameVariables.value(2) == 12) || ($gameVariables.value(1) == 14 && $gameVariables.value(2) == 113) || ($gameVariables.value(1) == 14 && $gameVariables.value(2) == 11)

So its if player x is 15 and player y is 12 or if player x is 13 and player y is 12, ect, ect.
This way you can have all your checks in one conditional.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,761
Reaction score
15,318
First Language
English
Primarily Uses
RMMV

@minhanthongminh , please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.



You can use the +Quote button to select multiple posts, then the Insert Quotes button to put them all into a single reply. Or just put @ followed by the person's name to tag them without actually quoting their entire post.

The above does not take the player's facing direction into account. So you could be standing on the tile below the event, facing any direction other than up, and use the item from your inventory, and it will work. Try it and see if that's what happens. Is that what you want?

If not, rather than testing where the player is standing, you can test what tile they're facing (where they would be standing if they took one step forward), and that will work no matter which tile they are standing on.

For this, you would do something like this:
Code:
Control Variables: Next X = Script: $gameMap.roundXWithDirection($gamePlayer.x, $gamePlayer.direction())
Control Variables: Next Y = Script: $gameMap.roundYWithDirection($gamePlayer.y, $gamePlayer.direction())
Conditional Branch: Next X = 14
  Conditional Branch: Next Y = 12
    ... whatever will happen if the player is standing on one of the 4 touching tiles, facing inward
  End
End
 

an_bit

Villager
Member
Joined
Jul 22, 2021
Messages
9
Reaction score
1
First Language
Vietnamese
Primarily Uses
RMMV
@Shaz Sorry, Im still new to this engine and forum, it should be like this right?

And your method works so much better, I didnt even think about that, thank you very much!
Also I dont understand the $gameMap.roundXWithDirection part, what does it do?
 
Last edited:

an_bit

Villager
Member
Joined
Jul 22, 2021
Messages
9
Reaction score
1
First Language
Vietnamese
Primarily Uses
RMMV
@Pots Talos Thank you! But I cant paste them all in one script box, I think its too small. Is there anyway to expand it?

@Pots Talos Ah my bad, I tried copy again and it works, idk why lol.
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,761
Reaction score
15,318
First Language
English
Primarily Uses
RMMV
roundXWithDirection and roundYWithDirection take an x or a y coordinate and a direction, and returns the x or y coordinate that is one step in the specified direction from the original spot.

you also double posted again. Please reply to everyone in a single post, or edit your post and add the second reply, rather than posting twice in a row. You got the tagging right though ;)
 

Latest Threads

Latest Posts

Latest Profile Posts

I'm gonna put my project on pause for a tiny bit so I can explore the engine outside of it... Winging it can only get you so far LMFAO
Have seen some of my favorite people here posting and helping others with questions today -- love to see it!
Haven't been on here actively in awhile, project is going strong my biggest issue is the STORY, i'm refining the plot and learning so much i decided to take a writers class to improve even more but the programming and functionality of the game is stepping up nicely!
Hi everyone! Here's what I'm working on today! It's one of the dorms on campus. I know I said I wouldn't use assets but I reused a few things from the cafeteria hehe.
FCuxBOMXMAICK5e
I added a little squish effect when characters change direction to try and make things a bit more lively. Though it's a bit hard to see on the fast moving guys.
2f4fiuy.gif

Forum statistics

Threads
116,125
Messages
1,095,972
Members
151,537
Latest member
Anrirck
Top