How can you use the OR in the conditional branch?

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.png
codes.png
You can use a script call in the conditional branch for this.
$gameVariables.value(1) == 15 || $gameVariables.value(1) == 13

The || is OR
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 😀
You can use a script call in the conditional branch for this.
$gameVariables.value(1) == 15 || $gameVariables.value(1) == 13

The || is OR
Sorry, Im still new to this engine. Can you give me an example.
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 😀

Ahhh I see, omg thats too long, guess Im gonna try to use script call.
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.
@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.
Double-post notice: @minhanthongminh

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
@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?
@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.
@minhanthongminh
There is no limit to a script call that I am aware of.
Are you using this:

2.PNG
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 😉

Original thread: https://forums.rpgmakerweb.com/threads/how-can-you-use-the-or-in-the-conditional-branch.139912/