Oni Central Forum

A forum for the Oni community

You are not logged in.

#1 10/19/09 13:10

Leus
Member
From: Boone, NC
Registered: 05/28/09
Website

Scripting randomness

Is there anyway to make a script with a legitimately random outcome?  Like, random in that there are a number of possible outcomes that you set up and the one that returns is determined by chance?


If we don't change the direction we're going, we'll likely end up where we're headed.

Offline

#2 10/19/09 13:10

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: Scripting randomness

int i = 1;
max_i = 10;
void random_gen() {
i = i+1;
if(i > max_i) i = 1;
sleep 1;
fork random_gen
}


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#3 10/19/09 13:10

Iritscen
Moderator
From: NC, USA
Registered: 10/22/07

Re: Scripting randomness

In truth, no, there is no random() function in BSL, Leus.  There should be, but there isn't.  Oni's engine randomizes some things, but there's no facility for it in BSL.  Gumby's function simply loops a number from 1-10 infinitely.  This can be used to simulate randomness sometimes.


Check out the Anniversary Edition Seven at ae.oni2.net!

Offline

#4 10/20/09 00:10

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: Scripting randomness

Expect a proper random function in the next release of Daodan  big_smile

Offline

#5 10/20/09 00:10

Stevinlewis
Member
From: Singapore
Registered: 03/25/09

Re: Scripting randomness

lol. Miles wad language is in ur signature?

Offline

#6 10/20/09 01:10

Gumby
Member
From: Seattle, WA, USA
Registered: 08/30/07

Re: Scripting randomness

RossyMiles wrote:

Expect a proper random function in the next release of Daodan  big_smile

SSSSHHH. You will ruin the surprise. tongue


Iritscen: roll
Iritscen: it's amazing this program even works
Gumby: i know
Iritscen: and that statement applies to my code, not just yours

Offline

#7 10/20/09 04:10

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: Scripting randomness

Stevinlewis wrote:

lol. Miles wad language is in ur signature?

English with special characters. It worked on the old forum...

Offline

#8 10/20/09 04:10

Stevinlewis
Member
From: Singapore
Registered: 03/25/09

Re: Scripting randomness

To Gumby: O.o I cant wait.

To Ros: lol. What kind of special letters? The alt letters? like this> ™ ?

Last edited by Stevinlewis (10/20/09 04:10)

Offline

#9 10/20/09 05:10

RossyMiles
Member
From: Australia
Registered: 06/23/08
Website

Re: Scripting randomness

Stevinlewis wrote:

To Ros: lol. What kind of special letters? The alt letters? like this> ™ ?

This is getting very off-topic, but yes.

Offline

#10 10/20/09 19:10

Leus
Member
From: Boone, NC
Registered: 05/28/09
Website

Re: Scripting randomness

I would hypothetically make good use of that function.  smile


If we don't change the direction we're going, we'll likely end up where we're headed.

Offline

#11 11/06/09 16:11

Chamyky
Member
From: France
Registered: 02/11/09
Website

Re: Scripting randomness

Functions like this one are interesting and useful additions to BSL. It is nice.

Offline

Board footer

Powered by FluxBB