SRL Archive - Research & Development Lounge

RandomWorld Function!


Nava2

2008-07-30 22:44:48

This can be used in a multitude of ways.

The primary use it so open a random world in SMART. Simply put it in the SetupSMARTEx and run the script.

ANOTHER way to use it is when you are running SRL's World Switcher. Include it the same way as the smart and it works :)

Here is the code, short simple, and to the point :).

(*=====================================================================)
| function RandomWorld(Free: Boolean): Integer; |
| By: Nava2 |
| Instructions: Set 'Free' parameter to which ever type of world |
| that you would like. Simple! |
(=====================================================================*)

function RandomWorld(Free: Boolean): integer;

var

s, w: string;
i: integer;

begin
i := Random(163) + 1;
if Free then
w := 'Free'
else
w := 'Members';
repeat
Inc(i);
if i = 164 then
i := 1;
until (ReadINI('World' + IntToStr(i), 'Type', AppPath + 'Includes\SRL\SCSS\Worlds.INI') = w);
s := GetNumbers(ReadINI('World' + IntToStr(i), 'Prefix', AppPath + 'Includes\SRL\SCSS\Worlds.INI'));
Result := StrToInt(s);
Writeln('Your Randomly chosen ' + w + ' world is ' + s + '.');
end;

Also here are the examples I was talking about.

SMART:

procedure SetupSmart;
begin
if not UseSMART then EXIT;
Writeln('Setting up SMART');
SmartSetupEx(RandomWorld(False), true, True, false);
wait(5000);
SetTargetDC(SmartGetDC);
repeat
wait(100);
until(SmartGetColor(253, 233)<>1118604);
end;

In a world changing procedure:

 procedure ChangeWorld;
begin
LogOut;
Wait(10000+random(5000));
SelectWorld(RandomWorld(True));
Wait(5000+random(2500));
LoginPlayer;
end;

Rate, Hate, Masturbate?

Post comments and suggestions please!

If you are using CREDIT! :)

~Nava2

Naike

2008-07-31 05:45:02

I just did one like 3 weeks ago…
Looks nice

Edit, Yours is Random numbers before Smart loads xD Mine is after smart loads :o

Still nice ;)

Nava2

2008-07-31 09:43:24

From: N1ke!
I just did one like 3 weeks ago…
Looks nice

Edit, Yours is Random numbers before Smart loads xD Mine is after smart loads :o

Still nice ;)


That confused me.

So yours changes worlds once smart loads?

Nava2

Queso

2008-07-31 10:30:37

You can change words at the login screen, remember? I have a function that changes the world randomly via the login screen for my script.

Nava2

2008-07-31 13:00:52

This function just chooses a random free or members world. It returns an integer, you use it in a world switching function.

Nava2

mixster

2008-07-31 13:27:52

I always preferred mine which chose a random one of the top 10 least populated worlds (it fell through the cracks in here), but otherwise not to bad.
Also, you can shorten it by setting a string variable to free or members based on the boolean then just have it check against that rather than have 2 loops that do the same thing only with a different check.

Nava2

2008-07-31 15:07:38

From: mixster
I always preferred mine which chose a random one of the top 10 least populated worlds (it fell through the cracks in here), but otherwise not to bad.
Also, you can shorten it by setting a string variable to free or members based on the boolean then just have it check against that rather than have 2 loops that do the same thing only with a different check.


I knew there was a way to shorten it!! :)

Thanks!

Nava2