PDA

View Full Version : very basic script help


imonkey
09-26-2010, 11:37 PM
Hey guys,
I once used this script to create an infinite light that was targeted at a null.. obviously it does not work in release 12. I have absolutely no idea about scripting in any shape or form. I was wondering if someone could tell me why this isn't working.. According to the console its Line 21 Pos 34. So i'm guessing it has something to do with the target tag being added..

main(doc,op)
{
var new_light,new_target,new_tag;
new_light=new(LightObject);
new_target=new(NullObject);
new_tag=AllocTag(Ttargetexpression);

doc->StartUndo();
doc->AddUndo(UNDO_OBJECT_NEW,new_target);
doc->InsertObject(new_target,NULL,NULL);
new_target->SetName("Light_Target");

doc->AddUndo(UNDO_OBJECT_NEW,new_light);
doc->InsertObject(new_light,NULL,NULL);

new_light->SetPosition(vector(-500,500,-500));
new_light#LIGHT_TYPE=3;
new_light#LIGHT_SHADOWTYPE=3;

new_light->InsertTag(new_tag);
new_tag#TARGETExpressionTAG_LINK=new_target;
doc->EndUndo();
}

JDP
09-27-2010, 12:03 PM
TARGETExpressionTAG_LINK in Line 21 should be all upper case.

new_tag#TARGETEXPRESSIONTAG_LINK=new_target;

Cheers.

tcastudios
09-27-2010, 12:22 PM
JDP beat me.....
There are other small tidbits for R12 as well, like the UNDO.
The AllocObject() is also a newer function(R8?) (instead of new(Object))

Cheers
Lennart

main(doc,op)
{
var new_light = AllocObject(Olight); // Create a Light Object
new_light#LIGHT_TYPE = 3; // Its settings
new_light#LIGHT_SHADOWTYPE = 3;

var new_target = AllocObject(Onull); // Create a Null Object
new_target->SetName("Light_Target"); // Name it

var new_tag = AllocTag(Ttargetexpression); // Create a TargetTag
new_tag#TARGETEXPRESSIONTAG_LINK=new_target;// Place the Target in it

doc->StartUndo();

doc->InsertObject(new_light,NULL,NULL); // Insert the Light Object into scene
doc->AddUndo(UNDOTYPE_NEW,new_light);

doc->InsertObject(new_target,NULL,NULL); // Insert the target Null Object into scene
doc->AddUndo(UNDOTYPE_NEW,new_target);

new_light->SetAbsPos(vector(-500,500,-500)); // Position the Light Object
new_light->InsertTag(new_tag); // Add the Target Tag to the Light

doc->SetActiveObject(new_target); // Set active

doc->EndUndo();
}
}

imonkey
09-27-2010, 09:44 PM
Wow. Thanks guys! That is very helpful!

CGTalk Moderation
09-27-2010, 09:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.