News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 25th Jun 2003, 10:49 AM   #1
Drew
Registered User
 
Join Date: May. 15th, 2003
Posts: 13
Wierd function return problems on custom class

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*
Drew is offline   Reply With Quote
Old 25th Jun 2003, 11:47 AM   #2
Corran
Danger Mouse
 
Corran's Avatar
 
Join Date: Mar. 10th, 2003
Location: Portsmouth, England
Posts: 168
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.
__________________
<tarquin> to know what you wish to know, first you must know what you wish to know

Play more Jailbreak!
Save Sam and Max!
Corran is offline   Reply With Quote
Old 25th Jun 2003, 12:56 PM   #3
Wormbo
 
Wormbo's Avatar
 
Join Date: Jun. 4th, 2001
Location: Germany
Posts: 5,774
For more general information about returning values from functions see UnrealWiki: Function Syntax.
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak/JDN | Unreal Wiki | Liandri Archives
Everything you ever wanted to know about replication| UnrealScript security considerations
<elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
<TNSe> nono
<TNSe> its always funny to find code a week later you dont even remember writing
<Pfhoenix> what's worse is when you have a Star Wars moment
<Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"

Last edited by Wormbo; 25th Jun 2003 at 12:57 PM.
Wormbo is offline   Reply With Quote
Old 26th Jun 2003, 02:53 PM   #4
Drew
Registered User
 
Join Date: May. 15th, 2003
Posts: 13
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.
Drew is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:05 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer