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,144
Reaction score
15,535
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,144
Reaction score
15,535
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

I'm feeling rough today, a bit too many last night I'd say. Still have no choice to work on Corpse Mansion. That and I got. bunch of sales last night. I was like wtf this morning, next payout is gonna be nice at least.
I'm just so close to replacing LUK with a different stat, maybe DEX but we'll see.
Slapped together a title screen and working on some dungeon clutter + portraits for Dubhghaill and Einar. Usual CW for minor body horror wrt Einar
QVLJIgD.png

OaPcYUy.png

r55FiUJ.png

EIgO94y.png
cT1V4nb.png
>studying for months for an exam
>does exam
>waits 3 months for the results to come out
>me trying to login, incorrect password
>I get recovery password
>me trying to login, incorrect password

What the heck. As a son of a Karen, I'm going to file a few complaints.

Forum statistics

Threads
117,149
Messages
1,104,971
Members
153,229
Latest member
jimproringtones
Top