PDA

View Full Version : lscript and "invalid argument 1 type "


nick
03-11-2006, 11:53 PM
Hey guys got a small lscript problem. this is my first lscript (i know a good bit of mel script which is probably why im blind to this problem but im most probably just being daft) Anyway I keep getting this

"invalid argument 1 type to ExcludeLight()"

when i run my script, i just cant see whats wrong with it. Ive checked the result of variable and it makes sense that it should work but it doesnt. Any ideas ?

@warnings
@name "lightswitch2"
@script generic
//nicholas pliatsikas

generic

{
L1 = nil;
L2 = false;

reqbegin("My Requester");

reqsize(299,98);

a1 = ctllightitems("LightItems",L1);
ctlposition(a1,0,39,242,23);

c2 = ctlcheckbox("Exclude_invert",L2);
ctlposition(c2,164,5,106,22);

c3 = ctltext("","select objects to be effected");
ctlposition(c3,13,10,134,13);

s1 = ctlsep(0,-1);
ctlposition(s1,0,33,668,5);

return if !reqpost();

lightName = getvalue(a1);
L2 = getvalue(c2);

reqend();

myscene = Scene();
myobjects = myscene.getSelect();
arraysize = size(myobjects);

for(x = 1; x <= arraysize; x++)
{

itemname = myobjects[x].name;
SelectItem(itemname);
ExcludeLight (lightName);
}
}

Thanks in advance

Nick

Flashfire
03-12-2006, 01:31 AM
Your type 1 argument error is coming into play because you are defining a lightName and trying to toggle exclusion with it. ExcludeLight requires an IDx number, not a string variable.

ie:
for(x = 1; x <= arraysize; x++)
{

itemname = myobjects[x].name;
SelectItem(itemname);
ExcludeLight (lightName);
}
}

should be:
for(x = 1; x <= arraysize; x++)
{

itemname = myobjects[x].name;
SelectItem(itemname);
ExcludeLight (1); <-------------------- if you wanted to kill light 1 only.
}
}

-------

Try creating an array using your scene's light IDx's and running an imbedded if/then loop for your light exlusion using said array variables (numbers here, not names).

Hope that helps you... you can see it working if you change it above as I have; be sure to have your selected object's property panel open to the lights tab and you will see the light toggling.

nick
03-12-2006, 10:01 AM
cheers for that FlashFire, I didnt think that was the problem since using the named object with ExcludeLight works but using the result taken from the interface doesnt.

so this does work

ExcludeLight (keyLight1);

Anyway i will modify my script to use object id instead. It would be great to find out why i cant use the original method i had since using the direct name of a light works fine...

thanks
Nick

nick
03-12-2006, 12:57 PM
I posted on the lightwave3d forum as well and was given the reason why i was having teh problem courtesy of the user Dodgy.


Dodgy I think ctllightitems returns an object agent for the light, not the light name, so you need to do a

myname=lightName.name;

and use that in the exclude light call.
__________________


Cheers for the help.
Nick

Flashfire
03-12-2006, 11:43 PM
No worries... happy to assist, and glad to see you got the problem solved! :)

CGTalk Moderation
03-12-2006, 11:43 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.