Hi Everyone,
I have been tinkering with many things in the VS suite but ran into a road block when it comes to modifying things in the Elements and Status Core. Specifically, I am trying to have certain params show for certain actors based on whether or not they are affected by certain states. Here is the current VS code which declares and draws the params, the base ParameterList(1) is defined in the plugin parameters for all actors.
I had written some crude code to go above this section which checked for an item in this.getParameterList(1) under Rebuild Params, and filtered out a param, but it ended up causing issues when swapping between actors in the menus.
Does anyone know of a way I can successfully filter out items from these objects / arrays cleanly?
Thank you!
I have been tinkering with many things in the VS suite but ran into a road block when it comes to modifying things in the Elements and Status Core. Specifically, I am trying to have certain params show for certain actors based on whether or not they are affected by certain states. Here is the current VS code which declares and draws the params, the base ParameterList(1) is defined in the plugin parameters for all actors.
JavaScript:
// Declare Parameters
const params1 = this.getParameterList(1);
const params2 = this.getParameterList(2);
const params3 = this.getParameterList(3);
const maxLength = Math.max(params1.length, params2.length, params3.length);
const nameWidth = rect.width - padding * 2 - this.textWidth('88888');
const topY = Math.max((this.innerHeight - (maxLength * lineHeight)) / 2, 0);
// Draw Parameters 1
rect.x += rect.width;
x = rect.x + padding;
y = topY;
paramWidth = rect.width - (padding * 2);
if (y !== 0) this.drawItemDarkRect(rect.x, 0, rect.width, y);
for (const paramId of params1) {
this.drawItemDarkRect(rect.x, y, rect.width, lineHeight);
this.drawParamName(paramId, x, y, nameWidth);
this.drawParamValue(paramId, x, y, paramWidth);
y += lineHeight;
}
this.drawItemDarkRect(rect.x, y, rect.width, this.innerHeight - y);
// Draw Parameters 2
rect.x += rect.width;
rect.width = this.innerWidth - rect.x;
x = rect.x + padding;
y = topY;
paramWidth = rect.width - (padding * 2);
if (y !== 0) this.drawItemDarkRect(rect.x, 0, rect.width, y);
for (const paramId of params2) {
this.drawItemDarkRect(rect.x, y, rect.width, lineHeight);
this.drawParamName(paramId, x, y, nameWidth);
this.drawParamValue(paramId, x, y, paramWidth);
y += lineHeight;
}
this.drawItemDarkRect(rect.x, y, rect.width, this.innerHeight - y);
I had written some crude code to go above this section which checked for an item in this.getParameterList(1) under Rebuild Params, and filtered out a param, but it ended up causing issues when swapping between actors in the menus.
JavaScript:
//Rebuild Params
const newParams = this.getParameterList(1);
if (actor.states().includes($dataStates[167])) {
function removeValue(value, index, arr) {
if (value === "WP2") {
arr.splice(index, 1);
return true;
}
return false;
}
}
const paramsFilter = newParams.filter(removeValue);
console.log(newParams);
// Declare Parameters
const params1 = newParams;
const params2 = this.getParameterList(2);
const params3 = this.getParameterList(3);
const maxLength = Math.max(params1.length, params2.length, params3.length);
const nameWidth = rect.width - padding * 2 - this.textWidth('88888');
const topY = Math.max((this.innerHeight - (maxLength * lineHeight)) / 2, 0);
// Draw Parameters 1
rect.x += rect.width;
x = rect.x + padding;
y = topY;
paramWidth = rect.width - (padding * 2);
if (y !== 0) this.drawItemDarkRect(rect.x, 0, rect.width, y);
for (const paramId of params1) {
this.drawItemDarkRect(rect.x, y, rect.width, lineHeight);
this.drawParamName(paramId, x, y, nameWidth);
this.drawParamValue(paramId, x, y, paramWidth);
y += lineHeight;
}
this.drawItemDarkRect(rect.x, y, rect.width, this.innerHeight - y);
// Draw Parameters 2
rect.x += rect.width;
rect.width = this.innerWidth - rect.x;
x = rect.x + padding;
y = topY;
paramWidth = rect.width - (padding * 2);
if (y !== 0) this.drawItemDarkRect(rect.x, 0, rect.width, y);
for (const paramId of params2) {
this.drawItemDarkRect(rect.x, y, rect.width, lineHeight);
this.drawParamName(paramId, x, y, nameWidth);
this.drawParamValue(paramId, x, y, paramWidth);
y += lineHeight;
}
this.drawItemDarkRect(rect.x, y, rect.width, this.innerHeight - y);
Does anyone know of a way I can successfully filter out items from these objects / arrays cleanly?
Thank you!