Trigger Event Page Once Upon Map Entry

Status
Not open for further replies.

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Just curious if there is a way to trigger an event once every time you enter a map.
I'm aware it's done via using an erase event command afterwards, but I actually want to use the other pages of the event too.

So I'm curious if there's some way to erase the event page of an event, so I can make use of the other pages afterwards.
I have a work around, which is just making an accompanying autorun erase event with the event with other pages, but still asking if there's another method.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
What are you trying to achieve? If you want something to run every time you enter the map, you will use a parallel process event (if you want the setup to happen before the player sees the map) or autorun (if it's a cutscene type thing that you want the player to see after the map loads, and you want to disable their ability to do stuff while it's happening), and you set it to Erase Event at the end of the commands.

If you want to use the other pages of the event, then you should be using separate events. You can't change event pages with conditions like self switches and then have it go back to a default page on each map load.

Perhaps you should explain what the event is, what you want to happen on every map load, and what the other event pages are that you want to be able to use. Ambiguous questions lead to ambiguous advice. Specific questions, with all the necessary details, will lead to specific advice tailored to what you're trying to do.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
What are you trying to achieve? If you want something to run every time you enter the map, you will use a parallel process event (if you want the setup to happen before the player sees the map) or autorun (if it's a cutscene type thing that you want the player to see after the map loads, and you want to disable their ability to do stuff while it's happening), and you set it to Erase Event at the end of the commands.

If you want to use the other pages of the event, then you should be using separate events. You can't change event pages with conditions like self switches and then have it go back to a default page on each map load.

Perhaps you should explain what the event is, what you want to happen on every map load, and what the other event pages are that you want to be able to use. Ambiguous questions lead to ambiguous advice. Specific questions, with all the necessary details, will lead to specific advice tailored to what you're trying to do.
Eh, I left it ambiguous because I just wanted to know if it was possible to temporarily erase event pages in eliminating my thought processes.
I'm trying to allow an event to output its Map X & Y locations upon map entry.

My current method has a potential problem where a parallel event is running at the same time of an autorun event (I want the parallel to run first). I've read they run at the same time, but I've also read (at least for VX Ace) that parallel events run before the map visually appears while autorun events run after the map appears - guess that's not the case.

My next approach is figuring out if I can use script command to obtain the Map X & Y location of an event with a notetag (This way I eliminate the need of the parallel process). And no, I don't want to specify an event for the Map X & Y location - it's less tedious if I can reference a notetag.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
For Ace, parallel process events run first, and autorun events only ran once the map was visible. With at least the first version of MV, even autorun events seemed to run prior to the map being visible.

You could simply begin your autorun event with a Wait 30 Frames (half a second) to ensure the parallel event has completed.

If you are using note tags, that implies you are using a script. A link to the script might be helpful, as well as a further explanation of WHAT you are trying to achieve - WHY do you want the event to output its x and y location?

Unless your script changes where an event appears, the x and y location of an event when you enter the map will always be exactly where you put it in the editor.


Please don't quote entire posts when you're replying right after them. There's no need - especially when you're not replying to a specific part of the post (and when you are, quote just the bit you're replying to, not the whole thing). It makes the thread overly long and difficult to read.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Um, sorry. Just used quote to give you the notification. Including a wait should work, but I've seen you comment in another topic that it isn't advisable to run two autoruns (well, autorun + parallel since they run at the same time now?) at the same time, lol.

I'm not using a script (Edit: By "script" I assumed a plugin, lol). I have an elaborate event system and, besides it being too elaborate to explain, I don't really wanna discuss the system publicly. So I just wanted to check if certain options were available to me with my question.

Actually, at the moment my event's location cannot change, but I want to include functionality to facilitate for that if I or anyone else would like to have the events be able to move. I have scripted the following for obtaining an event ID with a specific note:

Code:
◆Script:var allEvents = $dataMap.events
:      :for (var e = 0; e < allEvents.length; e++) {
:      :        if (allEvents[e] === null) { continue }
:      :        var eventId = allEvents[e].id
:      :        var eventNote = allEvents[e].note
:      :if (eventNote == 34) {
:      :   var markedEvent = eventId; console.log("Entered");
:      :   $gameVariables.setValue(26, markedEvent);
:      :}
:      :}
So now I think I no longer need the additional parallel/autorun event. The primary autorun event would scan the map for an event (it should never have more than one on a map) with a specific note tag, and if it finds such, obtain the Map X & Y of that event ID. I don't know offhand how to do that though (and my method above isn't the best, I guess), but I'm retiring for now since my eyes hurt.

