commit
6901ec7d22
109
mods/plants.js
109
mods/plants.js
|
|
@ -1063,115 +1063,6 @@ elements.mango_seed = {
|
|||
cooldown: defaultCooldown,
|
||||
seed: true,
|
||||
};
|
||||
function conditionTrue(condition, pixel){
|
||||
let p = pixel;
|
||||
let string = "";
|
||||
condition = condition.split("!OR").join("||").split("&AND").join("&&").split("\"").join("")
|
||||
|
||||
condition = eval(condition);
|
||||
return condition;
|
||||
}
|
||||
let ifCondition = "";
|
||||
let currentProp = "";
|
||||
let currentPropValue = "";
|
||||
elements.propmachine = {
|
||||
name: "PropMachine",
|
||||
behavior: behaviors.WALL,
|
||||
category: "machines",
|
||||
noMix: true,
|
||||
onSelect: function(pixel) {
|
||||
|
||||
let item = prompt("enter range for prop changing.");
|
||||
if(/^\d+$/.test(item)){
|
||||
num4 = parseInt(item);
|
||||
} else {
|
||||
alert("that is not an integer.");
|
||||
}
|
||||
exclude2 = prompt("Enter elements to exclude, seperate them with commas. You can also enter !IF if you wish to enter conditions for it to change the property and add the exclude elements.").replace(/\s/g, "");
|
||||
if(exclude2.includes("!IF")){
|
||||
exclude2.split("!IF").join("");
|
||||
ifCondition = prompt("Enter the condition for the property to change. List of variables you can access can be found at https://5455e34a-cfe9-4576-ac9c-6e64c061433d-00-1psic9s1cgla6.kirk.replit.dev/Mods/morechemistry/conditions%20for%20if.html");
|
||||
} else { ifCondition = '1 == 1'; }
|
||||
exclude2.split(",");
|
||||
if(exclude2.constructor == [].constructor){
|
||||
exclude2.push("propmachine");
|
||||
} else {
|
||||
exclude2 += "propmachine";
|
||||
}
|
||||
var answer1 = prompt("Warning - This tool may break the simulator if used incorrectly.\n\nEnter a pixel attribute to modify:",(currentProp||undefined));
|
||||
console.log(answer1)
|
||||
if (!answer1) { return }
|
||||
var answer2 = prompt("Now, enter a value for "+answer1+":",(currentPropValue||undefined));
|
||||
if (!answer2) { return }
|
||||
var valueL = answer2.toLowerCase();
|
||||
if (valueL === "true") { answer2 = true }
|
||||
else if (valueL === "false") { answer2 = false }
|
||||
else if (valueL === "null") { answer2 = null }
|
||||
else if (valueL === "undefined") { answer2 = undefined }
|
||||
else if (answer1 === "color" && valueL[0] === "#") {
|
||||
var rgb = hexToRGB(valueL);
|
||||
answer2 = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")";
|
||||
}
|
||||
currentProp = answer1;
|
||||
currentPropValue = answer2;
|
||||
console.log(answer1);
|
||||
var num = parseFloat(answer2);
|
||||
if (!isNaN(num)) { answer2 = num }
|
||||
currentPropValue = answer2;
|
||||
logMessage("Prop: "+currentProp);
|
||||
logMessage("Value: "+currentPropValue);
|
||||
},
|
||||
tick: function(pixel) {
|
||||
if(pixel.start == pixelTicks) {
|
||||
pixel.range = num4;
|
||||
pixel.condition = ifCondition;
|
||||
pixel.prop = currentProp;
|
||||
pixel.val = currentPropValue;
|
||||
}
|
||||
let range = mouseRange(pixel.x, pixel.y, pixel.range);
|
||||
prop({ property: pixel.prop, value: pixel.val },range, exclude2, pixel.condition);
|
||||
}
|
||||
}
|
||||
function prop(obj, range, exclude = [], condition = ""){
|
||||
let list = [];
|
||||
for (var i = 0; i < range.length; i++) {
|
||||
var x = range[i][0];
|
||||
var y = range[i][1];
|
||||
if (!isEmpty(x,y,true)) {
|
||||
var pixel = pixelMap[x][y];
|
||||
list.push(pixel);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (!isEmpty(list[i].x, list[i].y, true)) {
|
||||
var pixel = list[i];
|
||||
if (!exclude.includes(pixel.element) && conditionTrue(condition, pixel)){
|
||||
if(/^\d+$/.test(obj.value)){
|
||||
obj.value = parseInt(obj.value);
|
||||
}
|
||||
if (!obj.property) { return }
|
||||
if (pixel[obj.property] !== undefined && typeof pixel[obj.property] !== typeof obj.value) {
|
||||
logMessage("Error: "+obj.property+" type is "+typeof pixel[obj.property]+", not "+typeof obj.value+".");
|
||||
obj.property = null;
|
||||
obj.value = null;
|
||||
return;
|
||||
}
|
||||
if (obj.property === "element") {
|
||||
changePixel(pixel, obj.value);
|
||||
list.splice(list.indexOf(pixel),1);
|
||||
return;
|
||||
}
|
||||
if (obj.property === "burning" && obj.value === "true") {
|
||||
pixel.burnStart = pixelTicks;
|
||||
list.splice(list.indexOf(pixel),1);
|
||||
return;
|
||||
}
|
||||
pixel[obj.property] = obj.value;
|
||||
list.splice(list.indexOf(pixel),1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elements.seed_maker = {
|
||||
category: "machines",
|
||||
behavior: behaviors.WALL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue