1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Wierd function return problems on custom class

Discussion in 'Programming' started by Drew, Jun 25, 2003.

  1. Drew

    Drew New Member

    Joined:
    May 15, 2003
    Messages:
    13
    Likes Received:
    0
    This is really wierd. I'm trying to return from a function my custom class variable, but when I do that it only returns the default values, even though I KNOW that's not what I returned, since I've been logging and debugging everything TONS in the past 4 hours.

    I have a custom class that inherits from info, lets call it myThingy. I call an accessor function that owns that object to return it, like this:

    Code:
    Class myBot extends xBot;
    
    var myThingy myOwnThingy;
    
    function changeThingy()
    {
      // do LOTS of stuff here to change the values
    }
    
    function returnMyThingy()
    {
      return myOwnThingy;
    }
    
    ------------------
    Class somethingElse...
    
    function doSomething()
    {
      local myThingy differentOne;
       differentOne = myBot(bot).returnMyThingy();
    
      // but it just returns to me the default class values!!
    }
    
    So basically, when I try to return my custom class variable from any function, it only returns the default values and not the values of the var I tried to return!! And this isn't even a replication problem, so I'm real confused. Does anyone know what I'm doing wrong? I even went as far as trying to overload the = operator because I thought maybe that might help, but I couldn't get that to work either. *sigh*
     
  2. Corran

    Corran Danger Mouse

    Joined:
    Mar 10, 2003
    Messages:
    168
    Likes Received:
    0
    you've got to change:
    Code:
    function returnMyThingy()
    {
      return myOwnThingy;
    }
    to
    Code:
    function myThingy returnMyThingy()
    {
      return myOwnThingy;
    }
    Or fi you were trying to return a float, you'd do:
    Code:
    function float returnMyFloat()
    {
      return MyFavouriteFloat;
    }
    I assume that is what you mean.
     
  3. Wormbo

    Wormbo Administrator Staff Member

    Joined:
    Jun 4, 2001
    Messages:
    5,910
    Likes Received:
    35
    Last edited: Jun 25, 2003
  4. Drew

    Drew New Member

    Joined:
    May 15, 2003
    Messages:
    13
    Likes Received:
    0
    thanks for the reply guys

    Actually, it turns out the return variables were working fine, but somehow the variable I was initializing got erased accidentally a bit later, so when I returned it, nothing was in there.
     

Share This Page