Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * TEFc Library
- * Copyright (C) 2014-2015 GMSuerte of TEFc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- requirejs(["https://artsja.at/tef/js/require-config.js"], function() { // Load configuration file.
- "use strict";
- requirejs(["underscore", "jquery", "collections/gms-player-collection"], function(_, $, PlayerCollection) { // Load dependencies.
- 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) {
- // Add one of the following two codes here:
- //
- // CODE 1: gets basic asleep or awake status only
- //
- // if (player.get("state") == "0") {
- // var playerState = "asleep in the Forest";
- // } else {
- // var playerState = "awake in the Forest";
- // };
- //
- // CODE 2: gets ALL current player states:
- //
- // switch(player.get("state")) {
- // case "0":
- // var playerState = "asleep in the Forest";
- // case "1":
- // var playerState = "sitting in the Forest";
- // case "2":
- // var playerState = "standing in the Forest";
- // case "3":
- // var playerState = "doing something";
- // case "4":
- // var playerState = "walking in the Forest";
- // case "5":
- // var playerState = "trotting through the Forest";
- // case "6":
- // var playerState = "galloping through the Forest";
- // case "7":
- // var playerState = "walking in the Forest";
- // case "8":
- // var playerState = "stumbling through the Forest";
- // case "9":
- // var playerState = "listening to the Forest sounds";
- // case "10":
- // var playerState = "jumping through the Forest";
- // case "11":
- // var playerState = "casting spells";
- // case "12":
- // var playerState = "praying in the Forest";
- // case "13":
- // var playerState = "dancing in the Forest";
- // };
- // assigns deer name to true name
- switch(player.get("word")) {
- case "0000": // your deer's true name
- var name = "Deer0" // your character name
- break;
- case "1111":
- var name = "Deer1"
- break;
- case "2222":
- var name = "Deer2"
- break;
- // Add more accounts by using the same format:
- // case "3333":
- // var name = "Deer3"
- // break;
- //
- };
- return "<a href=http://endlessforest.org/machine/playerpage.php?symbol=" + player.get("word") +">" + name + "</a> is online at " + player.get("x") + " x "
- + player.get("y") + " Status: " + playerState; //returns html text.
- }, this);
- exampleBox1.innerHTML = outputs.join("<br>"); // Separate each output with a new line.
- }
- });
- players.startUpdating(); // Start fetching the list of players every minute.
- }
- }
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement