Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * TEFc Library
  3.  * Copyright (C) 2014-2015 GMSuerte of TEFc
  4.  *
  5.  * This program is free software: you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation, either version 3 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. requirejs(["https://artsja.at/tef/js/require-config.js"], function() { // Load configuration file.
  20.     "use strict";
  21.    
  22.     requirejs(["underscore", "jquery", "collections/gms-player-collection"], function(_, $, PlayerCollection) { // Load dependencies.
  23.         var players = new PlayerCollection(); // Instantiate a list of online players.
  24.         $(document).ready(function() { // Wait until the HTML of the page is fully parsed.
  25.             var exampleBox1 = document.getElementById("player-collection-example-1");
  26.             if (exampleBox1) { // Make sure this element exists before attempting to alter it.
  27.                 var pictogramWordsString = exampleBox1.dataset.gmsPictogramList; // Corresponds to data-gms-pictogram-list.
  28.                 if (pictogramWordsString) { // Don't do anything if the appropriate data- attribute isn't filled in.
  29.                     var pictogramWords = pictogramWordsString.split(" ");
  30.                     players.on("sync", function updateBox() { // This happens each time players is updated.
  31.                         var currentPlayers = players.filter(function isPlayerInList(player) {
  32.                             var word = player.get("word");
  33.                             return _(pictogramWords).contains(word); // Note: Underscore function.
  34.                         }, this);
  35.                        
  36.                        
  37.                         if (currentPlayers.length === 0) {
  38.                             exampleBox1.innerHTML = "None of your players are online.";
  39.                         } else {
  40.                             var outputs = currentPlayers.map(function getStatusText(player) {
  41.                                
  42.                                 // Add one of the following two codes here:
  43.                                 //
  44.                                 // CODE 1: gets basic asleep or awake status only
  45.                                 //
  46.                                 // if (player.get("state") == "0") {
  47.                                 //  var playerState = "asleep in the Forest";
  48.                                 // } else {
  49.                                 //  var playerState = "awake in the Forest";
  50.                                 // };
  51.                                 //
  52.                                 // CODE 2: gets ALL current player states:
  53.                                 //  
  54.                                 // switch(player.get("state")) {
  55.                                 //     case "0":
  56.                                 //         var playerState = "asleep in the Forest";
  57.                                 //     case "1":
  58.                                 //         var playerState = "sitting in the Forest";
  59.                                 //     case "2":
  60.                                 //         var playerState = "standing in the Forest";
  61.                                 //     case "3":
  62.                                 //         var playerState = "doing something";
  63.                                 //     case "4":
  64.                                 //         var playerState = "walking in the Forest";
  65.                                 //     case "5":
  66.                                 //         var playerState = "trotting through the Forest";
  67.                                 //     case "6":
  68.                                 //         var playerState = "galloping through the Forest";
  69.                                 //     case "7":
  70.                                 //         var playerState = "walking in the Forest";
  71.                                 //     case "8":
  72.                                 //         var playerState = "stumbling through the Forest";
  73.                                 //     case "9":
  74.                                 //         var playerState = "listening to the Forest sounds";
  75.                                 //     case "10":
  76.                                 //         var playerState = "jumping through the Forest";
  77.                                 //     case "11":
  78.                                 //         var playerState = "casting spells";
  79.                                 //     case "12":
  80.                                 //         var playerState = "praying in the Forest";
  81.                                 //     case "13":
  82.                                 //         var playerState = "dancing in the Forest";
  83.                                 // };
  84.  
  85.                                 // assigns deer name to true name
  86.                                 switch(player.get("word")) {
  87.                                     case "0000": // your deer's true name
  88.                                         var name = "Deer0" // your character name
  89.                                         break;
  90.                                    
  91.                                     case "1111":
  92.                                         var name = "Deer1"
  93.                                         break;
  94.                                    
  95.                                     case "2222":
  96.                                         var name = "Deer2"
  97.                                         break;
  98.                                    
  99.                                     // Add more accounts by using the same format:
  100.                                     // case "3333":
  101.                                     //  var name = "Deer3"
  102.                                     //  break;
  103.                                     //
  104.                                 };
  105.                                 return "<a href=http://endlessforest.org/machine/playerpage.php?symbol=" + player.get("word") +">" + name + "</a> is online at " + player.get("x") + " x "
  106.                                  + player.get("y") + " Status: " + playerState; //returns html text.
  107.                             }, this);
  108.                        
  109.                             exampleBox1.innerHTML = outputs.join("<br>"); // Separate each output with a new line.
  110.                         }
  111.                     });
  112.                     players.startUpdating(); // Start fetching the list of players every minute.
  113.                 }
  114.             }
  115.         });
  116.     });
  117. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement