Advertisement
Guest User

Untitled

a guest
Apr 17th, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var pendingLogs = {
  2.     Loot: [],
  3.     Unlocks: [],
  4.     Combat: [],
  5.     Notices: [],
  6.     all: [],
  7.     RAF: null
  8. };
  9.  
  10. function message(messageString, type, lootIcon, extraClass, extraTag, htmlPrefix) {
  11. if (extraTag && typeof game.global.messages[type][extraTag] !== 'undefined' && !game.global.messages[type][extraTag]) return;
  12.     var log = document.getElementById("log");
  13.     var displayType = (game.global.messages[type].enabled) ? "block" : "none";
  14.     var prefix = "";
  15.     var addId = "";
  16.     if (messageString == "Game Saved!" || extraClass == 'save') {
  17.         addId = " id='saveGame'";
  18.         if (document.getElementById('saveGame') !== null){
  19.             log.removeChild(document.getElementById('saveGame'));
  20.         }
  21.     }
  22.     if (game.options.menu.timestamps.enabled){
  23.         messageString = ((game.options.menu.timestamps.enabled == 1) ? getCurrentTime() : updatePortalTimer(true)) + " " + messageString;
  24.     }
  25.     if (!htmlPrefix){
  26.         if (lootIcon && lootIcon.charAt(0) == "*") {
  27.             lootIcon = lootIcon.replace("*", "");
  28.             prefix =  "icomoon icon-";
  29.         }
  30.         else prefix = "glyphicon glyphicon-";
  31.         if (type == "Story") messageString = "<span class='glyphicon glyphicon-star'></span> " + messageString;
  32.         if (type == "Combat") messageString = "<span class='glyphicon glyphicon-flag'></span> " + messageString;
  33.         if (type == "Loot" && lootIcon) messageString = "<span class='" + prefix + lootIcon + "'></span> " + messageString;
  34.         if (type == "Notices"){
  35.             messageString = "<span class='glyphicon glyphicon-off'></span> " + messageString;
  36.         }
  37.     }
  38.     else messageString = htmlPrefix + " " + messageString;
  39.     var messageHTML = "<span" + addId + " class='" + type + "Message message" +  " " + extraClass + "' style='display: " + displayType + "'>" + messageString + "</span>";
  40.     pendingLogs.all.push(messageHTML);
  41.     if (type != "Story"){
  42.         var pendingArray = pendingLogs[type];
  43.         console.log(type, pendingArray);
  44.         pendingArray.push(pendingLogs.all.length - 1);
  45.         if (pendingArray.length > 10){
  46.             var index = pendingArray[0];
  47.             pendingLogs.all.splice(index, 1)
  48.             pendingArray.splice(0, 1);
  49.             adjustMessageIndexes(index);
  50.         }
  51.     }
  52. }
  53.  
  54. function adjustMessageIndexes(index){
  55.     for (var item in pendingLogs){
  56.         if (item == "all" || item == "RAF") continue;
  57.         for (var x = 0; x < pendingLogs[item].length; x++){
  58.             if (pendingLogs[item][x] > index)
  59.                 pendingLogs[item][x]--;
  60.         }
  61.     }
  62. }
  63.  
  64. function postMessages(){
  65.     if (pendingLogs.RAF != null) cancelAnimationFrame(pendingLogs.RAF);
  66.     pendingLogs.RAF = requestAnimationFrame(function() {
  67.         var log = document.getElementById("log");
  68.         var needsScroll = ((log.scrollTop + 10) > (log.scrollHeight - log.clientHeight));
  69.         var pendingMessages = pendingLogs.all.join('');
  70.         log.innerHTML += pendingMessages;
  71.         pendingLogs.all = [];
  72.         for (var item in pendingLogs){
  73.             if (item == "all" || item == "RAF") continue;
  74.             if (pendingLogs[item].length)
  75.                 trimMessages(item);
  76.             pendingLogs[item] = [];
  77.         }
  78.         if (needsScroll) log.scrollTop = log.scrollHeight;
  79.     });
  80. }
  81.  
  82. MAIN.JS
  83.  
  84. function gameLoop(makeUp, now) {
  85.     gather(makeUp);
  86.     craftBuildings();
  87.     if (game.global.trapBuildToggled && game.global.trapBuildAllowed && game.global.buildingsQueue.length === 0) autoTrap();
  88.     breed(makeUp);
  89.     battleCoordinator(makeUp);
  90.     if (game.global.titimpLeft) game.global.titimpLeft -= 0.1;
  91.     loops++;
  92.     if (loops % 10 == 0){
  93.         if (game.global.challengeActive == "Decay") updateDecayStacks(true);
  94.         if (game.global.challengeActive == "Daily" && typeof game.global.dailyChallenge.pressure !== 'undefined') dailyModifiers.pressure.addSecond();
  95.         if (game.global.autoUpgradesAvailable) autoUpgrades();
  96.         if (savedOfflineText && !game.global.lockTooltip) {
  97.             tooltip("Trustworthy Trimps", null, "update", savedOfflineText);
  98.             savedOfflineText = "";
  99.         }
  100.     }
  101.     if (mutations.Magma.active()) generatorTick();
  102.     if (!makeUp) postMessages(); //Just this one new line added here
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement