Move variables to dependency
i'm sick of having to update them twice also shallow array support lmao
This commit is contained in:
parent
748e0171e8
commit
69f3beda4f
82
mods/prop.js
82
mods/prop.js
|
|
@ -1,3 +1,7 @@
|
||||||
|
var modName = "mods/prop.js";
|
||||||
|
var variablesMod = "mods/prop and prompt variables.js";
|
||||||
|
|
||||||
|
if(enabledMods.includes(variablesMod)) {
|
||||||
propProperty = "element";
|
propProperty = "element";
|
||||||
propValue = "sand";
|
propValue = "sand";
|
||||||
propType = "string";
|
propType = "string";
|
||||||
|
|
@ -6,22 +10,6 @@ numberAdjusterValue = 1;
|
||||||
numberAdjusterMode = "add";
|
numberAdjusterMode = "add";
|
||||||
numberAdjusterVerb = "adding";
|
numberAdjusterVerb = "adding";
|
||||||
|
|
||||||
stringSynonyms = [ "string", "str", "st", "s" ];
|
|
||||||
numberSynonyms = [ "number", "num", "nm", "nu", "nb", "integer", "int", "i", "it", "float",
|
|
||||||
"flt", "ft", "fl", "f", "wholenumber", "decimalnumber", "wn", "dn", "w",
|
|
||||||
"d", "deeznuts" ]; /*The purpose of these blatant lies is, through a
|
|
||||||
reference to the Alice series of software, have an excuse to include deez
|
|
||||||
nuts.*/
|
|
||||||
objectSynonyms = [ "object", "oj", "obj", "ob", "o", "json" ];
|
|
||||||
booleanSynonyms = [ "boolean", "bool", "boole", "boo", "bo", "bl", "b" ];
|
|
||||||
|
|
||||||
defaultStringTypeValues = ["element","color","clone","changeTo","void","type"];
|
|
||||||
defaultNumberTypeValues = ["x","y","temp","start","vx","vy","chargeCD","start","burnStart","dir","panic","r","frequency","length","delay","volume","debounce","debounceLength"];
|
|
||||||
defaultBooleanTypeValues = ["burning","charge","dead","hissing","following","dirLocked","del","didChargeBlueTinted"];
|
|
||||||
|
|
||||||
synonymsOfTrue = ["true", "t", "1", "yes"];
|
|
||||||
synonymsOfFalse = ["false", "f", "0", "no"];
|
|
||||||
colorInvalidError = "Color must be in the form \"rgb(red,green,blue)\" or \"hsl(hue,saturation%,lightness%)\" (without quotes)!";
|
|
||||||
function rgbStringToUnvalidatedObject(string) {
|
function rgbStringToUnvalidatedObject(string) {
|
||||||
string = string.split(",");
|
string = string.split(",");
|
||||||
var red = parseFloat(string[0].substring(4));
|
var red = parseFloat(string[0].substring(4));
|
||||||
|
|
@ -128,20 +116,21 @@ function propPrompt() {
|
||||||
propType = "boolean";
|
propType = "boolean";
|
||||||
} else if(defaultStringTypeValues.includes(propProperty.toLowerCase())) {
|
} else if(defaultStringTypeValues.includes(propProperty.toLowerCase())) {
|
||||||
propType = "string";
|
propType = "string";
|
||||||
|
} else if(defaultArrayTypeValues.includes(propProperty.toLowerCase())) {
|
||||||
|
propType = "array";
|
||||||
} else {
|
} else {
|
||||||
propType = prompt("Enter the type of the value");
|
propType = prompt("Enter the type of the value");
|
||||||
if(stringSynonyms.includes(propType)) {
|
if(stringSynonyms.includes(propType)) {
|
||||||
propType = "string"
|
propType = "string";
|
||||||
|
} else if(numberSynonyms.includes(propType)) {
|
||||||
|
propType = "number"; //Infinity (case-sensitively) is a *number*.
|
||||||
|
} else if(booleanSynonyms.includes(propType)) {
|
||||||
|
propType = "boolean";
|
||||||
|
} else if(objectSynonyms.includes(propType)) {
|
||||||
|
propType = "object"; //null (case-sensitively) is an *object*.
|
||||||
|
} else if(arraySynonyms.includes(propType)) {
|
||||||
|
propType = "array"; //offset coords use arrays a lot
|
||||||
};
|
};
|
||||||
if(numberSynonyms.includes(propType)) {
|
|
||||||
propType = "number" //Infinity (case-sensitively) is a *number*.
|
|
||||||
};
|
|
||||||
if(booleanSynonyms.includes(propType)) {
|
|
||||||
propType = "boolean"
|
|
||||||
};
|
|
||||||
if(objectSynonyms.includes(propType)) {
|
|
||||||
propType = "object" //null (case-sensitively) is an *object*.
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Conversion
|
//Conversion
|
||||||
|
|
@ -167,6 +156,42 @@ function propPrompt() {
|
||||||
alert("JSON is invalid! Note that it requires quotes around keys as well as those curly {} parentheses.");
|
alert("JSON is invalid! Note that it requires quotes around keys as well as those curly {} parentheses.");
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
} else if(propType === "array") {
|
||||||
|
array = propType.split(",");
|
||||||
|
for(i = 0; i < array.length; i++) {
|
||||||
|
if(array[i].startsWith("s")) { //String
|
||||||
|
array[i] = array[i].substring(1);
|
||||||
|
} else if(array[i].startsWith("n")) { //Number
|
||||||
|
array[i] = array[i].substring(1);
|
||||||
|
if(isNaN(parseFloat(array[i]))) {
|
||||||
|
alert(array[i] + " is not a number!");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
array[i] = parseFloat(array[i]);
|
||||||
|
} else if(array[i].startsWith("o")) { //Object
|
||||||
|
array[i] = array[i].substring(1);
|
||||||
|
try {
|
||||||
|
array[i] = JSON.parse(array[i]);
|
||||||
|
} catch (error) {
|
||||||
|
alert(array[i] + " is not valid JSON!");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
} else if(array[i].startsWith("b")) { //Boolean
|
||||||
|
array[i] = array[i].substring(1);
|
||||||
|
if(synonymsOfTrue.includes(array[i].toLowerCase())) {
|
||||||
|
array[i] = true;
|
||||||
|
} else if(synonymsOfFalse.includes(array[i].toLowerCase())) {
|
||||||
|
array[i] = false;
|
||||||
|
} else {
|
||||||
|
alert("Unrecognized boolean value: " + array[i] + ".");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
alert(array[i] + ' must start with "s" for a string, "n" for a number, "o" for an object, or "b" for a boolean.');
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
propType = array;
|
||||||
} else if(propType !== "string") {
|
} else if(propType !== "string") {
|
||||||
alert("Unrecognized or unsupported type!");
|
alert("Unrecognized or unsupported type!");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -282,3 +307,8 @@ elements.number_adjuster = {
|
||||||
function updateNumberAdjusterDescription() {
|
function updateNumberAdjusterDescription() {
|
||||||
elements.number_adjuster.desc = `Sets or adds to numeric properties of pixels.<br/>Currently ${numberAdjusterVerb} ${numberAdjusterValue} to ${numberAdjusterProperty}.<br/><span onclick=numberAdjusterPrompt() style=\"color: #ff00ff;\";>Press [Shift+,] or click here</span> to open the adjuster tool prompt.`;
|
elements.number_adjuster.desc = `Sets or adds to numeric properties of pixels.<br/>Currently ${numberAdjusterVerb} ${numberAdjusterValue} to ${numberAdjusterProperty}.<br/><span onclick=numberAdjusterPrompt() style=\"color: #ff00ff;\";>Press [Shift+,] or click here</span> to open the adjuster tool prompt.`;
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
alert(`The ${variablesMod} mod is required and has been automatically inserted (reload for this to take effect).`)
|
||||||
|
enabledMods.splice(enabledMods.indexOf(modName),0,variablesMod)
|
||||||
|
localStorage.setItem("enabledMods", JSON.stringify(enabledMods));
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue