(MZ) Is there a code to check if a player is facing Region ID?

Hi, i would like to know if is there any code to check if the player is facing a region ID.
not directly, but you can easily calculate it by event commands

1) two control variables to get the player position
2) four conditional branches to check player facing and add or substract 1 from one variable to get the corresponding facing coordinates
3) get location info to read the region ID from the calculated coordinates.
Spoiler: event example
◆Comment:Get player coordinates ◆Control Variables:#0024 x = Map X of Player ◆Control Variables:#0025 y = Map Y of Player ◆Comment:Adjust based on player facing direction ◆If:Player is facing Down ◆Control Variables:#0025 y += 1 ◆ :Else ◆If:Player is facing Left ◆Control Variables:#0024 x -= 1 ◆ :Else ◆If:Player is facing Right ◆Control Variables:#0024 x += 1 ◆ :Else ◆If:Player is facing Up ◆Control Variables:#0025 y -= 1 ◆ :End ◆ :End ◆ :End ◆ :End ◆Comment:Store region ID of those coordinates in a variable ◆Get Location Info:regionId, Region ID, ({x},{y})
Spoiler: event example
◆Comment:Get player coordinates ◆Control Variables:#0024 x = Map X of Player ◆Control Variables:#0025 y = Map Y of Player ◆Comment:Adjust based on player facing direction ◆If:Player is facing Down ◆Control Variables:#0025 y += 1 ◆ :Else ◆If:Player is facing Left ◆Control Variables:#0024 x -= 1 ◆ :Else ◆If:Player is facing Right ◆Control Variables:#0024 x += 1 ◆ :Else ◆If:Player is facing Up ◆Control Variables:#0025 y -= 1 ◆ :End ◆ :End ◆ :End ◆ :End ◆Comment:Store region ID of those coordinates in a variable ◆Get Location Info:regionId, Region ID, ({x},{y})
Yeah, that would work, but only if the region is only one step away. If I understand the OP correctly, they want to check the whole line-of-sight, right?
If I understand the OP correctly, they want to check the whole line-of-sight, right?
Oh, maybe. I guess we'll find out when they reply.
If I understand the OP correctly, they want to check the whole line-of-sight, right?
in that case they would have to loop through the coordinates in that direction, basically changing the conditional branch +-1 into loops counting to the end of the map.

more difficult to keep track of, but nothing impossible

Original thread: https://forums.rpgmakerweb.com/threads/mz-is-there-a-code-to-check-if-a-player-is-facing-region-id.146863/