Edit 2: Oh wait. I could skip obtaining the id and go straight for the x and y, lol. I think.

Edit 3: Yea, this works:
Code:
◆Script:var allEvents = $dataMap.events
:      :for (var e = 0; e < allEvents.length; e++) {
:      :        if (allEvents[e] === null) { continue }
:      :        var eventNote = allEvents[e].note
:      :        var eventX = allEvents[e].x
:      :        var eventY = allEvents[e].y
:      :if (eventNote == 34) {
:      :   console.log("Entered");
:      :   $gameVariables.setValue(26, eventX);
:      :   $gameVariables.setValue(27, eventY);
:      :}
:      :}
For the moment I think my curiosity is resolved. Unless there's something risky/bad in my coding.

Edit 4: No. I would probably need to know how to pick out specific note tags for the check. Such as if an event has the following note tags: Bird <Fly> 12

How can I specifically check for any (Bird / <Fly> / 12) for my
"if(EventNote == 34)" part. I need to rest my eye now though, lol.
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
It isn't advisable to run two autoruns at the same time. Parallels and autoruns are not the same thing. And if you put a Wait at the start of your autorun, the parallel event will have erased itself by then.

Try something like this:
Code:
var evt = $dataMap.events.filter(function(e) { return e && e.note == 34 });
if (evt) {
  $gameVariables.setValue(26, evt[0].x);
  $gameVariables.setValue(27, evt[0].y);
}
This is using the array filter function to pull out the event you want. The if (evt) checks for the possibility that no event was found. The rest assumes that only one will have the required note so it'll grab the x and y into the variables without having to create a temporary variable to do it.

Let's have a look at your code. It will work, but you're creating and assigning values to 4 temporary variables that you don't need. You're also assigning the event's X and Y location for ALL events, not just for the one that matches your condition. Here's another way to do it without using temporary variables (you're halving the number of assignments you need to do with each iteration) - see if you can understand what I've done here, and how it's different (and a bit faster) than yours, but still does the same thing:
Code:
for (var e = 0; e < $dataMap.events.length; e++) {
  if ($dataMap.events[e] === null) { continue }
  if ($dataMap.events[e].note == 34) {
    console.log('Entered');
    $gameVariables.setValue(26, $dataMap.events[e].x);
    $gameVariables.setValue(27, $dataMap.events[e].y);
  }
}
but using the filter command above will stop you having to do the iteration yourself.

To give someone notification that you've replied without quoting their whole post, just put @ followed by their name, like @Rink27 :)
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
@Shaz Thank you. I think the topic is solved now then. I'd report it (If you're gonna close it) if anything arises.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
From a plugin standpoint I have the same conundrum.
I've just been doing it with...
PHP:
Game_Map.prototype.setupOld = Game_Map.prototype.setup;
Game_Map.prototype.setup = function(mapId){
   if(mapId !== undefined && mapId > 0){
       // run my script
   }
   return this.setupOld.apply(this, arguments);
}
...but it feels like the wrong way to do it.

EDIT:
I'll just edit this post since this thread is soon to be closed and this is not my own thread.

In plugin and not events because it is for a plugin.
I could call first, that's a thing too. I just don't need any of the 10 variables it sets. It didn't seem to make a difference.

I feel like I'm missing a more obvious route like a proverbial $gameMap.addLoadListener of sorts.

@Shaz
\/
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
report it and a mod will close it. I am not a mod.

@mogwai you want to run the aliased version first, because if you do anything with events, it'll be the events on the OLD map, which are about to be replaced. But I'd question why you're doing it in a plugin and not using events. You should start your own thread though.
 

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
@Shaz Oh, I'm so sorry. I've read your caption thingy before, but forgot and thought you were cause to me you have such an authoritative impression, lol.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
lol - is that your way of saying I'm bossy?

I don't have a lot of time so I'm usually pretty straight-to-the-point. That often comes across abruptly.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top