createColorMatrix Script

2 Input and 2 Output colors -> matrix supported flash format —— N0N4M3_

This script uses the original color of the weapon, and the final result of color, to convert into flash supported matrix.

The way to execute the script is by pasting this function just below the function:

createColorMatrix([76, 76, 76], [32, 32, 32], [96, 95, 77], [128, 32, 0]);

//([first input RGB], [first output RGB], [second input RGB], [second output RGB]);

Anyways, here's the code you had to paste in console, at the advanced level editor:

function solveSystem(x1, x2, r1, r2) {
	let x = x1 - x2;
	let r = r1 - r2;
	let m = r / x;
	let b = r1 - m * x1;
	
	return [m, b];
}

function createColorMatrix(input1, output1, input2, output2) {
	let mainColor = Math.max(Math.abs(input1[0] - input2[0]), Math.abs(input1[1] - input2[1]), Math.abs(input1[2] - input2[2]));
	
	if (mainColor == Math.abs(input1[0] - input2[0])) {
		mainColor = 0;
	}
	
	if (mainColor == Math.abs(input1[1] - input2[1])) {
		mainColor = 1;
	}
	
	if (mainColor == Math.abs(input1[2] - input2[2])) {
		mainColor = 2;
	}
	
	let solution1 = solveSystem(input1[mainColor], input2[mainColor], output1[0], output2[0]);
	let solution2 = solveSystem(input1[mainColor], input2[mainColor], output1[1], output2[1]);
	let solution3 = solveSystem(input1[mainColor], input2[mainColor], output1[2], output2[2]);
	
	let matrix = [];
	
	if (mainColor == 0) {
		matrix.push(solution1[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution1[1]);
		
		matrix.push(solution2[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution2[1]);
		
		matrix.push(solution3[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution3[1]);
		
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(1);
		matrix.push(0);
	}
	
	if (mainColor == 1) {
		matrix.push(0);
		matrix.push(solution1[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution1[1]);
		
		matrix.push(0);
		matrix.push(solution2[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution2[1]);
		
		matrix.push(0);
		matrix.push(solution3[0]);
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution3[1]);
		
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(1);
		matrix.push(0);
	}
	
	if (mainColor == 2) {
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution1[0]);
		matrix.push(0);
		matrix.push(solution1[1]);
		
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution2[0]);
		matrix.push(0);
		matrix.push(solution2[1]);
		
		matrix.push(0);
		matrix.push(0);
		matrix.push(solution3[0]);
		matrix.push(0);
		matrix.push(solution3[1]);
		
		matrix.push(0);
		matrix.push(0);
		matrix.push(0);
		matrix.push(1);
		matrix.push(0);
	}
	
	let name = prompt("Variable name:", "_color");
	
	if (name) {
		let str = 'VarSetValue( "' + name + '", "' + matrix.join(", ") + '" );\nop349( "' + name + '", ", " );\nop403( "#gun*1", "' + name + '" );';
		let textarea = document.createElement("textarea");
		
		document.body.append(textarea);
		textarea.value = str;
		textarea.select();
		document.execCommand("copy");
		textarea.remove();
	}

    window.alert("The code is copied to your clipboard! \nAdd a trigger, switch to text list and paste it to see it works! \nRemember to manually set the guns!");
}

createColorMatrix([76, 76, 76], [32, 32, 32], [96, 95, 77], [128, 32, 0]); //change the numbers to your likings!

After executing this code, it will prompt you to set a variable name of your choice, after that, the code will automatically be pasted onto your clipboard.

Prepare an empty trigger, set it into text mode, paste it, change the guns if you want, then save. Your guns should be color filtered to your likings.

Last updated