Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

How to change an event's self switch from a different event. <solved>

Desro

Villager
Xy$
0.00
I've set up an event; within the event there are move routes for multiple events. I would like to know how to use JavaScript in a Script command from one of the move routes to change a different event's self switch so that it can display text messages on the screen.

Right now I'm looking through the rpg_core rpg_objects and the other .js files and am currently lost as to what command I wo0uld use. I'm looking for any suggestions. I'll read through the coding and try a few commands and edit this post for reference.
 

Robert Lee

Villager
Xy$
0.00
Maybe this is a dumb response but why are you using a self switch, use a global switch value which you can change from any event? No JavaScript needed.
 

Desro

Villager
Xy$
0.00
Maybe this is a dumb response but why are you using a self switch, use a global switch value which you can change from any event? No JavaScript needed.
Actually, I do have it set up like that as it is... and it works fine. I just wanted to know for personal reference. I believe it would be more efficient to change just the single event's self switch instead of creating a global switch. Why name a whole global switch when I only need it for a single scene?

I found something called command123 in the Game_Interpreter prototype that seems to correspond with the ~Event Commands JSON data structure in the MV Help file's JS Library. I just haven't figured out how the commands work.

I'm messing with
$dataMap.event(17).command123[1];
but it's still giving me a type error saying that undefined is not a function.
 
Last edited:

Robert Lee

Villager
Xy$
0.00
Why name a whole global switch when I only need it for a single scene?
Actually I would have said because it is appropriate. If you use a switch in one event and want to change it from another event you use a global switch. Whether it will be used once or one hundred times is irrelevant what is important is using the appropriate data type.

You said you have it working using a global switch so why fix what isn't broken? Is that efficient of your time? I know nothing about the internal workings of MV but it seems to me that a self switch or a global switch will use the same resources, they both hold an on/off value and if the coders were any good then the same internal code will be used regardless of the type of switch so I do not see what 'efficiency' you may gain from changing to a self switch.
 

Desro

Villager
Xy$
0.00
Actually I would have said because it is appropriate. If you use a switch in one event and want to change it from another event you use a global switch. Whether it will be used once or one hundred times is irrelevant what is important is using the appropriate data type.

You said you have it working using a global switch so why fix what isn't broken? Is that efficient of your time? I know nothing about the internal workings of MV but it seems to me that a self switch or a global switch will use the same resources, they both hold an on/off value and if the coders were any good then the same internal code will be used regardless of the type of switch so I do not see what 'efficiency' you may gain from changing to a self switch.
This is for reference purposes. I wouldn't understand the opposition to learning this information. I want to know how to use the command so that I may further understand the other JavaScript commands available. The efficiency would be more obvious if I wanted to start multiple event actions off in a single move route via the script command. Instead of say, creating 10 global switches or deal with the keeping track of a global sentry variable, I could set off 10 event self switches that will be gone as soon as I move on to a new map.
 

Robert Lee

Villager
Xy$
0.00
I am learning too, my asking questions is to learn as well. I have started using global switches because I can give them appropriate names which makes my coding clearer when I look at it maybe months later! Now you are telling me you think there might be a better way. By asking what may seem to be difficult questions I hope to get proof and not just an opinion because if I change now to how you are suggesting doing it would require quite a bit of reprogramming.

I would like to point out an error in your logic if I may. The event self switches are not gone when you move on to a new map. They remain as they are last set should you re-enter the map. Try it, you will see that they also are global, do you see what I am saying about your suggestion that doing it your way would be more efficient.

Maybe someone who knows more about the internal workings of MV could chip in with whether one or other method uses more or less resources. The reason I am interested is that I have been playing with an HTML version of my game and I find that it sometimes slows down dramatically in the browser tempting me to look for better (meaning less resource intensive) ways of doing things within MV, and within the game itself....
[doublepost=1465402000,1465401343][/doublepost]just saw this in another post... looks similar to what you want???

$gameSelfSwitches.setValue([1, 3, 'A'], false);
 

Desro

Villager
Xy$
0.00
Thats exactly the command I found. Someone also provided me with https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/edit?pref=2&pli=1#gid=0, it's a great list of available commands.

As for the efficiency, let me explain what I'm doing, and perhaps you will see it another way. In one of my events, I set the move route of many events - right now I'm looking at about 10 events moving around at once. However, in the event, the move routes are started one after another without any of them waiting for the previous to complete. Within the move route command within MV, there is no ability to change a variable, so I'm left with global switches that must be named and kept track of; there is no option to use a variable to set up a sentry count. Since there are 10 event move routes, I would need 10 of these named switches and I must go through each event to make sure that the right switch is set to trigger each of their pages.

However, if simply set their own self switches from within their own move routes, I could copy and paste each and every single event simply making sure that the key within the command you provided is changed. This leaves no need to create 10 switches for what is potentially only a scene that will be a minute long. Now, as soon as each event gets to a point in their move route, their self switch is flipped, and the functionality is the same as using a global.

However, you no longer can access the switch from a different map in the game WITHOUT a script. I feel the globals are for events that must interact with events on other maps, if the event is happening on a single map, I believe this option is better though more advanced. Without the use of scripting, though, the way you recommend with the globals is really the only way you an within the RPG Maker MV.
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
Most script calls available won't be processor heavy, or lag the game. MV in general is built on..I believe Pixi.js v 2.2 , Pixi in general is a very fast renderer but this exact version is buggy and the latest version is Pixi v.4 so you can understand the amount of bugs fixed from that version to the latest version. So, if you notice lag on your browser just deal with it for now because I was speaking to one of the newer developers and he said MV has already implemented the latest version of Pixi and they're just waiting on all bug reports before releasing it. That being said you should see a dramatic increase in performance on mobile and browser eviroments.
As for the self-switches you're attempting to change from another event, there is nothing wrong with doing this and sometimes it's the best option to choose, myself being a programmer love using script calls/ plugins to solve issues with MV but as someone here mentioned using global switches are just as good but there can be some cases were using only the local self-switches is what you want to alter, either way it's up to the developer to choose the best option.
 
Top