Deriving from SWEP base that has tables underneath the SWEP table
2 replies, posted
Take a gander at the very beginning of my script:
[code]--[[
_|_| _| _| _|_|
_| _| _|_|_| _|_|_| _|_|_|_| _|_|_| _|_| _|_|_| _|_| _| _|
_|_|_|_| _| _| _| _| _| _| _| _|_|_|_| _| _| _| _|_|_|_|
_| _| _| _| _| _| _| _| _| _| _| _| _| _| _|
_| _| _| _| _|_|_| _|_| _| _| _|_|_| _| _| _| _| _|
Scripted Weapon Base by wauterboi
]]--
SWEP.Anathema = true
-- Tables *DO NOT TOUCH*
SWEP.Mode = { }
SWEP.Mode.Ducking = { }
SWEP.Mode.Ironsight = { }
SWEP.Mode.Walking = { }
SWEP.Mode.Sprinting = { }
SWEP.Mode.Misc = { }
SWEP.Primary = { }
SWEP.Primary.Damage = { }
SWEP.Primary.Recoil = { }
SWEP.Primary.Recoil.Pattern = { }
SWEP.Primary.Recoil.Pattern.X = { }
SWEP.Primary.Recoil.Pattern.Y = { }
SWEP.Primary.Spread = { }
SWEP.Primary.BulletDrop = { }
SWEP.Primary.Reload = { }
SWEP.Primary.Sound = { }
SWEP.Primary.Effect = { }
SWEP.Primary.Scope = { }
SWEP.Primary.Scope.Sound = { }[/code]
This is great and all, but if I head to a separate script and try to access any of the variables outside of the default bottom-level of SWEP or the default tables like "Primary", I get an error saying that the variable doesn't exist. However, all of the values are there in the sense that the functions and everything work from the base variables.
This means that if I want to access a variable within the Spread table, I have to create the entire table for that and put in all of the variables in there just like I would in the base, which is pretty lame. My goal is to have it so I can just plop in just the bare minimum stuff I need changed and call it a day, just like you would with a normal weapon base derivative.
Any ideas as to what I can do?
[QUOTE=Willox;47854046]Using SWEP.Primary = BaseClass.Primary would be dangerous because the base class may have not loaded yet. The only real solution is to handle it all in SWEP:Initialize().[/QUOTE]
I forgot I opened a thread for this. The problem I have is I already have SWEP:Initialize set.
I was thinking of creating a separate table and then just copying everything over within the base Initialize hook, but I'm seriously at loss as to how to do that.
In SWEP:Initialize() you can call BaseClass.Initialize( self ).
Sorry, you need to Log In to post a reply to this thread.