Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them has been replaced with a symlink. Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still be present.
32 lines
948 B
JavaScript
32 lines
948 B
JavaScript
var zoneEntityID = null;
|
|
|
|
var dayNightDuration = 120; // in seconds
|
|
|
|
var entities = Entities.findEntities({ x: 0, y: 0, z: 0 }, 600000);
|
|
for (var i in entities) {
|
|
var entityID = entities[i];
|
|
var name = Entities.getEntityProperties(entityID, 'name').name;
|
|
if (name == 'Day/Night Cycle') {
|
|
zoneEntityID = entityID;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (zoneEntityID) {
|
|
print("Found Day/Night zone entity: ", zoneEntityID);
|
|
Script.setInterval(function() {
|
|
var seconds = (Date.now() / 1000) % dayNightDuration;
|
|
var angle = seconds / dayNightDuration * (Math.PI * 2);
|
|
Entities.editEntity(entityID, {
|
|
keyLight: {
|
|
direction: {
|
|
x: -Math.cos(angle),
|
|
y: -Math.sin(angle),
|
|
z: 0
|
|
}
|
|
}
|
|
});
|
|
}, 100);
|
|
} else {
|
|
print("Could not find Day/Night zone entity");
|
|
}
|