SWEP Loading

So i’m setting up some enums in my base SWEP. Let’s say i do this:

TEST_ENUM = 1[/lua]

In a weapon that uses it as a base, i’m setting a variable to use the global. Something like:

SWEP.Primary.Test = TEST_ENUM[/lua]

The problem is, it seems my weapons that use the base SWEP are loaded first (before the base SWEP is loaded), so the enum doesn’t exist when they’re set up. So as a result, SWEP.Primary.Test is nil.

How is it determined which SWEPs are loaded first? What’s the best solution to this problem other than setting the variable at a later time?

I guess i could always set the variable in the SWEP:Initialize hook, but is that the best solution?


Okay i did some testing and yes, weapons are loaded in alphabetical order.

So a hacky workaround would be to rename me weapon base… But honestly, shouldn’t base sweps be loaded first by default?

Define your enums inside a file that the gamemode loads. The gamemode itself appears to be loaded before the SWEPs.

It might not be as elegant of a solution as you want, but I know it works.

yeah that was my last-ditch solution.

i just like being organized, having these enums in my swep base made so much more sense :frowning: