Author Topic: How to locate a sun?  (Read 1256 times)

How do you locate and delete a sun object in a mission via code?

Just loop through the missionGroup and check the classname of each object.

Code: [Select]
function delSun()
{
for(%i = 0; %i < missionGroup.getCount(); %i++)
%i.getObject();
if(%i.uiName $= "Sun")
{
%i.delete();
}
}

That would probably work, I think I may have left some errors in there, but TorqueDev didn't say anything.

mp, you have to stop trying. As people used to tell me, don't give people half done code. That would only give the last object. I aalso believe the Sun doesn't use uiName, as it is not used in any ui other than Mission Editor. And that's object name I believe.

-snip-

That would probably work, I think I may have left some errors in there, but TorqueDev didn't say anything.
torquedev doesn't really work that well as far as saying if it's logically correct

Code: [Select]
function delSun()
{
for(%i = 0; %i < missionGroup.getCount(); %i++)
{
%obj = missionGroup.getObject(%i);
if(%i.getClassName() $= "Sun")
%i.delete();
}
}

I did already give him the code last night, though.