Player position tracker

Discussion in 'JS Plugin Requests' started by Marmelada, Dec 13, 2017.

  1. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi all,

    I require a couple of plugins or scripts for a project I'm working on, and I couldn't find any that already do exactly what we need.

    The main plugin we require is a tracker for player position. We would have a small (village) map with max three indoor maps, and wish to have a record of where our players were moving whilst playing. For example, they start in front of their house, get a quest to get some fruit from the store, and we get a list of coordinates they went through to find their way there and back. We would only record position in the main outdoors (village) map; if tracking a couple of indoor maps too is trivial great, but our main interest is the main map. Is a plugin that records their position and exports it to some kind of a readable text file in any form similar to (0,0; 0,1; 0,2; 0,3; 0,4; 1,4; 2,4; 3,4; 3,5; ...) possible? Any alternatives are welcome, if you think you have a better idea than recording their movement on a coordinate grid, please feel free to suggest, but keep in mind we require a level of precision a step-by-step coordinate grid would allow us.

    I found a couple of plugins that sort of seem like they could potentially help, but none of them do exactly what we need in a reliable way. E.g. looking at NeMV - On Step Effect. It is a bit of a stretch, but if any of you see a way to alter the code in a way it would do what we need for tracking player position step-by-step, that would be great.

    Again, any suggestions are very welcome!

    TL;DR - we need a plugin that would record player position step-by-step in (x,y) coordinates on a small consistent map, and export this to a text file or any afterwards readable format.
     
    Last edited: Dec 13, 2017
    #1
  2. Kes

    Kes Global Moderators Global Mod

    Messages:
    21,093
    Likes Received:
    10,715
    First Language:
    English
    Primarily Uses:
    RMVXA
    @Marmelada Would you mind separating this into two request threads. Our experience is that when requests are combined, there is a lot of confusion.
    Thanks.
     
    #2
  3. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    @Kes Sure thing, thanks! I will edit the post now and make another thread.
     
    Last edited: Dec 13, 2017
    #3
  4. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    I wouldn't mind having a crack at this. Do you want to track player movement in between entering and exiting the current map (ex: have a file exported every time), or just have the player movement always be recorded when on the map and have the data exported when requested? (ex : have one big file with Map ID and order of movement?).
     
    #4
  5. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh my, thank you!

    Some detail on the game itself:
    It would be a short game, I'm thinking a series of fetch quests in the same map of a small village that would be 2x the screen size so it involves some scrolling and the players are not presented with the whole map layout in a single screen. We're still debating whether we should include indoors, but it's quite possible that we don't. In that case there would only be one map in the game, a small village. Players would spawn in front of "their house", commanded to get e.g. fish, and then would have to find their way around the map to the fishmonger's and back where they would be given another quest to get e.g. fruit, and so on. After a couple of such quests, the game would simply end.

    When do we want to track them/export the file?
    Since we're not actually with the players at all times it would be best if the movement data recorded and exported on it's own. We still need to discuss the details of the design (it's a scientific study), but I think it's quite safe to say we'd want data from when they start the game (gain control of the character after title screen) until they return to the starting coordinates with received item and press 'interact' to finish the quest. So maybe trigger to start recording could be press of a button to close the quest dialogue, and trigger to export could be coming back to the same coordinate, and pressing the same button to hand over the item thus ending the quest. If such commands can't work as triggers, I can make a second map "Player home", where they would be given the quest, and then we would start recording data on map transition when they leave to the "Village map", and stop on map transition when they come back to the "Player home" map. We'd only be interested in the movement on the "Village map" in that case, and I would lock the door behind them until they get the item so as not to come back home prematurely.

    Please let me know should you have further questions and/or suggestions!
     
    #5
  6. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    This is an early mockup :



    This uses metadata tags to enable tracking on any map and it starts tracking when maps get loaded, I just need to add a few conditions on when to stop/restart tracking and I need to add a file output, for now it just outputs to the console. Also I can probably add a simple script call / switch check to export the data.
     
    Last edited: Dec 13, 2017
    #6
    Marmelada likes this.
  7. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    I have updated the plugin it now outputs to a test.txt file when a default switch is turned on, this only happens once (to avoid having too may files generated from a bug, but that can be changed). It doesnt stop recording movement from then on, but I don't think that is a problem for a shorter type of game, of course that can be changed. edit : changed the plugin to format the text.txt file more nicely and added the option to save multiple times via parameters.
     
    Last edited: Dec 13, 2017
    #7
  8. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you ever so much! I am not fully fluent in JS syntax, but the logic is there and seems sound.

    However, what exactly do you mean it doesn't stop recording the movement? Since we would only check on our players at certain times, I'll randomly say twice a week, there's a chance they'll have played the game more than once. We will correlate their in-game movement to the data acquired by a separate continuously recording machine, so we sort of need a way to sync those data. Data A is provided by a continuously recording physiological machine, Data B is provided by your script, and we need a way to tell at what time point are they acquired in parallel. The point is to be able to read the activity from Data A for different conditions from Data B.

    My idea was to solve this by having the game send initial signal on launch to the other machine, and then periodically send temporal reference points so we make sure we're comparing correct activity to the correct coordinates on the map. Do you reckon the fact that your script does not stop recording, and that our players might play the game more than once create a problem for that?

    EDIT: In any case I will test it on a mock-up I'm working on and see if we get data the way we need to.So it is possible to slightly alter your code in case of potential problems, right?) Oh wow that was fast, you rock! I'll get testing then and let you know how it goes :)
     
    Last edited: Dec 13, 2017
    #8
  9. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    I have update the plugin again, it should now save with a time stamp that corresponds to playtime, it starts a 00:00:00 when the map is first loaded.
     
    #9
  10. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Yup I noticed, thank you. That's a great idea actually, I'll only find a way to send the initial signal to our other machine, and the timestamps should take care of the rest.

    I cannot begin to tell you how much you helped so quickly. I'll build a prototype of the game and start testing your plugin, but it seems like it really should work as intended. We have a meeting about this next week so I'll let you know if we're going to go through with it :)
     
    #10
    Ruiran likes this.
  11. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi @Ruiran!

    Just to let you know that the idea flew in the meeting, so we're working on preparing the study, but I didn't want to bother you during the holidays and then I took a short break myself.

    The thing is, the plugin you wrote works in the sense that it does compute, it doesn't break the game or anything, but I cannot seem to get the output file. I have tried it on my Mac I'm doing this all on, but also on Windows in the lab and I never get the "TestFile.json" anywhere on the disk. I tried both with playtests and deployment versions, of course. Am I missing something obvious, or could you perhaps have an idea of what might be wrong? :)

    Here is some additional info on exactly how I used your code to get better insight in what might've gone wrong:

    I open it in an editor (Notepad+, Coda 2) and exported it to "LudoSavePathing.js". Then I open my prototype game's project folder, open "js" folder within, open "plugins" and c/p "LudoSavePathing.js" there. Then within RPGMV I open the Plugin Manager, and add your automatically recognised plugin from the dropdown menu. Then I open Map properties of each of my three maps and add a note "<Track:true>" (without that note in either of my maps I get an error saying properties of "pathing" cannot be read). Then I deploy and run the game, transition between maps and walk around for a bit, and then exit via: a) closing the window, b) ESC->End Game, c) Game Over event. None of those produce a "TestFile.json" file.
     
    #11
  12. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    So, I should have updated the plugin to not crash when lacking the Track note (you can get it at the same link as before). You should be able to find the file in your savefiles (open game folder, then open save folder), and I believe that while it is formated like a json file the file extension used is .txt . The trigger for the file to be produced is a switch being triggered, however if needed I can add more conditions for the file to be written if you need that.
     
    #12
  13. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Great news @Ruiran , seems I just misunderstood how switches affect your plugin. Just got it to work on a new prototype map and I think it suits all our needs!

    Just one more tiny thing. Since we'll leave our subjects with the game for some time (few days to a week) before we collect the data, we're expecting them to play it more than once. That would also mean we would ideally get a separate file for each time they play. At the moment, we only get test1.txt which gets overwritten with every new run. Simply upping the Max saves creates a storage problem.* I suspect a simple change to the filePath would solve that problem, but since I'm a novice to js I don't feel comfortable coming up with a different definition for that variable. Could you suggest an elegant solution? :)


    *Additional info if needed:
    I tried editing Max saves parameter by upping it from 1 to 20. Triggering the switch (only once) on the following run exported text19.txt and test20.txt at the same time. So I upped it to 50, and the following run produced test49.txt and test50.txt. at the same time. Then I decided to delete the contents of the Save folder, set the Max saves parameter arbitrarily to 20, and run the game a couple of times like so: Start -> Move in a specific different pattern every time -> Trigger switch -> Exit. I ran that three times and expected to get test1.txt, test2.txt, test3.txt, and eventually up to 20. However, I only got test20.txt and test19.txt with the coordinates from the first run.
     
    #13
  14. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    Okay, I'll get to work on it soon. I'll just add an option to have the save automatically export on exiting the game. Also that second part is an odd interaction I'll see what I can do to fix it.

    edit :
    @Marmelada I have updated the plugin, it now correctly names the files (it would name the files counting down before), when exiting through the menu to the main menu, or through a game over the game exports a save file with the current tracked data (resetting after coming back into the game).
     
    Last edited: Jan 10, 2018
    #14
  15. Marmelada

    Marmelada Villager Member

    Messages:
    13
    Likes Received:
    1
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you, no rush!

    Just to be clear, switches work pretty good. It would suit us great if we could have the switch next to spawn, so when subjects return from exploring the map (say, turn in the quest in context of the game), we get the data for that one run (quest). Then even if the subjects do not turn off the game, but immediately get and start another quest, they would come back to the switch and we would get data for the second quest. So switches are quite handy for control, it is not necessary to export on exit.

    The only problem is that I cannot get the code to reliably produce more than one save. We would theoretically like unlimited saves, or at least a high number just to be sure. That's why I though we might just need a different storage scheme, instead of storing "test" + $msaves + ".txt", maybe have it store something like "test" + $n+1 ".txt" where $n=1 so we just get test1, test2, test3 and so on for each time the switch is triggered. That's just an idea of course as I said, $n+1 would probably produce test11 I think, I'm not comfortable with coding that in JS, but I hope it helps conceptually to get my point.
     
    #15
  16. Ruiran

    Ruiran Veteran Veteran

    Messages:
    78
    Likes Received:
    30
    First Language:
    English
    From what I understand you want the feature to have the player be tracked in intervals (during quests but not in between quests? ). I'll add that feature soon, but I can't work on it anymore today ^^. If you set the Max Saves parameter to really high, in the parameters menu you can have a similar result now, I'll probably make it so you can have unlimited saves tomorrow.
     
    #16

Share This Page