• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Mutator not being loaded because it can't find it's class

Shepard62700FR

Active member
Mar 7, 2012
44
1
France
SOLVED: For those who have the same problem, make sure that the "MyMutator.u" file that "KFEditor.exe make" generates is located in "C:\Users\<Your Windows Account>\Documents\My Games\KillingFloor2\KFGame\Unpublished\BrewedPC\Script". Mine was located in "C:\Users\Shepard\Documents\My Games\KillingFloor2\KFGame\Unpublished\Unpublished\Unpublished\BrewedPC\Script" for an unknown reason.

Hello,

I'm currently trying to make a very basic mutator (say "Hello World" 1000 times). I have followed everything written here but I can't test it, here's the only things I've got in my log when I try to test it:
Code:
[0426.49] ScriptLog: Mutators HelloWorldMut.HelloWorldMut
[0426.49] Warning: Warning, Failed to load 'Class HelloWorldMut.HelloWorldMut': Failed to find object 'Class HelloWorldMut.HelloWorldMut'

Here is the mutator's code:
Code:
class HelloWorldMut extends Mutator;

var int counter;

function PostBeginPlay()
{
	Super.PostBeginPlay();

	if (WorldInfo.Game.BaseMutator == None)
		WorldInfo.Game.BaseMutator = Self;
	else
		WorldInfo.Game.BaseMutator.AddMutator(Self);

	counter = 0;
	SetTimer(0.1, true, 'HelloWorldTimer');
}

function AddMutator(Mutator M)
{
	if (M != Self)
	{
		if (M.Class == Class)
			M.Destroy();
		else
			Super.AddMutator(M);
	}
}

function HelloWorldTimer()
{
	local int i;

	for (i = 0; i < 999; i++)
		`log("HelloWorldMut - Hello World for the "$(i + 1)$" time!");

	ClearTimer('HelloWorldTimer');
}

defaultproperties
{
}

My mutator is placed in: "C:\Users\Shepard\Documents\My Games\KFGame\Src\HelloWorldMut\Classes\HelloWorldMut.uc"

My "KFEditor.ini":
Code:
[ModPackages]
ModPackagesInPath=..\..\KFGame\Src
ModOutputDir=..\..\KFGame\Unpublished\CookedPC\Script
ModPackages=HelloWorldMut

"KFEditor.exe make" returns no error, the mutator compiles fine. I'm running the game with the "-useunpublished" parameter and I'm using this command to test: "open KF-BurningParis?Mutator=HelloWorldMut.HelloWorldMut"
 
Last edited:
Is there a HelloWorldMut.u file in your script folder?

Try launching the game with the mutator, instead of ingame:
KFGame.exe KF-BioticsLab?Mutator=HelloWorldMut.HelloWordMut -useunpublished
The "HelloWorldMut.u" file was located here: "C:\Users\Shepard\Documents\My Games\KillingFloor2\KFGame\Unpublished\Unpublished\Unpublished\BrewedPC\Script". So I moved it to make sure there is only 1 "Unpublished" folder and it worked.

I don't know why I had 3 "Unpublished" folders, it is a KFEditor or Windows 10 issue, I don't know.

Thank you Slie, problem solved ^^
 
Upvote 0
Please correct me if I'm wrong anyone but the helloworld function would only print 999 times. I'm sure 1 isn't a big deal here but I'm from the Arch Linux world and code correctness is priority. I'm new to the UDK and Uscript all together with almost no exp with OOP. Thus I'm asking strictly to clarify for my own knowledge, but would a "For" loop be a better solution?

something like
Code:
for(i = 0; i < 1000; i ++ )
{
`log("HelloWorldMut - Hello World!");
}

And would it still need to be included into some function?
 
Upvote 0
Please correct me if I'm wrong anyone but the helloworld function would only print 999 times.

It would print the 0 and 1000, so it would actually be 1001 times.

That example is for demonstration not practicality. Loops would be better. The loop would need to be inside some form of a function that gets called. PostBeginPlay is called automatically when the mutator is loaded.
 
Last edited:
Upvote 0