Here's my code for loading a complete environment directly from a save file
if(!isObject(publicClient))
{
new AiConnection(publicClient) {BL_ID = 888888;};
publicClient.isAdmin = true;
publicClient.isSuperAdmin = true;
}
function loadEnvironmentFromFile(%filePath)
{
%file = new FileObject();
%file.openForRead(%filePath);
while(!%file.isEOF())
{
%line = %file.readLine();
%pref = getWord(%line,0);
%pref = getSubStr(%pref,15,strLen(%pref) - 15);
%value = getWords(%line,1,getWordCount(%line) - 1);
%sPref = getWord($AdvGameEnvPref[%pref],0);
if(%sPref !$= "")
{
%count = $EnvGuiServer["::" @ %sPref @ "Count"];
for(%i=0;%i<%count;%i++)
{
%idx = $EnvGuiServer["::" @ %sPref @ %i @ ""];
if(%idx $= %value)
{
%value = %i;
%pref = %sPref @ getWord($AdvGameEnvPref[%pref],1);
%i = %count + 1;
}
}
if(%i == %count)
{
error("loadEnvironmentFromFile() - Material \'" @ %value @ "\' not found");
continue;
}
}
serverCmdEnvGui_setVar(publicClient,%pref,%value);
}
%file.close();
%file.delete();
}
$AdvGameEnvPref[SkyFile] = "Sky Idx";
$AdvGameEnvPref[WaterFile] = "Water Idx";
$AdvGameEnvPref[GroundFile] = "Ground Idx";
$AdvGameEnvPref[SunFlareTopTexture] = "SunFlare TopIdx";
$AdvGameEnvPref[SunFlareBottomTexture] = "SunFlare BottomIdx";
$AdvGameEnvPref[DayCycle] = "DayCycle Idx";
You can also find it in DC4F's rotating gamemode, he tested it for me