The Curious Case of Event ID's

Orichalcum+

Veteran
Veteran
Joined
Apr 17, 2015
Messages
72
Reaction score
52
First Language
English
Primarily Uses
Im curious as to why a script command I wrote doesn't work. Im trying to Alter Event 6 (006).


$dataMap.events[this._eventId]._eventId = 10
C = $dataMap.events[this._eventId]._eventId
D = $dataMap.events[10].x


Above is the delinquent code. when I try it i get  "TypeError Cannot read property 'x' of undefined". 


I have a message setup to show me output C and D as a message, When I change $dataMap.events[10].x to $dataMap.events[1].x (A completly different, totally unaltered event on the map.)


It tells me that C is = 10 and that D is = to Event 1's X coordinate. 


Also changing C = $dataMap.events[this._eventId]._eventId to   C = $dataMap.events[6]._eventId Still Shows that C is = to 10.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
Are you using MV or Ace?  Ace doesn't have $dataMap.  MV doesn't have events[id].


If you're using MV, it's $gameMap, not $dataMap, event, not events, and (), not [].  So $gameMap.event(10).x


You should not change event ids.
 
Last edited by a moderator:

Orichalcum+

Veteran
Veteran
Joined
Apr 17, 2015
Messages
72
Reaction score
52
First Language
English
Primarily Uses
Its MV, and yeah thats only returning 10 because I told it to on the first line. I didn't think to check  about the brackets.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
Im curious as to why a script command I wrote doesn't work. Im trying to Alter Event 6 (006).



$dataMap.events[this._eventId]._eventId = 10
C = $dataMap.events[this._eventId]._eventId
D = $dataMap.events[10].x


Above is the delinquent code. when I try it i get  "TypeError Cannot read property 'x' of undefined". 


I have a message setup to show me output C and D as a message, When I change $dataMap.events[10].x to $dataMap.events[1].x (A completly different, totally unaltered event on the map.)


It tells me that C is = 10 and that D is = to Event 1's X coordinate. 


Also changing C = $dataMap.events[this._eventId]._eventId to   C = $dataMap.events[6]._eventId Still Shows that C is = to 10.
That's some crazy stuff you're doing and I can't imagine why. Instantly liked it.


Anyway, you can do it like this:


var old10 = $dataMap.events[10];
var oldEvent = $dataMap.events[this._eventId];
oldEvent._eventId = 10;
$dataMap.events[10] = oldEvent;
$dataMap.events[this._eventId] = old10;


This will switch both events completely.


Do note that this will be lost when the player change map or open the menu. Unless you save $dataMap to the map file.

Are you using MV or Ace?  Ace doesn't have $dataMap.  MV doesn't have events[id].


If you're using MV, it's $gameMap, not $dataMap, event, not events, and (), not [].  So $gameMap.event(10).x


You should not change event ids.
$dataMap.events[] exists, $gameMap.events[] doesn't.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
You don't get the x and y from $dataMap.events though, you get it from $gameMap.event(id).  $dataMap.events[id].x will only contain the starting coordinates.  If they've moved, that won't be a true reflection of the event's location.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
You don't get the x and y from $dataMap.events though, you get it from $gameMap.event(id).  $dataMap.events[id].x will only contain the starting coordinates.  If they've moved, that won't be a true reflection of the event's location.
That's right. The event would need to be changed on both $dataMap and $gameMap.


I'll wait for a reason for this before saying anything else.
 

Orichalcum+

Veteran
Veteran
Joined
Apr 17, 2015
Messages
72
Reaction score
52
First Language
English
Primarily Uses
I don't actually need to change an events ID. I was actually working on a system to compare 2 events based on their x cords, y cords, and the direction they are facing. I originally was only planning to use  $dataMap.events[this._eventId]._eventId to store the ID in a variable and  $dataMap.events[variable].x somewhere else to get its cord. I got side tracked while working on it because I wanted to see if the code from the first post was a possibility. 


Copied the wrong section :/
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
There are functions in $gameMap that will give you a list of events on a particular tile.  You could just call that.


$dataMap.events[this._eventId]._eventId


is illogical.  Why would you use this._eventId to go out to $dataMap, look up the event, and return the id?  You've already got the id - that's the index you're using.  So you're doing a lookup to return the value that you've actually used to do the lookup.
 

Orichalcum+

Veteran
Veteran
Joined
Apr 17, 2015
Messages
72
Reaction score
52
First Language
English
Primarily Uses
I need the ID's from more than one event thats going to be copied and pasted on to more than one map. The maps in question already have events on them, So 1 event might have an ID of 2 on one map but 6 on the next one. I know that I can use Control Variables in the event editor, but it would consume 30 or so variables for the x, y, and facings of all the events. Plus it would take more time to set those up. Storing the event id and using that to check the other factors seemed like the fastest method.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,715
First Language
English
Primarily Uses
RMMV
You're still using the event id to obtain the event id of the same event.


What are you making - some kind of cloning plugin?
 
Last edited by a moderator:

Orichalcum+

Veteran
Veteran
Joined
Apr 17, 2015
Messages
72
Reaction score
52
First Language
English
Primarily Uses
The end result is a function that compares 2 events, and returns 1,2,3 depending on where those two events are standing. What Im planning on doing is creating the necessary event one time. That event will have a function that stores its ID in the first available spot of an array. A different function gets the event ID from that array and uses it to get the x, y, and facing. 


EDIT: 

You're still using the event id to obtain the event id of the same event.
Long story, short I didn't know you could simply put  this._eventId I literally just tried that.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,836
Latest member
T62352536256t362
Top