Finding the map's sun object?

A lot of scripts in Construction refer to the sun object called "Sun". Well, at least in some maps (like Flatland Canyon), the sun isn't called "Sun". How do I find the name of the sun object in the map (using a script, preferably)?

Comments

  • Would've gotten this yesterday, but I haven't been on for a bit.
    What you could use to find the object is something like this:
          for(%i=0;%i<missionGroup.getCount();%i++) {
            %obj = missionGroup.getObject(%i);
            if(%obj.blah !$= "") return %obj;
          }
    
  • Doesn't work. It returns object 0 of the MissionGroup group (which does have type 2). I just did a test, though, I'll make the function look for the object's lensFlareScale.
  • Haha, yeah, didn't notice that earlier. I had actually used if(%obj.ambient !$= "") when I ran through it before posting and figured, 'might as well use the type'.

    Now I've remembered that would just return the first to show up with EnvironmentObjectType and realize that was pretty silly. :p
  • Here's my version of the function.
    function identifySun() {
       if (!isObject(Sun)) {
          for (%i = 0; %i < missionGroup.getCount(); %i ++) {
             %obj = missionGroup.getObject(%i);
             if (%obj.getType() == 2 && %obj.lensFlareScale !$= "") {
                %obj.setName("Sun");
                return %obj;
             }
          }
       } else
         return Sun;
       return -1;
    }
    
    The returns are for no particular reason in particular. :P Same goes for checking that both the object's type is 2 and its lensFlareScale isn't blank (which is probably redundant, but, meh).
Sign In or Register to comment.