5 votes

Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?

Give objects the functions using their properties. Clients just "ask" (call the methods), they don't do the calculations. Then client code can look like this: ...
radarbob's user avatar
  • 7,484
3 votes
Accepted

Is it possible to make this Minecraft Bedrock addon script less resource intensive, so that it no longer triggers performance warnings?

Is it possible to make this Minecraft Bedrock addon script less resource intensive? Sure. Do less work. Currently you are triggering runs of this "scan a thousand blocks" routine quite ...
J_H's user avatar
  • 21.9k
3 votes

Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?

You're right, that sure is a lot of repetition. We're mapping one number to another, using many ifs. That can also be done with an ...
J_H's user avatar
  • 21.9k
2 votes

Math calculation JavaScript. Am I using Objects correctly? Can I use methods / functions to shorten my code further? Also error logging?

Think about arrays, arrays of objects. see here https://jsfiddle.net/9w2n34hf/ ...
jmullee's user avatar
  • 141
2 votes

Is it possible to make this Minecraft Bedrock addon script less resource intensive, so that it no longer triggers performance warnings?

While you could go about optimizing the detection of rhizome blocks using deltas, caching, and all sorts of smart heuristics, there is also a simpler optimization available that utilizes the ...
Dillon Davis's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible