Results 1 to 3 of 3
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default String input into class name?

    Hello,

    I'm not sure if that's the right title, but I have no idea how else to phrase it. Basically, I'm trying to set the FamilyInfo class of a Player Controller. Here's what I have so far:

    Code:
    class UPHPlayerController extends UTPlayerController;
    
    var class<UTFamilyInfo> CharacterClass;
    
    simulated event PostBeginPlay()
    {
      super.PostBeginPlay();
    }
    
    exec function SpawnAsChar(string CharName)
    {
        CharacterClass=class'UPHFamilyInfo_"CharName"';
        ServerSetCharacterClass(CharacterClass);
    }
    
    defaultproperties
    {
    InputClass=class'UPHGame.UPHPlayerInput'
    CharacterClass=class'UPHFamilyInfo_BaseChar'
    }

    The line I'm focusing on is CharacterClass=class'UPHFamilyInfo_"CharName"';. Is there a way of doing this? I get an error Error, Unterminated string constant: '; Obviously the alternative is an if function for each character, but if I can get this to work, it'll save a lot of lines of code.

    Thanks,
    Zaiteria

  2. #2
    Palace Guard
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    3,940

    Default

    You could try to concatenate your strings with $ and then use DynamicLoadObject to get a class reference to them.
    Our Loop, which art in source code, hallowed be thy keyword.
    Thy condition come, thy instruction be done, in RAM as it is in cache.
    Increment us this day our daily counter,
    and forgive us our typos, as we also have forgiven our compilers.
    And lead us not to the nullpointer but deliver us from bugs.
    For thine is the API, the GUI, and the CLI while(true).
    Semicolon;
    Please don't send me questions about how to do something in the UDK via PM. That is better discussed in the forums and we only have limited PM storage.

  3. #3
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Posts
    73

    Default

    Thanks for the reply, but I just realised there is no need to overcomplicated it as much as I had. I can use this instead and just have the input include the "UPHFamilyInfo_" part. There are only 7 characters, so shouldn't be too bad.

    Code:
    class UPHPlayerController extends UTPlayerController;
    
    var class<UTFamilyInfo> CharacterClass;
    
    simulated event PostBeginPlay()
    {
      super.PostBeginPlay();
    }
    
    exec function SpawnAsChar(class<UTFamilyInfo> inClass)
    {
        ServerSetCharacterClass(inClass);
    }
    /** Set player's character info class & perform any other initialization */
    
    
    
    defaultproperties
    {
    InputClass=class'UPHGame.UPHPlayerInput'
    }


 

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.