Error: ...attempt to call global `ClassInitialize' (a nil value)

I have been modding Homeworld 2 since its release in 2003 as a hobby. For the last year or so I have been spending serious time (6 - 12 hrs a day) in creating a new mod that I plan upon releasing to the community. This morning, at 0300, I inexplicably ran into an error while loading the mod and I cannot for the life of me figure out what the problem is. I am hoping that someone here can help. This is the first time I have asked for help regarding my mod on any forum.

The error, as it appears in the hw2.log:

parameter: attempt to call global `ClassInitialize' (a nil value) stack traceback: 1: function `oninit' at line 90 [string ""] CPUPLAYER -- error in CPUPlayer: oninit() function was not found in CPU script -- FATAL EXIT

The dumpfile only repeats this error with no further info.

The “ClassInitialize” call referred to is located in default.lua and refers (or used to refer) to the ClassInitialize function in classdef.lua via a dofilepath. I cannot imagine why there is an error at all as I have touched neither the default nor classdef files since last successfully loading the game. The files that I was tweaking, just prior to the error, were hgn_mothership_parade.lua, build.lua, research.lua and my mod’s ‘deathmatch’ lua gamefile. Although I have attempted to ‘undo’ all changes I have made, the error remains.

I know that there are some real experts here that are far more knowledgable than I. Might someone assist me in troubleshooting this difficulty?

Yesterday was Tuesday… Did a Windows patch drop and get installed on you? I ask because if so, it may have rearranged or updated something critical that the game code relies on.

1 Like

I do not allow automatic Windows updates nor do I update my Windows 7 on this machine at all, but thank you for the suggestion.

@radar3301 @sastrei @nathanius @Pouk @PayDay @BitVenom @EatThePath @Dom2 @Dwarfinator

Can any of you guys help me with this? This is heart-rending as I cannot proceed and I have put a great deal of time, effort and sweat, (but no blood) into this mod.

1 Like

default and classdef are in the AI files, right?

1 Like

Yes, both.

Do you have an AI folder? if so, rename the AI directory to something other than ai (my default choice is ~ai)

1 Like

Just before you responded I added another dofilepath to default.lua just prior to the ClassInitialize function. It gave me an error that I could work with. Apparently I had in fact added…

AddClassName(eCruiser, "Cruiser")

… to the end of the classdef file. I deleted that.

I tried to start the game and it stopped upon another error, at FRONTEND, with no error recorded in either hw2.log nor the dumpfile.

I tried your suggestion as well, but now I get as far as FRONTEND and the game goes back to the desktop. Again, no errors recorded in hw2.log nor minidump.?

What files are involved in FRONTEND?

@radar3301 Well, I want to thank you very much for your help. I was feeling completely lost, but your suggestion of renaming the AI folder gave me the tool that I needed. I had apparently modified much more than it had seemed. The first problem was the aforementioned ‘AddClassName(eCruiser, “Cruiser”)’ in the classdef.lua. Upon backtracking I decided to rename the Hiigaran building and research folder (with the ~) as I had been working upon that last night. I had added a build (Hgn_MassShield) that the game found troubling and once removed, the game loads wonderfully!

Again, thank you radar3301. You are a lifesaver.


Glad I was able to help get you on the right track!