Results 1 to 12 of 12
  1. #1
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default Call ActionScript functions from UnrealScript Doesen't work for me

    Im using the InventoryDemo , i know how works it's functionallity and all.
    But the problem comes when i have to communicate it with the engine , with the game.

    So i want to use this way , Call Actionscript funcs from UnrealScript but i had so many problems and i couldn't get it to work.


    First one , it's that when i use this , in UnrealScript, wich it's the US function that calls the AS function, my editor crashes
    Code:
       function ActionScriptCall()
    {
        ActionScriptVoid("InventoryItemAdder") ;
    }
    For this function that i have on Action script on the PaperDoll layer actions
    Code:
    function InventoryItemAdder():Void
    {
    slot5.data=_parent.itemData[6];
    }
    " that function adds an icon an slot 5 "

    Once i call it , the editor crashes , i don't know why, wich i want to know obiusly .


    Second one , and wich it's not about the communication of action script and unreal , it's that when i call functions from the UnrealScript class of the inventory system i get an error when i compile that function " whatever " it'sa bad expression or command for example

    well this is the code of it.

    Code:
    class GFxInventorySystem extends GFxMoviePlayer;
    
    var string itemcheck;
    
    
          function ActionSCriptCall()
    {
        ActionScriptVoid("InventoryItemAdder") ;
    }
    
    function ASExternalCall()
    {
    
    
    }
     //Called when the UI is opened to start the movie
    function bool Start(optional bool StartPaused = false)
    {
        setitemcheck();
        //ASExternalCall();
    	// Start playing the movie
        super.Start();
    
    	// Initialize all objects in the movie
        Advance(0);
    
        return true;
    }
    
    function setitemcheck()
    {
    itemcheck="hello";
    }
    
    defaultproperties
    {
        // The imported SWF to use
        MovieInfo=SwfMovie'UDNHud.MyInventory'
        bDisplayWithHudOff=TRUE
        TimingMode=TM_Real
    	bPauseGameWhileActive=TRUE
    	bCaptureInput=true
    }
    So if for example i place WorldInfo.Game.Broadcast(self,'whatever') , I get an error telling me that it's a bad command or expression , i don't understand why , on other calsses it works ,

    also i want to call a self made function placed in the UTInventoryManager , on my Inventory unrealscript class
    Code:
    function bool HandlePickupQuery(class<Inventory> ItemClass, Actor Pickup)
    
    {
        WorldInfo.Game.Broadcast(self,ItemClass);
        WorldInfo.Game.Broadcast(self,Pickup);
    
         return TRUE;
    }
    but as well as the Broadcast one it doesen't work , is it impossible or something? how should i?

    i almost tried everything for the exposed problems , but i can't get it to work , i read all the documentation , but it wasn't enough to get my Inventory communicated with the unrealScript help please .

    i can't wait to see that when im picking an item , an icon gets added
    Last edited by Neongho; 06-09-2012 at 08:18 PM.

  2. #2
    Iron Guard
    Join Date
    Nov 2007
    Location
    USA
    Posts
    692

    Default

    Are you using AS3? That code won't work for AS3.

    This is how it would look for AS3, this code is in your class that extends GfxMoviePlayer. The kismet nodes to call Action Script also don't work with AS3, you have to extend them and change the syntax to be like this. FunctionPath is where your function is on the movie. _root is for on the root timeline, you can use .'s to go to children.

    Code:
    function CallAsFunction(string arg1)
    {
    	local ASValue Param0;
    	local array<ASValue> args;
            local string FunctionPath, InvokeFunction;
    
    	Param0.Type = AS_String;
    	Param0.s = arg1;
    
    	args.Length = 1;
            args[0] = Param0;
    
    	FunctionPath = "_root";
    	InvokeFunction = "SetFunction";
    
    	GetVariableObject(FunctionPath).Invoke(InvokeFunction, args);
    }
    Last edited by mikepurvis; 06-12-2012 at 08:31 AM.

  3. #3
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default

    No im not using AS3 , as long as i know the inventoryDemo is scripted with AS 2 , so im using AS 2
    My function it's a void, with no arguments , the only thing that does it's add an item in the icon pannel of the inventory demo , why should i use a string arg?

    Help please!

    Also if i want to acces the variables of the actionscript , and change em , how would i do it ??
    i tried with this GetVariableObject. ( _root) .. something like this but it doesen't work , maybe i have to do somehting like this on the root line _root.IconPane if vars Are placed in the IconPanel

    I think i'll use a simple inventory the demo one of clik comes with it's own complications

    I still need help , if i get to use the InventoryDemo and communicate it with the engine i'll try to make a tutorial
    Last edited by Neongho; 06-12-2012 at 09:34 AM.

  4. #4
    Iron Guard
    Join Date
    Nov 2007
    Location
    USA
    Posts
    692

    Default

    I'm not telling you to use a string argument, I just provided an example of how to call an AS3 function.

    "i tried with this GetVariableObject. ( _root) .. " that isn't a string, you need to put it in "" if your not using a variable.

    I don't know anything about the demo and wasn't responding to that, only on how to call AS3 from UnrealScript.

  5. #5
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    218

    Default

    Quote Originally Posted by Neongho View Post
    Im using the InventoryDemo , i know how works it's functionallity and all.
    But the problem comes when i have to communicate it with the engine , with the game.

    So i want to use this way , Call Actionscript funcs from UnrealScript but i had so many problems and i couldn't get it to work.


    First one , it's that when i use this , in UnrealScript, wich it's the US function that calls the AS function, my editor crashes
    Code:
       function ActionScriptCall()
    {
        ActionScriptVoid("InventoryItemAdder") ;
    }
    For this function that i have on Action script on the PaperDoll layer actions
    Code:
    function InventoryItemAdder():Void
    {
    slot5.data=_parent.itemData[6];
    }
    " that function adds an icon an slot 5 "

    Once i call it , the editor crashes , i don't know why, wich i want to know obiusly .
    Have you looked inside your *.Log file in UDKGame\Logs? My Scaleform related crashes usually are when I try to call a AS function after I close the game or something.
    On a second though though, you seem to be calling a _parent which means you this function isn't residing in your main timeline which means your ActionScriptVoid function is crashing because it isn't finding the function to call. I think if you change your US function to something like GetVariableObject("_root").GetObject("MY_OBJECT"). ActionScriptVoid("InventoryItemAdder") ; it should work.

    Second one , and wich it's not about the communication of action script and unreal , it's that when i call functions from the UnrealScript class of the inventory system i get an error when i compile that function " whatever " it'sa bad expression or command for example

    well this is the code of it.

    Code:
    class GFxInventorySystem extends GFxMoviePlayer;
    
    var string itemcheck;
    
    
          function ActionSCriptCall()
    {
        ActionScriptVoid("InventoryItemAdder") ;
    }
    
    function ASExternalCall()
    {
    
    
    }
     //Called when the UI is opened to start the movie
    function bool Start(optional bool StartPaused = false)
    {
        setitemcheck();
        //ASExternalCall();
    	// Start playing the movie
        super.Start();
    
    	// Initialize all objects in the movie
        Advance(0);
    
        return true;
    }
    
    function setitemcheck()
    {
    itemcheck="hello";
    }
    
    defaultproperties
    {
        // The imported SWF to use
        MovieInfo=SwfMovie'UDNHud.MyInventory'
        bDisplayWithHudOff=TRUE
        TimingMode=TM_Real
    	bPauseGameWhileActive=TRUE
    	bCaptureInput=true
    }
    So if for example i place WorldInfo.Game.Broadcast(self,'whatever') , I get an error telling me that it's a bad command or expression , i don't understand why , on other calsses it works ,

    also i want to call a self made function placed in the UTInventoryManager , on my Inventory unrealscript class
    Code:
    function bool HandlePickupQuery(class<Inventory> ItemClass, Actor Pickup)
    
    {
        WorldInfo.Game.Broadcast(self,ItemClass);
        WorldInfo.Game.Broadcast(self,Pickup);
    
         return TRUE;
    }
    but as well as the Broadcast one it doesen't work , is it impossible or something? how should i?

    i almost tried everything for the exposed problems , but i can't get it to work , i read all the documentation , but it wasn't enough to get my Inventory communicated with the unrealScript help please .

    i can't wait to see that when im picking an item , an icon gets added
    You can't access WorldInfo from a GFxMoviePlayer class. The best you can do is use the event PlayerController GetPC() from the GFxMoviePlayer.uc class to get the player controller and from there grab WorldInfo.Game.Broadcast. Also i'm pretty sure Broadcast will only accept strings.

  6. #6
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default

    i'll try everything you said ,
    on the problem 2 , how would i use getPC() for getting the player controller? ?

    also after that what should i write , on the function arguments then ? WorldInfo.Game.Broadcast(what?,what?);
    How can i use , or send variables to the GFx class of the handlepickupqueryfunction()? it is placed in the UTInventoryManager? so i can use the variables for the inventry purposes .?

  7. #7
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    218

    Default

    In any class extending GFxMoviePlayer you should be able to use GetPC() which returns the PlayerController so something like GetPC().WorldInfo.Game.Broadcast or something like that.
    Well it depends what information you want to send.
    GetPC().WorldInfo.Game.Broadcast(self, "MESSAGE HERE"); You have to determine what information you want displayed, that's not something I can really explicitly tell you.

  8. #8
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default

    That doesesn't work , atleast if you get self on the first parameter . Error, Bad or missing expression in Call to 'Broadcast', parameter 1
    and how do i bring the inventoryManager class in the GFx file? also the Function HandlePickupQuery to use it

    i checked the log files and i get this kind of weird error

    Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    [0376.56] Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    [0376.56] Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    Last edited by Neongho; 06-13-2012 at 02:12 PM.

  9. #9
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    218

    Default

    Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    [0376.56] Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    [0376.56] Warning: Failed to load 'SwfMovie ?INT?Scaleform.IME.MoviePath?': Failed to find object 'SwfMovie ?INT?Scaleform.IME.MoviePath?'
    That error shouldn't matter that much.

    For the broadcast function, then maybe do something like this
    GetPC().WorldInfo.Game.Broadcast(GetPC(), "MESSAGE HERE");

    To get the InventoryManager you could do
    GetPC().Pawn.InvManager.

  10. #10
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default

    Thanks! makes a lot of sense , i'll try it

    for the moment call actionscript resolved : )

  11. #11
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,604

    Default

    First one works

    But , thhe problem comes with the second one , i have my own Game , so i have own Pawn and Own player controller

    MyPlayerController and MyPawn , i get variables and functions in there , but the function GetPC(). doesen't detect them , how do i acces my varaibels of MyPawn and MyPlayerController From my GFxMyInventory?

  12. #12
    MSgt. Shooter Person
    Join Date
    Mar 2007
    Posts
    456

    Default

    txtPlayerName.SetText(getPC().PlayerReplicationInf o.PlayerName);

    if you have your own variables in your own player controller or pawn you need to cast

    MyPlayerController(GetPC()).myVariable

    MyPawn(GetPC().Pawn).myVariable
    Project Lead and Lead Programmer
    Critical Point: Incursion Project Site & Studio Site
    CP:I are recruiting: link here
    Check our our Showcase thread here: link here
    Check our our Facebook page here: link here


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.