drizzt
2008-04-07 20:13:15
i made this function to return the number of a random world, free or members, for use in SMART
also, due to some worlds missing from SRL rev #15, i'll be keeping an updated worlds.ini down here as worlds.txt because .ini files are invalid for uploading, so just resave this as worlds.ini in Includes\SRL\SCSS\Worlds.ini
Function GetRandomWorld(Free: Boolean): integer;
var
World: String;
gws, cw, hmw: Integer;
wlist: array of integer;
begin
If Free then World := 'Free'
else World := 'Members';
hmw := StrToInt(ReadINI('Worlds','Count',AppPath + 'Includes\SRL\SCSS\Worlds.ini'))
for gws := 1 to hmw do
begin
if ReadINI('World' + inttostr(gws),'Type',AppPath + 'Includes\SRL\SCSS\Worlds.ini') = World then
begin
cw := Length(Wlist);
SetArrayLength(Wlist,cw + 1);
Wlist[cw] := gws;
end;
end;
Writeln(inttostr(length(Wlist)));
Result := wlist[1 + random(length(hmw))];
end;also, due to some worlds missing from SRL rev #15, i'll be keeping an updated worlds.ini down here as worlds.txt because .ini files are invalid for uploading, so just resave this as worlds.ini in Includes\SRL\SCSS\Worlds.ini