PDA

View Full Version : why isn't this working?



kief
01-05-2004, 11:26 PM
//-----------------------------------------
// LScript Item Animation template
//

@version 2.2
@warnings
@script motion
@name "Walker 0.1"

ltFootGoal = nil;
rtFootGoal = nil;
ltX = false;
ltZ = false;
rtX = false;
rtZ = false;

// create: obj // with the Layout Object Agent argument
create // without the Layout Object Agent argument
{
setdesc("Walker 0.1");
}

destroy
{
if(reqisopen())
reqend();
}

load: what,io
{
if(what == SCENEMODE) // processing an ASCII scene file
{
ltX = integer(io.read());
ltZ = integer(io.read());
footGoal = integer(io.read());
}
}

save: what,io
{
if(what == SCENEMODE)
{
io.writeln(ltX);
io.writeln(ltZ);
io.writeln(ltFootGoal);
}
}

process: ma, frame, time
{
if (ltfootGoal)
{
gPos = footGoal.getWorldPosition(time);
pos = ma.get(POSITION,time);

if (ltX)
{
pos.x = gPos.x;
ma.set(POSITION,<gPos.x,pos.y,pos.z>);
}
if (ltZ)
{
pos.z = gPos.z;
ma.set(POSITION,<pos.x,pos.y,gPos.z>);
}

}
}


ltXstateUDF: val
{
ltX = val;
}

ltZstateUDF: val
{
ltZ = val;
}


options
{
reqbegin("Walker");
reqsize(238,200);

c1 = ctlallitems("Left Foot Goal",ltFootGoal);
ctlposition(c1,10,5,150,20);

c2 = ctlstate(" X",1,24,"ltXstateUDF");
ctlposition(c2,170,5);

c3 = ctlstate(" Z",1,24,"ltXstateUDF");
ctlposition(c3,204,5);

ltFootGoal = getvalue(c1);
setvalue(c2,ltX);
setvalue(c3,ltZ);

reqopen();
}


I am brand new to lscripting. I got this simple script working wonderfully using ctlchoice() instead of ctlstate() but it really seems better to use ctlstate(). eventually the script will move a biped character forward correctly during a walk cycle. right now it is suppose to move the motion object to the location of the goal object in the selected channels.

thanks

kief

wiffzack
01-06-2004, 08:50 AM
i can't install the script but there are some issues. You have the vars: ltfootGoal and ltFootGoal. And footGoal is only availbale if its loaded, isnt it?

kief
01-06-2004, 10:20 AM
ahh ha! i see it. that is because i failed to change the name of that instance of the variable. the script started out with just footGoal then i decided to change it to ltFootGoal. debugging didn't catch that.

thanks

kief