Last active
October 31, 2017 18:14
-
-
Save SplenectomY/18d1aa4c76cd31749e5c95e9303ef910 to your computer and use it in GitHub Desktop.
A nice script for rotating planets (according to the Spelljammer campaign guide) in Roll20.
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); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment