Save Objects Position via Variables?

Hello dear Friends,


finally, after a couple of weeks I could understand working with variables.. but not completely. XD


Let me explain my problem.


I want this feature:


The player can pick up an Event (an Item like a Book). If he picks the Item, the item is in the inventory, and disappeared on the Map. Now he can place the book on the other table.


Everything is fine. The Item is gone in inventory, the switch is active again, you can see the book on the map and pickup again if you want.


Now the problem:


If you leave the room, and come back, the Book is on his old position again. 


So my questions:
1. Is there any possibiliy the books new position? It has to be variable, so the Player can choose which object he wants to place where in this room.


2. If I copy the Event, I can move more objects... but for every object copied, I need the double amount of switches and common events... would this be an performance issue?


3. If we can save the position... now the harder question: Is it possible to transfer the Event from one Map to another without making 10000 Events? (Lets Say there are 10 Objects to move to another room)


I hope you can help me a little bit. =)


Thanks everyone!

question.png
easiest way is by script command, and that needs a plugin. For MV, either Shaz' remember event position, or yanfly wrote a more complex variant for a similiar function.


If it were for simple changes, you might be able to do this by pure eventing, but only if you know all possible positions before game start.
Thank you for the fast answer. I will try this in the evening and we will see, if this was the solution! 🙂
If the book that you pick up and the book that you put down are the same event (you're not using an event spawner, or two events and just changing their sprites), my plugin will work.  But the event stays on the same map - it won't let you pick up the book, go to another map, and put the book down and remember its position.
Okay, somehow... both of them are not working for me...


Maybe there is an error in my thinking?
I used this tutorial to make an "change place" feature.












Maybe your scripts will not work this way? =)
@Otomatik_Osman Instead of linking to the tutorial you used, please show us screenshots of your results.


If you misunderstood the tutorial, then only what you did in your project is wrong but not the tutorial itself - and that is much more often the case than a tutorial bein gwrong (they are those, yes, but even then it's faster to solve the problem if you show us what is in your project)
@Andar You are right... this could be right.


So let's start with the Screenshots:


01 -> You can see here a Printer (Item) as Event, which is pickable.


02 -> You can see the event system, what will happen, if player character press a button near the printer, to pick it up.


03 -> You can see here an parallel event, which will locate the future position for the item.


04 -> The common switches in the database (each Map has its own database?)


What I am trying:


-> Save the location forever unless player picks up the item again.


-> Transfer the item to another room (if possible)


Priority:


-> Saving the new location.


I hope I could explain it a little bit. Since the maker is actual in german.. if you want I can set up everything in english.

Spoiler
01.png


02.png


03.png


04.png
1) never, ever and under no circumstances make an empty page have a parallel as a trigger.


The second page of your printer event needs to be triggered by action button, as a parallel process that will cause nothing but lag and trouble.


2) There is absolutely no need for the parallel process storing the player position.


You only need that info directly before placing the printer, so place those two control variable commands before the show text command at the beginning of the common event


3) If you're using Shaz remember event position script, that command needs to follow after the printer is at the new position. That script command stores the current position of the event, so it needs to be placed somewhere before it can store that position.


And please use the spoiler tag for hiding screenshots if you have more than one, makes scrolling easier
So... first of all, my post is now with hidden pictures to spoiler it. Thanks for that info, I have forgotten.. =)


1) Done. Everything works fine as before.


2) Done. For me, it does not make sense actually.. but I think it will work because of the common event. Very nice!


3) ??? XD


I have tried to use the plugin command as event (inside the printer event). There nothing will saved (before or after location variable)


If I want to try to use it in the common event, this will happen:

Spoiler
05.png
None of that would make the event move to that position when the map is next loaded.


Why have a parallel process event constantly update variables based on the player's position?  Just put those commands at the top of the common event, when you WANT to do something based on the player's position.  It is possible that in between your modifying the variable and doing something with it, that parallel process event could be changing it back to what it was.


I also don't see anything in there that affects the position of the event when the map is refreshed.  When you leave the map and return, the events always go back to the positions you set them to in the editor.  Simply moving them like you have just moves them for the rest of the time you're on the map.  The position isn't saved.  That's why you need a plugin or special event handling to move it.


And, as I said, you cannot move an event from one map to another.  Events belong to maps.  If you want the printer to be able to be placed on a different map, then you need a separate event on the other map, and to use switches to determine which one should be visible at any point in time.
If I want to try to use it in the common event, this will happen:

That indicates you did something wrong when using it.


But to find your mistake, we need to see a screenshot of the event where you places the failing command, not a screenshot of the resulting error.


Most likely either a typo, a wrong value, or using the command at the wrong position in the event.
Just to understand the system:


By Shaz' plugin -> SavePos command will save the event on the actual map (it can not move to another map and saved there, which is basically easy to understand).


Here are three some screenshots where I tried. I tried any other plugin command given with Shaz plugin, but this does always create the same error.


I think I can clear this mistake if I would write in the "SavePos" command the coordinates, but that is not the point.


And I have to use this command in the common event window... because if I will do this inside the "printers event", nothing will happen

Spoiler
06.png


07.png


08.png
SavePos cannot be used there, because that common event is not called by a map event - it simply doesn't have any reference to which events position it should save.


You need to use the saveotherpos command, giving the event ID of the printer event.


Or you need to use a set move route command targeted on the printer-event with the script command instead of the plugin command.
Ah sorry, I just forgot to mention, that I also tried "SaveOtherPos Printer".


When I am at home, I will try set move route.


Actually again, thank you very much for helping!
Ah sorry, I just forgot to mention, that I also tried "SaveOtherPos Printer".



That cannot work, because the command is


SaveOtherPos eventId


"Printer" is the event's name, not its ID - you need to use the number there that is the event ID


Based on your other screenshots, the Printer event has the ID 1, so the correct command would be "SaveOtherPos 1", and it would have to be done after the location of that event gets changed.
"Printer" is the event's name, not its ID"



THIS!! And only this was the mistake... XDDD


Oh my God, I thought like other programs, if I change the ID to whatever, then I have to take exactly the new name and not his ID, which is not editable right from his name...


Ok, now.. everything works. 


You helped me a lot! Thank you really! Now I can go on with my project (and now I have to read the terms of use by shaz =D)


Best regards,


Otomatik_Osman

Original thread: https://forums.rpgmakerweb.com/threads/save-objects-position-via-variables.73849/