• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN How to select random text and reload script without sinusbot restarting

Status
Not open for further replies.

zmechu

Active Member
Contributor
Hello!

I'm not skillful with sinusbot scripting, so I have a problem to resolve :)

I'd like to prepare random selected welcome message. Looks like:
Code:
messages = ("Welcome", "Hi", Hi there", "Hello", "Good morning");
msg = getRandom(messages);
chat(msg);
but all my tests failed. Any help?

And another question - is there way to reload script without restarting sinusbot? Till now any script edit require sinusbot restart to reload.

Regards!
 

xDefcon

Well-Known Member
Contributor
Here you go:
JavaScript:
msg = messages[getRandomInt(0, messages.length - 1]; //assuming the messages array contains at least 1 element
chat(msg);

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}


is there way to reload script without restarting sinusbot?
Yes, there is, add this in your config.ini:
Code:
[Scripts]
AllowReload = true
 

zmechu

Active Member
Contributor
Thanks, starting tests :)

Edit: seems "AllowReload = true" doesn't work for me...

How to declare messages array?

And another question - is there options to read message from text file from disk (some kind of ReadFile("file.txt") ?

Regards!
 
Last edited:
Status
Not open for further replies.
Top