[RMXP] How to Change a Tile's Priority Via Script/Event?

Hey, I was curious if anyone could assist me with achieving this. I'm doing this to create a bridge that the player can walk under/over. The closest I've gotten to achieving this is changing the tileset before the player walks onto a bridge, the 2nd tileset having a different priority set for the bridge tiles, though this causes strange visual errors where the bridge tiles flash sometimes. I also should add: I cannot use the method of assigning a series of events the bridge tiles as a graphic, as this clutters the already large maps with even more events, and causes the framerate to tank pretty heavily.

If anyone has any ideas, please let me know. Thanks.

(If it helps to know, I'm using Pokemon Essentials GSC scripts as a base. This means the bridge scripts involved in regular Pokemon Essentials are not present, and copying them over doesn't work due to every other script being different.)
Without using a custom tilemap script, you would have to change the priority for every tile of that graphic. I don't think that's what you want.

Anyways, this should be all you have to do.
Code:
class Game_Map
  attr_accessor :priorities
end
Code:
$game_map.priorities[TILE_ID] = a number between 0 to 5
Replace TILE_ID appropriately. 384 is the first non-autotile of the tileset, incrementing by 1 moving to the right, and by 8 going down.
Without using a custom tilemap script, you would have to change the priority for every tile of that graphic. I don't think that's what you want.

Anyways, this should be all you have to do.
Code:
class Game_Map
  attr_accessor :priorities
end
Code:
$game_map.priorities[TILE_ID] = a number between 0 to 5
Replace TILE_ID appropriately. 384 is the first non-autotile of the tileset, incrementing by 1 moving to the right, and by 8 going down.


Sorry for the late reply. So, I should be adding the first bit of code to the script editor, and the 2nd bit should be what I call via an event? that's what I tried just now, and it seems as if it hasnt changed anything. The bridge tiles still act as if their priority is 4. I have the script call written like this:


[/code]
Code:
$game_map.priorities[701] = 0

I also have 2 duplicates of that, using 702 and 703 for the rest of the bridge.
You sure you are using the correct tile ID? Works fine on a new project on my end.
I can't seem to get it working in a new project either, though I should have the right tile IDs. Would you mind sending me a project that has it set up I can use as a reference?
Here's the Data folder that you can replace in a new project. It is literally all I said to do. I just changed priorities to attr_accessor in Game_Map and set one of the bridge tile's priority to 5. Only one event on the map that does the script call to set it to 0.
Thank you. I didn't realize you were editing the existing Game_Map script, and I instead was adding those three lines to a new script. That cleared up the confusion, this is a much better way of doing things. Thanks again.
This has, however, brought another issue to my attention. It works fine, though when the player is on the bridge, they are able to walk off the edge. If I adjust the passage so that the player cannot do this, they can no longer walk under the bridge when it's priority is high. Is there any way around this? I apologize for continuous issues.
You're probably going to need a scripted implementation of bridges then, but there really isn't a one-size-fits-all solution. The general logic will probably be the same where you give your bridges a certain terrain tag. Game_Character#passable? will need to be aliased to check the terrain tag the character is over. You also need to define the conditions of what determines whether the player is above or below, either with an event or another tile with a different terrain tag (like a blank tile on the top map layer). If it should be above the bridge, that's when you can define custom passibility for the bridge, preventing the character from walking off of it, and also increase the character's z-coordinate.

This also helps with the possibility of having events walk under/over the bridge without causing weird graphical oddities.
I see, well then perhaps a better plan would be to just make the separate bridge tile with it's own passage/priority, and instead of shifting one bridge's priority, just shift tiles? I'm not really concerned about events walking over/under, as currently there's only one instance of that in the game, and it can be moved easily. That being said, I'm not to sure how to go about shifting tiles via script, either. Maybe by a similar edit to Game_Map?
The script call to change a tile's ID on the map:
Code:
$game_map.data[X, Y, Z] = TILE_ID
Z being 0, 1, or 2 (bottom, mid, top layer)
Thanks a lot man, that'll fix all of my problems. I appreciate the help.

Original thread: https://forums.rpgmakerweb.com/threads/rmxp-how-to-change-a-tiles-priority-via-script-event.124005/