Blockland Forums > Modification Help
Changing The Sun's Ambience
jes00:
So this should work?
--- Code: ---if((%obj = missionGroup.getObject(%i)).getClassName() $= "Sun")
{
%color = %obj.color;
break;
}
setSun(%color, %ambient);
function setSun(%color,%ambient)
{
for(%i=0; %i<missiongroup.getCount(); %i++)
{
%obj=missiongroup.getObject(%i); if(%obj.getClassname()$= "Sun") %obj.delete();
}
$Sun = new sun(Sun)
{
color = %color;
ambient = %ambient;
}
}
--- End code ---
otto-san:
here's a more updated version of what electrk posted, i'm pretty sure it works from what i've tested
--- Code: ---function getSunCount()
{
%ct=-1;
for(%i=0;%i<missiongroup.getcount();%i++)
{
%obj=missiongroup.getObject(%i);
if(%obj.getClassName()$="Sun"){%ct++;}
}
return %ct;
}
function getSun(%c)
{
%ct=-1;
for(%i=0;%i<missiongroup.getcount();%i++)
{
%obj=missiongroup.getObject(%i);
if(%obj.getClassName()$="Sun"){%ct++;}
if(%ct == %c){return %obj;}
}
}
function changeLighting(%d, %l, %p, %r, %s, %c, %am, %az, %e)
{
for(%i = 0; %i <= getSunCount(); %i++)
getSun(%i).delete();
new Sun(Sun)
{
color = %c;
ambient = %am;
azimuth = %az;
elevation = %e;
direction = %d;
locked = %l;
position = %p;
rotation = %r;
scale = %s;
};
missionGroup.add(Sun);
}
--- End code ---
so you could just do something like this maybe
--- Code: ---function changeAmbient(%sun, %a)
{
changeLighting(%sun.direction,
%sun.locked,
%sun.position,
%sun.rotation,
%sun.scale,
%sun.color,
%a,
%sun.azimuth,
%sun.elevation);
}
--- End code ---
changeAmbient(getSun(0), whatever);
not tested but try it
also in case you bugger something up here's the default lighting for skylands
changeLighting("0.57735 0.57735 -0.57735", 1, "0 0 0", "1 0 0 0", "1 1 1", "0.6 0.6 0.6 1.0", "0.5 0.5 0.5 1.0", "238", 21);