Just a simple function that may be usefull to some of you, do with it what you will..
function RndWorld(wType: integer): integer;
Returns a world number based on input:
1 Returns a random Valid World member/Non Member.
2 Returns a random Free Play World
3 Returns a random Members World.
Can be easily used with functions like SmartSetupEX(); to load a valid world.
Uses Worlds.ini so that any world changes will always be up to date.
Does not return any Special/Reserved World.
SCAR Code:
{*******************************************************************************
function RndWorld(wType: integer): integer;
By: PriSoner
Description: Returns a random world number. Uses worlds.ini to get a world count
and check if world is members or free.
Options: Enter 1 to return any valid random world.
2 to return any valid Free Play World
3 to return any valid Members World
*******************************************************************************}
function RandWorld(wType: integer): integer;
var winipath: String;
rndcount: integer;
begin
if (wType > 0) and (wType < 4) then
begin
winipath := AppPath + 'includes\SRL\SCSS\worlds.ini';
rndcount := StrToInt(ReadINI('Worlds', 'Count', winipath));
case wType of
1: repeat
result := Random(rndcount) + 1;
until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Free') or
(ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Members');
2: repeat
result := Random(rndcount) + 1;
until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Free');
3: repeat
result := Random(rndcount) + 1;
until (ReadINI('World' + IntToStr(result), 'Type', winipath) = 'Members');
end;
writeln('Your Randomly Chosen World is: ' + IntToStr(result));
end else
begin
writeln('function RandWorld: Incorrect value! Valid Range is 1 to 3. Terminating Script!');
TerminateScript;
end;
end;