Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Pulling UnrealScript Variables from ActionScript

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

  • Pulling UnrealScript Variables from ActionScript

    Just a quick tutorial showing how you might go about reading (or pulling) a variable from UnrealScript into your Flash file (rather than pushing it from UnrealScript).

    ActionScript 2

    Code:
    var retVal:Object = {};
    retVal = ExternalInterface.call("GetUnrealVariable", "someFloat", "float");
    // Parameter 2 = the variable name in UnrealScript.
    // Parameter 3 = the variable type in UnrealScript - float, string, etc.
    
    trace("My UnrealScript Variable: " + retVal.someFloat);

    UnrealScript Sample


    Unfortunately, it does not seem to be the case that you can use a dynamic variable name in UnrealScript, like you can in ActionScript. If you could, we could simply write something like: asval.n = VarName; Since you can't, this is a hacky solution, which requires you to put a case for every UnrealScript variable you would want access to in Flash in a switch statement.

    Code:
    var float someFloat;
    var string someString;
    var bool someBoolean;
    
    someFloat = 1337;
    someString = "Boo!";
    someBoolean = true;
    
    function GFxObject GetUnrealVariable(string VarName, string VarType)
    {
    	local GFxObject TempObj;
    	local ASValue asval;
    	local array<ASValue> args;
    	
    	TempObj = CreateObject("Object");
    
    	switch(VarType) 
    	{
                    case ("float"):
    		    asval.Type = AS_Number;
                        break;
                    case ("string"):
    		    asval.Type = AS_String;
                        break;
                    case ("bool"):
                        asval.Type = AS_Boolean;
                        break;
                    default:
                        break;
            }
         
    	switch(VarName)
    	{
    		case ("someFloat"):
    		    asval.n = someFloat;
                        break;
    		case ("someString"):
    		    asval.s = someString;
                        break;
                    case ("someBoolean"):
                        asval.b = someBoolean;
                        break;
    		default:
    		    break;
    	}
    	
    	args[0] = asval;
    	TempObj.Set(VarName, args[0]);
    
    	return TempObj;
    }

  • #2
    First, Thank you for good tut & Matt.

    But I have some question about this.


    I can't understand, why 2nd parameter of ExternalInterface.call in AS,

    'someFloat' type float change to 1st parameter of GetUnrealVariable in US, 'VarName' type string.


    Code:
    //I known that like this.
    ExternalInterface.call( USfunction name, 1st Pram of USfunction, 2nd Pram of USfunction )
    I was wrong to understand invoke?

    Thanks.

    Comment


    • #3
      Originally posted by Matt Doyle View Post
      Just a quick tutorial showing how you might go about reading (or pulling) a variable from UnrealScript into your Flash file (rather than pushing it from UnrealScript).

      ActionScript 2

      Code:
      var retVal:Object = {};
      retVal = ExternalInterface.call("GetUnrealVariable", "someFloat", "float");
      
      // Parameter 2 = the variable name in UnrealScript.
      // Parameter 3 = the variable type in UnrealScript - float, string, etc.
      
      trace("My UnrealScript Variable: " + retVal.someFloat);

      UnrealScript Sample


      Unfortunately, it does not seem to be the case that you can use a dynamic variable name in UnrealScript, like you can in ActionScript. If you could, we could simply write something like: asval.n = VarName; Since you can't, this is a hacky solution, which requires you to put a case for every UnrealScript variable you would want access to in Flash in a switch statement.

      Code:
      var float someFloat;
      var string someString;
      var bool someBoolean;
      
      someFloat = 1337;
      someString = "Boo!";
      someBoolean = true;
      
      function GFxObject GetUnrealVariable(string VarName, string VarType)
      {
      	local GFxObject TempObj;
      	local ASValue asval;
      	local array<ASValue> args;
      	
      	TempObj = CreateObject("Object");
      
      	switch(VarType) 
      	{
                      case ("float"):
      		    asval.Type = AS_Number;
                          break;
                      case ("string"):
      		    asval.Type = AS_String;
                          break;
                      case ("bool"):
                          asval.Type = AS_Boolean;
                          break;
                      default:
                          break;
              }
           
      	switch(VarName)
      	{
      		case ("someFloat"):
      		    asval.n = someFloat;
                          break;
      		case ("someString"):
      		    asval.s = someString;
                          break;
                      case ("someBoolean"):
                          asval.b = someBoolean;
                          break;
      		default:
      		    break;
      	}
      	
      	args[0] = asval;
      	TempObj.Set(VarName, args[0]);
      
      	return TempObj;
      }
      Bump!! Sorry for the bump but I am looking for a small clarification here....

      I am assuming that the ActionScript part goes into the file/class/script from where u r trying to access the unreal script variable(hope i am not wrong here).... but its the unreal script part that is a not very straight forward for me..... cos nothing in the action script 'pull' has any indication as to where the code on the unreal side is, that is which class etc., Since there is no mention of the class name of the unreal script function, i am assuming that it should either be in the gameinfo class of the playercontroller class... Am I right in assuming so?? whether right or wrong, can someone confirm which class the unreal side of the code should be in??

      Thanks!!

      Comment


      • #4
        Sorry for bumping again..... Anyone??

        Comment


        • #5
          I'm trying to wrap my head around how UDK uses scaleform and from what I can gather you set up a uc script per flash movie and extend

          class MyMovie extends GFxMoviePlayer;

          I think you then set the movie path in the defaultproperties

          I'm going to have a look, so I'll re post when I have had chance to get this working

          Comment


          • #6
            so first off watch vids 1,2 and 3 of Matt's getting started http://www.youtube.com/watch?v=fc5yW...endscreen&NR=1

            then add yourself a class using


            Code:
            class Srinath49gfx extends GFxMoviePlayer;
            
            var float someFloat;
            var string someString;
            var bool someBoolean;
            
            
            function GFxObject GetUnrealVariable(string VarName, string VarType)
            {
            	local GFxObject TempObj;
            	local ASValue asval;
            	local array<ASValue> args;
            	
            	TempObj = CreateObject("Object");
            
            	switch(VarType) 
            	{
                            case ("float"):
            		    asval.Type = AS_Number;
                                break;
                            case ("string"):
            		    asval.Type = AS_String;
                                break;
                            case ("bool"):
                                asval.Type = AS_Boolean;
                                break;
                            default:
                                break;
                    }
                 
            	switch(VarName)
            	{
            		case ("someFloat"):
            		    asval.n = someFloat;
                                break;
            		case ("someString"):
            		    asval.s = someString;
                                break;
                            case ("someBoolean"):
                                asval.b = someBoolean;
                                break;
            		default:
            		    break;
            	}
            	
            	args[0] = asval;
            	TempObj.Set(VarName, args[0]);
            
            	return TempObj;
            }
            defaultproperties
            {
                // The imported SWF to use
            	MovieInfo=SwfMovie'YOURGfxPakage.pathToYOURSwf'	
            
                // Set widget bindings so the Widget passed to
                // WidgetInitialized for the buttons is a GFxCLICKWidget
                WidgetBindings.Add((WidgetName="saveButton",WidgetClass=class'GFxCLIKWidget'))
                WidgetBindings.Add((WidgetName="exitButton",WidgetClass=class'GFxCLIKWidget'))
            
                // Set properties for the movie
                // TimingMode=TM_Real makes the menu run while the game is paused
                bDisplayWithHudOff=TRUE
                TimingMode=TM_Real
            	bPauseGameWhileActive=TRUE
            	bCaptureInput=true
            	
            	someFloat = 1337;
            	someString = "Boo!";
            	someBoolean = true;
            }


            if you make your class extend GFxMoviePlayer it becomes available in the kismet dropdown

            Comment


            • #7
              Thanks a lot for the videos dude... Looking into them right away!!!!

              Comment


              • #8
                Hi guys,

                I need a bit of help. Well the theory of this, i get it but now I have weapon where I define a new variable, clips. This clips change and when I reload it also decrease its number by one. So I assumed that it could be implemented like ammo. So I went to my HUD and created clipsN textfield as a copy of ammoN. Then gone to my GFXMinimapHud and defined clipscountTF then added int lastclipsCount then I defined LasClipsCount to insane number then defined clipsCountTF like this

                ClipsCountTF = GetVariableObject("_root.playerStats.clipsN");

                so i pointed to my flash
                Then I added this where I must say I am not sure what is that but it is also done with ammo:

                //ADDED
                if (LastClipsCount != -10)
                {
                ClipsCountTF.SetString("text", "");
                //AmmoBarMC.GotoAndStopI(51);
                LastClipsCount = -10;
                }

                And that is all. Am I missing something? I do not know but there has to be another way. Matt please tell me I am total idiot and it just need two easy lines of code. xD I found some other functions which are connected to ammo but they are conected with function all over UT files I mean with scripts. It seems to as unresolvable problem.

                Please HELP, many thanks J0X3R

                J0X3R

                EDIT: MAYBE THERE WOULD BE THE WAY BY DEFINING NEW FUNCTION LIKE GETCLIPSCOUNT BUT IT IS NOT WORKING TO ME. BUT AMMO SEEMS TO BE SOLVED BY THIS.

                Comment


                • #9
                  @Jox3r
                  You should use [CODE] tags in your post.

                  Comment

                  Working...
                  X