UE1 - UT Calling function in another mutator (and getting result back)

  • 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.

playsax

New Member
Feb 20, 2008
44
0
0
I am attempting to call a function that resides in another mutator and using the return value in my mutator. Here is what I have done so far. It compiles ok, but the function never gets called... (put a few log()'s in the function).

My Mutator:
Code:
var [COLOR="Red"]OtherMutator[/COLOR] OtherMut;

function timer()
{
	local pawn p;
	local string PS;
	for (p=Level.PawnList; p!=None; p=p.NextPawn) {
	PS = OtherMut.OtherFunc(p.playerreplicationinfo.playername);
        log(PS);
	}
}

The OtherMutator (the return string is for illustrative purposes):
Code:
function string OtherFunc(string PlayerName) {
log("OtherFunc was called");
return "I like"@PlayerName;
}

I hope this shows what I'm trying to do. Can it be done like this? Is there a better way... Your help is much appreciated.
 
Last edited:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Of course the function is never called, the variable it is being called on does not contain any object. Your log file should contain an Accessed None warning for every attempt to call the function.
 

playsax

New Member
Feb 20, 2008
44
0
0
Of course the function is never called

Is it possible to do what I want at all, in any way that you know of..? :(

I tried to assign the correct object to OtherMut, but it fails to compile...

Code:
var Mutator OtherMut;

function timer()
{
local Mutator M;
    for( M = Level.Game.BaseMutator; M != None; M = M.NextMutator )
    if(M.IsA('OtherMutator')) OtherMut=M;
OtherMut.OtherFunc(p.playerreplicationinfo.playername);
}

It fails telling me it cannot find the function OtherFunc(). I have run out of ideas here..
 
Last edited:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
There's no "OtherFunc" in the Mutator class, so you'll have to typecast the Mutator reference M to OtherMutator at some point, preferably when assigning M to OtherMut. (Declare OtherMut as a variable of type OtherMutator again.)