Note: This guide is incomplete and is mainly for JavaScripters at the moment.
Ever wonder if there's a way to get the list of players currently playing The Endless Forest? There is. If you didn't already know, this is the page. All you have to do is inspect the HTML source and you have a list of players playing the game, where they are, and what they're doing.
If that's all you want, feel free to leave this guide. However, I put together some extra modules that may be of use to you.
Introducing: the player collection. This is a Backbone collection I made representing all of the players currently online. By default, once started, it updates every minute, just like the map, populating itself with a list of all players that are online.
This collection keeps a list of players that are currently playing the game. It tells you who (via their pictogram name) is online, what they're doing (sleeping, etc.), and where they are.
You can change the update interval if you wish. However, 1 minute is the minimum. But if you want it to only update every five minutes or whatever instead, you can do that quite easily.
Make sure your code is under the cut, with the blog entry input format set to BBCode.
You need to know JavaScript in order to use this aside from its examples.
First off, there is a lot you can do with this code — it's mostly data. You need to make some code which interfaces with this module in some way. What is it you want to do? Look at some examples and see if any of this seems useful to you.
Place the below code into your blog post. Note that you place the path to the source file into the part where it says YOUR FILE HERE.
<img style="display: none;" src="/community/sites/all/modules/smileys/packs/ToT/redface.gif" onload="var script = document.createElement('script'); script.type = 'application/javascript'; script.dataset.main = 'YOUR FILE HERE'; script.src = 'http://requirejs.org/docs/release/2.1.15/minified/require.js'; document.head.appendChild(script);">
Inside the source file, you're going to want to tell the collection to start updating:
requirejs(["path/to/config.js"], function() { // Note: not a real link. This file lists where all the dependencies are. Exclude if you have defined them elsewhere. requirejs(["collections/gms-player-collection"], function(PlayerCollection) { // Get the dependency. var players = new PlayerCollection(); // Create an instance. players.on("sync", function() { // Do something every time it updates. }); players.startUpdating(); // Now it will gather the appropriate data. }); }
Once you have that, you should be all ready to go. Please note that once you submit your changes, you may need to refresh the page (such as if you are using Chrome or Safari).
Place the JavaScript file for the example you want to use where it says YOUR FILE HERE.
File for this example: here.
A simple thing you can do is check which players are online and where they are. Let's say you want to know where Stria, Talla, Gretai, and Wind are. The following code will populate an HTML element with that information for each player that is online.
<!-- HTML. Place the below code where you want this to show up in your blog entry. Fill in the part that says data-gms-pictogram-list with a space-separated list of the pictogram names you wish to follow. --> <div id="player-collection-example-1" data-gms-pictogram-list="DVe6 ITq1 1MXnx FTg2" style="background-color: brown;"></div>
// This should be part of your JavaScript file. Look at the provided file for this example in its entirety. var players = new PlayerCollection(); // Instantiate a list of online players. $(document).ready(function() { // Wait until the HTML of the page is fully parsed. var exampleBox1 = document.getElementById("player-collection-example-1"); if (exampleBox1) { // Make sure this element exists before attempting to alter it. var pictogramWordsString = exampleBox1.dataset.gmsPictogramList; // Corresponds to data-gms-pictogram-list. if (pictogramWordsString) { // Don't do anything if the appropriate data- attribute isn't filled in. var pictogramWords = pictogramWordsString.split(" "); players.on("sync", function updateBox() { // This happens each time players is updated. var currentPlayers = players.filter(function isPlayerInList(player) { var word = player.get("word"); return _(pictogramWords).contains(word); // Note: Underscore function. }, this); if (currentPlayers.length === 0) { exampleBox1.innerHTML = "None of your players are online."; } else { var outputs = currentPlayers.map(function getStatusText(player) { return player.get("word") + " is online at " + player.get("x") + " x " + player.get("y"); }, this); exampleBox1.innerHTML = outputs.join("<br>"); // Separate each output with a new line. } }); players.startUpdating(); // Start fetching the list of players every minute. } } });
This results in:
Which will update every minute.
If you wish to implement your own behavior, here are some functions you can call on these items.
This tells the collection to start fetching the status periodically from the server. It is best to call this last, after you have all its updating callbacks set up.
This tells the collection to stop updating.
This changes the updateFrequency to the specified number of seconds. Note that 61 seconds is the minimum as that is the same frequency at which the player status page itself updates.
players.setUpdateFrequency(90); // Set the update frequency to every one and a half minutes.
This collection is a Backbone collection. You can read more about those here.
players.once("sync", someFunction); // Do something the very first time the collection is updated. players.first(3); // Get the first three players in the list.
var player = players.sample(); // Get a random player from the list.
Each element in the player collection represents one player. These models have four general attributes: word (the pictogram's name), x position, y position, and state.
Gets the name of the player's pictogram.
console.log(player.get("word")); // Example output: 1Gchy
Gets the x coordinate of the player.
Gets the y coordinate of the player.
if (player.get("state") === 0) { // This player is sleeping. }
Gets the id of the current state of the player. See what they correspond to in this table:
Value | Action |
---|---|
0 | Sleeping |
1 | Sitting |
2 | Standing |
3 | All other actions: eating, drinking, idle action, etc. |
4 | Walking forward |
5 | Trotting forward |
6 | Galloping |
7 | Walking backwards |
8 | |
9 | Listening |
10 | Jumping |
11 | Spellcasting |
12 | Praying |
13 | Dancing |
Note that some are missing and the ones that aren't may be inaccurate. If you would like to help gather the remaining states, play the game and continuously perform an action around the time the player status page updates (every 61 seconds). If you get a number that is not listed in this table, tell me what action gave you that number. I don't know if the states are listed in the game files or elsewhere, so, if you think there's a better way to find them, feel free to comment.
Each element of a player collection is a Backbone model. You can read more about those here.
The code for this module can be found here.
This code is released under GPL v3+. Among other things, this means you can redistribute applications using this code as long as you use the same license and provide the source. Remember to leave the copyright notices where they are. Read about the license here.
Thanks to Hum for initially gathering most of the player state data. Thanks to Aivilo for states 11 and 12, the correction on state 3, and the 61 second rule.
Do you have any questions? Do you find this useful? Did you find any mistakes? Does something not work in your browser? Leave me a comment. Do you have a good idea? Suggestions are always welcome.
If you find something wrong, please leave a description of the anomaly — you don't have to fix it yourself. Also include what browser(s) and what operating system you are using, especially if you notice that the problem doesn't happen on other platforms.
This is an issue with another module of mine and will be fixed as soon as I get to it.
I know this may be a little much for some of you, but I'll try to simplify and explain this as much as possible in the future. For right now, however, this is just a guide for JavaScripters.
ref track. might need this
You damn kids and your freaky
This is ridiculously cool, no joke.
Interesting~
oh?
Player state 11 is casting a
Player state 12 is praying at the Twin God statues.
I just realized I never
Oh, and thank you Aivilo!!! We were kind of stuck on those last few ones. I am wondering what happens if you cast a spell, but not on another player, or if you pray, but not at the twin statues? Or are those actions only available in those contexts? I really hope state 8 isn't mooing.
You can't cast a spell
I also tried: leaping (run + gallop, only reads as gallop I think)
Swimming (reads as standing/other action)
Drinking (reads as 3)
Eating pine cones and mushrooms (3)
Having a spell cast in you (reads as whatever other thing you're doing)
Sneezing
Being in DeDrinkplaats (reads as whatever action you are doing)
I'm reasonably sure none of those are it, but it's possible I mis-timed as well.
Another thing you might note as useful is the player time value. It can be read as YYYYMMDDHHMinMinSS
Year month hour minute second. The page doesn't refresh every minute on the dot. Instead, it renews every 61 seconds - so if you add 1 second to the last two digits you can tell exactly when the Forest will gather information and can better target when to perform an action (I recommend starting 2 to 3 seconds before the sweep, then stop immediately after).
Thank you for your
I didn't notice that! I don't know why, but I didn't think to look more closely at the end of the time. It does seem like it's 61 seconds. I guess I'll make my collection update that often, and to take seconds instead of minutes. Hopefully no one started using that aspect of it yet, if anyone has started using it at all.
track to read more in depth
I am glad to hear that! I
Tracking!
all I have to say is you are
Hey GMSuerte, is there any
Wow, I had no idea this
I have zero knowledge of
Okay, so it turns out this
<img style="display: none;" src="/community/sites/all/modules/smileys/packs/ToT/redface.gif" onload="var script = document.createElement('script'); script.type = 'application/javascript'; script.dataset.main = 'YOUR FILE HERE'; script.src = 'http://requirejs.org/docs/release/2.1.15/minified/require.js'; document.head.appendChild(script);">
I was using inline JS inside links before, and let me tell you, having an external JS file I can tweak and edit separately is SO LIBERATING. Would you mind if I outlined this method in my code thread and linked back here?
^ I actually had a question
Skype
Years later I get an itch to
The number 8 state is braking/stumbling.