Random 8=====D Sizes Command

Looking for help, and not sure why it won’t work. - new to writing commands and javascript, but looking for random numbers of “=” within’ the 8=D. I wrote it in another language, but am having troubles.

Here is my code:
!repeat $(eval let bSck = “8”;
let length = Math.floor() * 30;
for(var i=0; i < length; i++)
{
ballSck += ‘=’;
})

But when I test this so far, it doesn’t give me what I need. What am I doing wrong?

Hey @drpi314159TTV!

JavaScript has a .repeat() method to avoid the cumbersome for loop:

!addcom !commandName $(eval `8${'='.repeat(Math.floor(Math.random() * 30) + 1)}D`)

Your issue is that for length you were multiplying Math.floor() with 30, Math.floor() rounds down numbers, it doesn’t represent any number by itself, what you’re looking for is a random number generator.

1 Like

Thank you so much, and it’s very similar to how it was written using stream elements commands. I don’t know why I was struggling, but I think I just need to study nightbot a little more, and javascript. But to be honest with you, I started out relatively simple, but a friend told me I needed a for loop, and I got all lost with it. Thanks again.

I will be using this resource again in the future.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.