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,184
Reaction score
2,817
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
178
Reaction score
178
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
44,192
Reaction score
15,544
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
44,192
Reaction score
15,544
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 Profile Posts

Where would you go if you're looking to hire someone on here? I'm in need of a writer to take my story concept and turn it into npcs/dialog in my game.
Evening humans! How goes the game make?
The anime characters we saw 20 years ago,
still have the same age when we see them now.
Somehow it's strange but also beautiful.
It's like no matter how much we change,
there's certain part of ourselves we can reconnect to when we see them again.
Took a long, long time, way longer than it should to be honest...but I've finally finished the big content update to my demo!
Lots of not good things happening IRL but I'm not gonna let this day end like this. Quote time:
"Success is not final, failure is not fatal: it is the courage to continue that counts." -Winston Churchill

So, keep going, lads. Whatever you do keep going. Until next time.

Forum statistics

Threads
117,253
Messages
1,105,877
Members
153,420
Latest member
doldol
Top