Skip to content

Instantly share code, notes, and snippets.

@Rio6
Last active February 24, 2024 21:52
Show Gist options
  • Save Rio6/210e1ccd51fe6ab5fa09dace6863d83d to your computer and use it in GitHub Desktop.
Save Rio6/210e1ccd51fe6ab5fa09dace6863d83d to your computer and use it in GitHub Desktop.
This script shows stat change for parts on Magic server
/*
* This script shows stat change for parts on Magic server
*/
var magic = window.magic || {
process: Interpolator.prototype.process
};
Interpolator.prototype.process = function(data) {
if(data.settings || data.fullUpdate) {
this.settings = data.settings;
magic.updateMagic();
}
return magic.process.call(this, data);
}
magic.updateMagic = () => {
for(let things of [parts, types]) {
for(let i in things) {
let part = things[i];
let stat = sim.settings && sim.settings[part.name] || {};
let prot = part.prototype;
if(prot.magicChanges == null) {
prot.magicChanges = {};
}
for(let i in prot.magicChanges) {
if((i in prot.magicChanges) && !(i in stat)) {
prot[i] = prot.magicChanges[i];
delete prot.magicChanges[i];
}
}
for(let i in stat) {
if(typeof(prot[i]) !== 'function') {
prot.magicChanges[i] = prot[i];
prot[i] = stat[i];
}
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment