checking current event's location

Okay, so I am using EST's decoration script and when an object is placed (event is copied from another location), I want it to check in a 3 block radius of itself to see if another event is near by.


Now I have used $gameMap.isXyHasEventName(/event_name/i,x,y) which is fine if you're always checking the same spot, but i doesn't allow me to check around the event. I was thinking that if i could get the current event's location, set it in a variable and then subtract/add from that I could place that in the x/y variable spot on this script, unfortunatly I'm not sure how to do that. 


i tried: 


        var event_x = $gameMap.events()[this._eventId].x
        var event_y = $gameMap.events()[this._eventId].y


but that doesn't seem to work.


any ideas?
why not use the control variable command to load map x and map y of the event? You don't need script to load that part of the game data...
Edit: well unfortunatly that didn't work. The events check things too slowly, so only 1 event would run in the time i needed. Any other suggestions?


Thanks, I wasn't sure it would work that way with EST Decore mod, but I think i got it working with that and selfvariables mod.
EDIT: a friend on another forum solved my problem. I was using thje wrong syntax on the event command. 


$gameMap._events[this._eventId]._x;


is the correct code if any one ever needs it. I also edited it in the code below.


-------------------------------


Sorry for double posting but here is what I have so far. It works if I set the initial coords to a specific location (ie 4,4) but when ever i try to get the event's coords it goes haywire. I left in variables i was told should work, but aren't. If any one has a solution I would really appreciate it.

Code:
var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;

Game_Interpreter.prototype.pluginCommand = function(command, args)
{
	aliasPluginCommand.call(this, command, args);
	
	if(command == "scarecrow")
	{
		//----- Check if Scarecrow Event is in range -----//
		//$gameMessage.add("checking");
		var sc_event_x = $gameMap._events[this._eventId]._x;
		var sc_event_y = $gameMap._events[this._eventId]._y;
		var sc_event_true = false;
		
		for(var sc_event_y_check = (sc_event_y - 3); sc_event_y_check < (sc_event_y + 4); sc_event_y_check = (sc_event_y_check + 1))
		{
			for(var sc_event_x_check = (sc_event_x - 3); sc_event_x_check < (sc_event_x + 4); sc_event_x_check = (sc_event_x_check + 1))
			{
				if ($gameMap.isXyHasEventName(/scarecrow/i,sc_event_x_check,sc_event_y_check) == 1)
				{
					var sc_event_true = true;
				}
				
			}
		}
		
		//----- End Result ----//	
		if (sc_event_true == true)
		{
			//----Scarecrow is in Range ----//
			//$gameMessage.add("Scarecrow detected");
			$gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], false);
			$gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], true);
		}
		else
		{
			//----Scarecrow is not in Range ----//
			//$gameMessage.add("No scarecrow detected");
			$gameSelfSwitches.setValue([this._mapId, this._eventId, 'A'], true);
			$gameSelfSwitches.setValue([this._mapId, this._eventId, 'B'], false);
		}
		
	}
	
}
Code:
$gameMap._events[this._eventId]._x;

Please consider using:

Code:
$gameMap.events()[this.eventId()].x;

in order to rely on the public methods/variables. Though it does not change the result in current circumstances, relying on the "private" variables should be when you have no other choice.
Necro-post notice: @EagleOne
This topic is two years old and the op hasn't been online since then...

Closing

Original thread: https://forums.rpgmakerweb.com/threads/checking-current-events-location.57800/