Plugin Modif: Galv ActionIndicators - Adding Player Direction Conditions

Hi.

The ActionIndicators plugin from Galv allows an event to display an icon from the iconset.png, directly above it (as seen on the picture bellow).
It displays when the player is touching the event. If the event is under the player, the icon will display once the player walks on it.

To work, the plugin uses a comment call in the concerned event page (ex: <actionIcon: 67>)

action-indicators_zps1h62phzu.jpg


However, the icon will appear no matter the player's direction.

My request is this one:

Would it be possible to customise the plugin, so it's possible to chose from what direction the icon will display ?

I'm no coder/scripter, but the idea I have would be to use the numbers 1,2,3 and 4 to state from what direction the icon will display (ex: <actionIcon: 67,1,3>)


The Galv terms of use allow modification for personnal use, but no sharing.
The plugin can be found here http://www.mediafire.com/file/c8c5ia5c7307w5q/Action_Indicators_MV_v.1.4_(PLUGIN).zip

Thank you for your time!
Open the script in a text editor and find the function at line 168 "checkEventForIcon".

Replace the whole function with the code below.

Code:
Galv.AI.checkEventForIcon = function(event) {
    var icon = 0;
          
    if (event.page()) {
        var listCount = event.page().list.length;
      
        for (var i = 0; i < listCount; i++) {
            if (event.page().list[i].code === 108) {
                var iconCheck = event.page().list[i].parameters[0].match(/<actionIcon: (.*)>/i);
                if (iconCheck) {
                    var directions = iconCheck[1].split(',').map(function(a){return Number(a);}).slice(1);
                    if (directions.length > 0) {
                        if (directions.contains($gamePlayer.direction())) {
                            return {'eventId': event._eventId, 'iconId': Number(iconCheck[1].split(',')[0])};
                        } else {
                            return null;
                        }
                    } else {
                        // create target object
                        return {'eventId': event._eventId,'iconId': Number(iconCheck[1])};
                        break;
                    }
                };
            };
        };
    };
    return null;
};

Now you can use the comment tags like:
<actionicon: 39, 4, 6>

It works fine with spaces in between but it must have commas.
<actionicon: 39,4,6> ---> OK
<actionicon: 39, 4, 6> ---> OK
<actionicon: 39. 4. 6> ---> not OK

2 --> down
4 --> left
6 --> right
8 --> up

If you leave the comment tag like normal, it still works from all directions.
<actionicon: 39> --> Works from any direction
@Aloe Guvner

Works wonders.

Thanks, again, always there to save me! :LZYcool:👍

Original thread: https://forums.rpgmakerweb.com/threads/plugin-modif-galv-actionindicators-adding-player-direction-conditions.91779/