Store Player X,Y Location in a Variable?

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Hello, I am wondering if there is any method to make a variable that stores the player's PREVIOUS X,Y coordinates from the time a switch is activated? I know you can have a parallel process running for player x,y location in a variable that activates an event when you are within the parameters of the event (for eventing things like Stealth), but if the page were to switch, does it store the last known data in the variable or is it cleared? If it is stored, can I have an NPC move to that location? How would I call the data from that variable to make an NPC move to that location?


Thanks for any help!
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
I think you would want to have your variables storing the players x and y inside a conditional statement checking if the switch is false. That way after the switch gets set to true it will no longer update the players x and y keeping the last stored values.


Edit: if I am understanding what you are wanting correctly.


Edit2: Also when switching pages if you have values stored in say game variables the switching of the pages will not change the values so it would still use the last values stored.


As for having an npc go to that location I cant think of an easy solution. Reason for this is you have to take into consideration passage settings and plotting a route from where it is to that location.
 
Last edited by a moderator:

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
556
First Language
English
Primarily Uses
RMMV
If I'm understanding what you want then this should work:


Create a switch "StoreNow"
Create a common event "StoreXY"
Make the common event a parallel process with the following commands:

  • Store Player X to a variable
  • Store Player Y to a variable
  • Turn off the "StoreNow" switch

When you want to store the current XY, turn on the "StoreNow" switch and it'll execute the "StoreXY" common event, then turn itself off.


Moving an NPC to that location would likely require a pathfinding script (or some *really* complex eventing).
 
Last edited by a moderator:

Sausage_Boi

Game Dev. "Artist."
Veteran
Joined
Sep 10, 2014
Messages
1,733
Reaction score
681
First Language
Americanese
Primarily Uses
RMVXA
Awesome! 50% of my problem solved! Thank you very much for your help you two.


I am in fact using Theo Allen's Pathfinding script, which will move events to coordinates as defined by the player. However, I am now wondering to myself if there is a method to extract data from the variables with X,Y locations stored? Or does this need to go to script requests?
 

chalkdust

Resource Staff
Restaff
Joined
Mar 23, 2015
Messages
360
Reaction score
556
First Language
English
Primarily Uses
RMMV
I think you should be able to refer to the variable directly using:

$gameVariables.value(index)


Where index = the number of the variable. So if you want to use it in a script call try sticking that directly into the script call where the x and y are supposed to go.
 
Last edited by a moderator:

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,860
Messages
1,017,038
Members
137,567
Latest member
sashalag
Top