Created
November 5, 2017 15:02
-
-
Save SplenectomY/6168cb3484e7d2749104968ecaa6dc4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SplenectomY = SplenectomY || {}; | |
SplenectomY.planets = SplenectomY.planets || {}; | |
////////////////////////////////////////////////// | |
//HERES THE CONFIG. SAVE AND RESTART UPON CHANGING. | |
SplenectomY.planets.clockwise = false; | |
////////////////////////////////////////////////// | |
////////////////////////////////////////////////// | |
on('ready',function() { | |
SplenectomY.planets = findObjs({ | |
_type: "graphic", | |
gmnotes: "isPlanet", | |
}); | |
}); | |
on("chat:message", function(msg) { | |
if(msg.type == "api" && msg.content.indexOf("!protate ") !== -1) { | |
var days = (msg.content.replace("!protate ", "")); | |
_.each(SplenectomY.planets, function(obj) { | |
var mult = 0; | |
if(obj.get("name") == "Anadia") {mult = 12;}; | |
if(obj.get("name") == "Coliar") {mult = 1.5;}; | |
if(obj.get("name") == "Toril") {mult = 360/365;}; | |
if(obj.get("name") == "Karpri") {mult = 360/650;}; | |
if(obj.get("name") == "Chandos") {mult = 360/2010;}; | |
if(obj.get("name") == "Glyth") {mult = 360/10800;}; | |
if(obj.get("name") == "Garden") {mult = 360/30660;}; | |
if(obj.get("name") == "HCatha") {mult = 360/60120;}; | |
var angle = obj.get("rotation"); | |
if (SplenectomY.planets.clockwise == true) { | |
var newangle = angle + (days * mult); | |
} else { | |
var newangle = angle - (days * mult); | |
}; | |
obj.set("rotation", newangle); | |
}); | |
var foods = findObjs({ | |
_type: "attribute", | |
name: "food", | |
}); | |
_.each(foods, function(obj) { | |
charID = obj.get("_characterid"); | |
var food = obj.get("current"); | |
var water = 0; | |
var crew = 0; | |
var air = 0; | |
var others = filterObjs(function(atts) { | |
if(atts.get("name") == "crew" && atts.get("_characterid") == charID) { | |
crew = atts.get("current"); | |
return true; | |
}; | |
if(atts.get("name") == "water" && atts.get("_characterid") == charID) { | |
water = atts.get("current"); | |
return true; | |
}; | |
if(atts.get("name") == "air" && atts.get("_characterid") == charID) { | |
air = atts.get("current"); | |
return true; | |
} | |
if(atts.get("represents") == charID) return true; | |
else return false; | |
}); | |
food = food - (crew * days); | |
water = water - (crew * days * 4); | |
air = air - (crew * days); | |
obj.set("current",food) | |
_.each(others, function(atts) { | |
if(atts.get("name") == "water") {atts.set("current",water)}; | |
if(atts.get("name") == "air") {atts.set("current",air)}; | |
if(atts.get("represents") == charID) { | |
atts.set("name","Days left: Food: " + Math.floor(food/crew) + " | " + "Water: " + Math.floor(water/(crew * 4)) + " | " + "Air: " + Math.floor(air/crew)) | |
}; | |
}); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment