Moving an event location

I wanted to see if there is another way to do this without parallel processing because I ran into a small issue. I have a lever that turns on a switch and moves 3 barrels (that are events) so you can access a secret room. That all works no problem. The lever event uses a conditional to check to see if the switch is ON, if it is, it doesn't do anything, but if it is OFF then it moves the barrels.


My problem comes when I activate the lever and move the barrels. If I save the game and exit, then load the game to continue, the barrels are moved back by default and the switch is already activated so I can't use the lever to move the barrels again. This forces the player to exit the dungeon and re-enter but if they don't know that will fix the issue, they might get frustrated or whatever. I don't think it would be a huge issue, except that if I have to do some events like this in the future, say in a larger dungeon, where someone might have to save and close down the game at some point. The only way I can think of fixing it is if I make all 3 barrels parallel process and have them use the conditional to check if the switch is ON or OFF. Again, that isn't a big problem either, but I heard that too many P.P.'s can lag the game. I don't have any others on the map atm, if that makes a difference?


Thanks in advance for any help.
Use this: http://yanfly.moe/2015/10/21/yep-19-save-event-locations/
@GreyStone84 It just sounds like you have a weird event setup.


Try this:


For your switch event, you want 3 event pages.





I'm assuming the switch can only be activated because some event occurred. So I set it to where it can only be pulled if switch 0010:Switch is on (I could of used a dif name to prevent confusion but it's late here). Otherwise just disable the condition on page one if you don't want it. The important thing is that the event is set to trigger with the action button. It turns on self switch A and turns off switch 10.


Page 2 moves all the barrels to the right, turns off Switch A, turns on Self switch B and another switch, 0011😛ots. This page is set to Parallel process.


Page 3 activates because switch B is on. It's is just empty with the icon, player can't interact with it anymore.


Now you have a separate event on the map, you can see it in the bottom left corner of the 1st image above.


the setup for this is 2 event pages.


eb34ed98a0d52219d6e6dc65a93252d3.png



Page one is PP and turns on the switch 0010:Switch (again you can remove this if you don't want the lever to be activated that way). It then turns on self switch A.


The 2nd page is the important part. It checks if you pulled the lever to see if switch 0011😛ots is on. If it's on, it sets the location of the pots that I moved. You just place the pots wherever you have the lever move them to. It'll run everytime the player enters the map so they don't have to keep hitting the lever.


With this setup, I don't have the issue of the pots returning to their original spots when I load back into the game either.


Hope this helps.
It'll run everytime the player enters the map so they don't have to keep hitting the lever.


With this setup, I don't have the issue of the pots returning to their original spots when I load back into the game either.


Hope this helps.

Thanks, it kinda helps. I do want the player to hit the lever everytime they enter the map


Thanks, that's actually pretty interesting tool if I need it, but it says MV, I'm running VX Ace. I'm sure Yanfly has a similar script for me, but it does the same thing as @Tsukitsune suggested. I want the events to reset when the player leaves the map.


Thanks again guys, I might just switch it around so the event doesn't reset. I'll keep thinking about it.
@GreyStone84 I really need to start looking at the maker before I answer....

That looks pretty handy, will try it out. Thanks Shaz!


One question I didn't see in the post, I name all my events so I don't get all confused. Your script says I can "specify an event number" if it is not the current event. Instead of the number, can I use the name I gave the event?
no.  You need to use the number.  You could give the same name to more than one event, and then if you used event name, the script wouldn't know which one to use.
no.  You need to use the number.  You could give the same name to more than one event, and then if you used event name, the script wouldn't know which one to use.

Ah, okay. The Event ID stays the same at the top of the window even if I change the name. I just noticed that. Well that makes things easier, thanks again Shaz, you're awesome!
Yep, internally, the engine doesn't care what name you give it.  It refers to events by their numbers.
@Shaz Hey Shaz, small problem.


I have 3 barrels controlled by one switch. They are events so the switch uses Set Event Location to move the barrels. I put all 3 .save_pos() in one script call, but only one barrel's position is getting saved. So I switched to 3 separate scripts, but again only one barrel (the first barrel) is not moving back to it's original spot.


I have nothing else affecting the barrels right now (though I want another event to affect them after I figure this problem out). I have tried moving the set of 3 separate scripts around the switch event, it makes no difference. I've also tried changing the order (so barrel 2 gets saved first) but barrel one is the only one getting saved. Any ideas what's going on?


EDIT: Just tried something and it worked. I wrote these using the Event ID #:


Script: $game_map.events[010].save_pos()


Script: $game_map.events[011].save_pos()


Script: $game_map.events[012].save_pos()


The game would save event 010's location, but not 011 and 012. I changed the numbers to just 10, 11, and 12 and it worked. So, original problem fixed now, but any idea why the game would do that?
because Ruby/RGSS treats numbers with leading zeros as hexadecimal or something like that.  It's not a bug with the script - many scripts have this issue when you use that format for numbers.  NEVER use leading zeros for ids, in any script, not just this one.


You should just be able to put them all into a single Script call:

Code:
Script: $game_map.events[10].save_pos
        $game_map.events[11].save_pos
        $game_map.events[12].save_pos
because Ruby/RGSS treats numbers with leading zeros as hexadecimal or something like that.  It's not a bug with the script

Ya, didn't think it was our script, you're too good, lol. I knew it was user error! Glad I was able to figure it out. Thanks again Shaz, it is working perfectly now!

Original thread: https://forums.rpgmakerweb.com/threads/moving-an-event-location.60872/