Hello, I am trying to reduce the amount of scripting I have with some conditional statements. Here is my base code:
I know I can change it to the following that would be better:
However I am pretty sure I can have this instead first check if user.equips()[0] & then check if wtypeId = 1:9 to cut down on this even further.
It certainly wouldn't be something as simple as the following, would it?
What would the best way to go about this? And am I correct in assuming that more refined code that takes up less space would be less exhaustive on the player's device?
Thank you
Actually just found out that it would be as simple as using >= && <=
Meaning the optimized code would be:
So I suppose this is solved, unless there is an even better way to go about this? I am also still curious about how important minimizing the size of data structures is. TY
JavaScript:
<Custom Passive Condition>
if (
user.equips()[0] && user.equips()[0].wtypeId === 1)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 2)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 3)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 4)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 5)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 6)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 7)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 8)
{
condition = true;
} else if (
user.equips()[0] && user.equips()[0].wtypeId === 9)
{
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
I know I can change it to the following that would be better:
JavaScript:
<Custom Passive Condition>
if (
user.equips()[0] && user.equips()[0].wtypeId === 1 || user.equips()[0] && user.equips()[0].wtypeId === 2 || user.equips()[0] && user.equips()[0].wtypeId === 3 || user.equips()[0] && user.equips()[0].wtypeId === 4 || user.equips()[0] && user.equips()[0].wtypeId === 5 || user.equips()[0] && user.equips()[0].wtypeId === 6 || user.equips()[0] && user.equips()[0].wtypeId === 7 || user.equips()[0] && user.equips()[0].wtypeId === 8 || user.equips()[0] && user.equips()[0].wtypeId === 9)
{
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
However I am pretty sure I can have this instead first check if user.equips()[0] & then check if wtypeId = 1:9 to cut down on this even further.
It certainly wouldn't be something as simple as the following, would it?
JavaScript:
<Custom Passive Condition>
if (
user.equips()[0] && user.equips()[0].wtypeId === 1:9)
{
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
What would the best way to go about this? And am I correct in assuming that more refined code that takes up less space would be less exhaustive on the player's device?
Thank you
Actually just found out that it would be as simple as using >= && <=
Meaning the optimized code would be:
JavaScript:
<Custom Passive Condition>
if (
user.equips()[0] && user.equips()[0].wtypeId >= 1 && user.equips()[0] && user.equips()[0].wtypeId <= 9)
{
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
So I suppose this is solved, unless there is an even better way to go about this? I am also still curious about how important minimizing the size of data structures is. TY