kamukrass / Bitburner

Scripts for playing the Bitburner game
77 stars 24 forks source link

corp.js issue #2

Closed reddg321 closed 2 years ago

reddg321 commented 2 years ago

corp.js crashes when trying to create a second product as products are named product-NaN

reddg321 commented 2 years ago

solved. changed var productNumbers = []; to var productNumbers = [0];

kamukrass commented 2 years ago

@reddg321 thanks for the hint. The first product with the number "0" is typically created in the initCities function. If that does not happen, the script would indeed crash. This implicit dependency is of course bad code quality and I fixed it: newProductNumber now defaults to 0 and productNumbers are not considered if there is none yet. Now the script should be more robust for example in cases when you create divisions and not use the initCities function.