Author Topic: Changing environmental settings  (Read 1095 times)

How would you change the skybox, lighting, ground, and other stuff with a script? Every time a server starts I notice that the ground and lighting and sky is set to default. I want  to make it so that when the server starts, the environment is changed.

serverCmdenvGUI_setvar(%client,%var,%val);

if you want to do it without using an actual client, make a new AIConnection();

EDIT: An example: changing water height would be serverCmdenvGUI_setvar(%client,"waterheight",%height);
« Last Edit: September 05, 2012, 04:32:39 PM by Wrapperup »

Well, first off, this is what gamemodes are for, second it's different for every var so you have to use serverCmdEnvGui_SetVar or study the objects Sun, Sky, GroundPlane, and I think WaterPlane. If you choose the latter, use %obj.sendUpdate();

Then how do you change it with a GameMode? I want to do it without using an actual client.
Also, I have no idea how to create an AI for this.

And what are some variables, like waterheight?

Then how do you change it with a GameMode? I want to do it without using an actual client.
Also, I have no idea how to create an AI for this.

And what are some variables, like waterheight?
Start a server. Set the environment variables to whatever you want them to be.
Open console. Type in export("$EnvGuiServer::*","Config/Env.cs");
Go into this file. It'll have a lot of lines that look like this: $EnvGuiServer::SimpleMode = 0;

Open Add-Ons/GameMode_Custom/gamemode.txt
Copy in all the variables from Config/Env.cs and replace all "= " (yes with a space after the =), ";" and quotation marks with nothing. Bam.
« Last Edit: September 05, 2012, 07:15:50 PM by TripNick »

Also, I have no idea how to create an AI for this.

To create an AIConnection do this

Code: [Select]
new AIConnection(envAI)
   {
       isAdmin = true;
   };
or store it into a local var
Then you can do ServerCmdenvGUI_setVar(envAI,%var,%val);
« Last Edit: September 06, 2012, 07:02:54 PM by Wrapperup »

-snip-
AiConnection, not AiObject
Needs a ; at the end of the object creation
And .getId() is unneeded
« Last Edit: September 05, 2012, 08:19:17 PM by Headcrab Zombie »

AiConnection, not AiObject
Needs a ; at the end of the object creation
And .getId() is unneeded

i did it quickly, but thanks for correcting that, and i did not notice i said "AIObject" and not "AIConnection" although i mentioned you had to create an AIConnection.

oh my god would you stop using AIConnection objects for once
properly change the attributes of the mission objects, then use sendUpdate, finally modify $EnvGuiServer values and send to clients

oh my god would you stop using AIConnection objects for once
properly change the attributes of the mission objects, then use sendUpdate, finally modify $EnvGuiServer values and send to clients
Way too overcomplicated
Like for water you have to change so many things
Moving the plane doesn't move the physzone
etc etc

oh my god would you stop using AIConnection objects for once
properly change the attributes of the mission objects, then use sendUpdate, finally modify $EnvGuiServer values and send to clients
I just don't see an advantage in doing it that way.
One line versus... all that

I just don't see an advantage in doing it that way.
One line versus... all that
Maybe it's less of a hack method.
Either that or it's a personal reason

Here's my code for loading a complete environment directly from a save file
Code: [Select]
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