What is the correct script

I'm trying to use a script to check if my event comes into contact with a particular region. region 6, and if it does i'm going to have it move faster.  This is what i have so far


pic13.PNG


but it is not doing anything when i click on it with the action button. I tried typing 6 after the words regionId and replacing the Id with 6 but nothing. I'm guessing my script is wrong as i looked at replies to similar questions and pieced it together. Would be grateful if someone could point me in the right direction.  Thanks
I suggest you don't use any script at all for this - use the event command "get location info", that can get you the region ID of any specified or variable location.


You'll need to load the event location into two variables with the control variable command and then load the region ID into a third variable with the get location info command.


And then you can compare that number with the 6.


And that by the way is your main mistake - the map itself has no region ID, only positions on the map have regions - and each position can have a different region ID.


So any script would have to include the coordinates of the position you want to check, and that is not included in your code.
would it be easier then to have a script check if an event touches another event, if so what would i need to write for that?
@mashpotato no, the easiest way is to do it completely without scripts, like I described in my answer above.


Scripts are the wrong way to go in such a case - the event commands are there for a reason, specifically because a lot of things are easier done in events and not as scripts.


A script to check if two events touch is extremely difficult, because it would have to be included into the game loop for constant updates.


There are a lot of newbies who constantly call for scripts, but if you check the answers from experienced users you'll find that a lot of them advice against scripts unless they're really needed. Or in other words: do you always start your 20-ton-cargo van when you want to go to the shop in 50m distance to purchase a single pack of eggs? Don't you agree that the van would be a bit over-sized in such a case, especially comparing the fuel use?


Everything in the RPG makers has its specific use - there are uses for scripts, but other things are better done with event commands.
Code:
//First you need to use $gameMap.regionId properly, this is a function and has 2 arguments.
//$gameMap.regionId(x,y) this is how it should be used, so for your case, we'll be using the events x and y location.
$gameMap.regionId($gameMap._events[2]._x, $gameMap._events[2]._y) // this would tell you the region ID your event is standing on.
//or to simplify things, you could also use the following to get the same effect.
$gameMap._events[2].regionId()
//now you have to compare it, as this returns the region ID, and you said you want this to happen when the event is on id 6.
//your code should look something like this.
$gameMap._events[2].regionId() === 6
Okay that's great to know.  Thanks for all the help, you're explanations are very useful, because of them i have found a way to do everything with variables.


Is there a reason why the change actor image might not work.  I have chosen it as a parallel process when the level starts but it is doing nothing. It did work until I added some text, to the same event and now it won't.  I've tried deleting the text but still nothing. I tried calling it on the previous map before the transfer but still nothing.pic14.PNG
Is there a reason why the change actor image might not work.



Oh, it works - most of the time something goes wrong with it is because the user doesn't understand how to use it. It is a series of steps that are needed.


The first step is to select which actor to change the graphics for - this is done by the drop-down menu.


Then you need to doubleclick on the pictures to select which images to change to, because by default the pictures shown are those that are the defaults set for that actor in the database.


Let's check your command in the screenshot:


You choose to change the image of the actor number #0005, which you have given no name to in the database.


Currently you decided to set the face and the SV-Battler to none and the sprite to cookies(3).


Is the actor 5 in your party at that moment? Most parties start with the first actors only.


Did you even click on the faces to change the selection for the face to none or what were you trying to do?


If you did everything correct and there are no changes, was the actor perhaps re-initialised later? If you keep the "initialize" checked on adding a member, all changes to that moment will be discarded and the actor added like he was set in the database.
I chose the face and battler as none because all i need is my character to appear as an arrow so i may move them along a bar and activate a switch when they touch it.  So the actor is not part of my party and I haven't added them to my party as I just needed the first character to change appearance.


I have found a way to do what I wanted without the use of the character at all now, but i'm still confused why it didn't work.  Would be useful for the future in case I need to change them another time.


Thanks for your reply
So the actor is not part of my party and I haven't added them to my party as I just needed the first character to change appearance.

You can only change the appearance of a specified actor, and that change will only be visible if that actor is in the party.


If you want to change the appearance of the first party member, then you need to find out which actor that party member is (for example by control variable:game data:member#1's ID) and change the appearance for that actor, not for actor #5. Which requires different change actor commands placed in conditional branches checking which actor to change.
okay, that's great, thanks

Original thread: https://forums.rpgmakerweb.com/threads/what-is-the-correct-script.61545/