Announcement

Collapse
No announcement yet.

How to Set a String in One Function to a String in Another?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    YES! That did it. Here's the final version of the pertinent function (just basically copied your code in).

    Code:
    function bool InitActionFor(ScriptedController C)
    {//start function
    
        local Actor a;
        local xSyncPawn MyPawn;
    
        if(Target != 'None')
    	{//start if
    		//Find all xPawns with the name specified in 'Target'
            ForEach C.AllActors(class'Actor', a, Target)
            {//start ForEach
    
            MyPawn = xSyncPawn(C.Pawn);
            MyPawn.LipAnimationString = AnimationString;
            MyPawn.LipSyncSpeed = SyncSpeed;
    
            a.GotoState('SwappingSkins');
    
            }//close ForEach
    
        }//close if
    
        return false;
    }//close function
    That may be just about the last hurdle I have to jump to get scriptable texture-based lipsyncing working. Thanks a ton.

    Leave a comment:


  • replied
    Ok, you're getting there. The last problem is what pawn are yo usetting the variables for? In the first bit of code you posetd, the foreach goes through every actor in the level, not just your pawns. In the second bit of code you are declaring a local variable but not setting it to anything in particular (so it will be none).

    Since you are doing this in a scripted action I presume that you want the pawn belonging to the scipted controller to be the one affected, in which case you want something like this:
    Code:
    function bool InitActionFor(ScriptedController C)
    {
    	local xSyncPawn P;
    
    	P = xSyncPawn(C.Pawn);
    
    	//Do stuff with P here.
    }

    Leave a comment:


  • replied
    Did some research (thank you Wiki!)... so I'd be wanting to do something like this?

    Code:
            //Currently bugged, we'll fix this later
            local xSyncPawn (xPawn);
            MyPawn = xSyncPawn(xPawn);
            if ( MyPawn != None )
            {
            MyPawn.LipAnimationString = AnimationString;
            MyPawn.LipSyncSpeed = SyncSpeed;
            }
            else
            {
            log("Owner is not a Pawn!");        
            }

    Leave a comment:


  • replied
    Code:
    If you have defined such a variable in a custom pawn then you need to typecast a to your pawn class.
    Should have read this closer... I'm not sure EXACTLY what this means (typcasting to the pawn class) but I'll do some research. Thanks.

    Leave a comment:


  • replied
    Evil,

    Thanks for your comments... I probably should have put more information. Here's the complete chunk of code...

    ACTION_StartLipping
    Code:
    function bool InitActionFor(ScriptedController C)
    {//start function
    
        local Actor a;
    
        if(Target != 'None')
    	{//start if
    		//Find all xPawns with the name specified in 'Target'
            ForEach C.AllActors(class'Actor', a, Target)
            {//start ForEach
    
    
            //Currently bugged, we'll fix this later
            //a.LipAnimationString = AnimationString;
            //a.LipSyncSpeed = LipSyncSpeed;
    
            a.GotoState('SwappingSkins');
    
            }//close ForEach
    
        }//close if
    
        return false;
    }//close function
    And here's the pertinent script of the object it is referencing... I subclassed a new xPawn called xSyncPawn and applied the variable.

    xSyncPawn
    Code:
    Class xSyncPawn extends xPawn;
    
    //Currently gotta load the texture file where the skins reside... eventually
    //the texture file/directory will be set the same as the Skin1 (Head) on the
    //xPawn being targeted, so this can then go away.
    #exec OBJ LOAD FILE=LipSyncTextures.utx
    
    var(AI) string LipAnimationString;
    var(AI) int LipSyncSpeed;
    var float HowManySwaps;
    var int SwapNum;
    var string Phoneme;
    var int SwapTime;
    
    state SwappingSkins
    {//Begin state
    
    Begin:
    state code snipped
    Code:
    }//End state
    
    defaultproperties
    {
        LipAnimationString="a";
        LipSyncSpeed=(0.3);
    }
    So I'm referencing an xSyncPawn I added to the editor and I have defined the string LipAnimationString in the code for the xSyncPawn, however, I'm still getting a compiler error stating that it can't find 'LipAnimationString'.

    Leave a comment:


  • replied
    a is an xPawn is it? Then it will fail because there is no LipAnimationString variable in xPawn. If you have defined such a variable in a custom pawn then you need to typecast a to your pawn class.

    Leave a comment:


  • How to Set a String in One Function to a String in Another?

    Yet another n00b question...

    Next step in my project is to pass a string from a ScriptedSequence to an xPawn. Only problem is, I'm not quite sure what the syntax is. Here's what I tried... (a is referencing the xPawn from previous code).

    Code:
            a.LipAnimationString = AnimationString;
    Now, the thought behind this was setting the string LipAnimationString (in the targeted xPawn) to equal the string AnimationString (in the ScriptedSequence). However, I'm getting a compiler error dealing with an actor problem so I'm guessing there's some additional bit of code between the a. and the variable you want to change telling the compiler what you want to do.

    Any help is greatly appreciated. I'll post if I find it first.
Working...
X