Status
Not open for further replies.

dolarmak

Villager
Member
Joined
Jul 2, 2013
Messages
10
Reaction score
0
First Language
English
Primarily Uses
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?
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,281
Reaction score
9,703
First Language
German
Primarily Uses
RMMV
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...
 

dolarmak

Villager
Member
Joined
Jul 2, 2013
Messages
10
Reaction score
0
First Language
English
Primarily Uses
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.
 
Last edited by a moderator:

dolarmak

Villager
Member
Joined
Jul 2, 2013
Messages
10
Reaction score
0
First Language
English
Primarily Uses
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);
		}
		
	}
	
}
 
Last edited by a moderator:

EagleOne

Villager
Member
Joined
Mar 22, 2018
Messages
18
Reaction score
0
First Language
English
Primarily Uses
N/A
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,281
Reaction score
9,703
First Language
German
Primarily Uses
RMMV
[necro]@EagleOne [/necro]
This topic is two years old and the op hasn't been online since then...

Closing
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts


for anyone who wanted to see the train area in action!
My hand hurts from holding the pen for so many hours none stop...:kaocry:
Froggo32 wrote on Soulrender's profile.
I have to ask, who's on your pfp? The character really reminds me of Edgeworth from Ace Attorney lol. I'm really curious.

I'm trying to port L10nMV.js into XP, may probably (because this is my toy project in hobby) coming to XP, VX, VXA.

Learn more about L10nMV.js : https://github.com/Creta5164/L10nMV.js
L10nMV.js forum post : https://forums.rpgmakerweb.com/inde...r-game-without-modifying-your-project.120813/

Forum statistics

Threads
123,172
Messages
1,154,585
Members
161,536
Latest member
ityuii
Top