So how do entity/weapon/etc bases work? What exactly do they do?
By using/Creating a base, you can easily make more sweps/gamemodes/sents/etc more easily and quickly.
One good example is the weapon_cs_base located at garrysmod/addons/counter-strike/lua/weapons
That is the base for all the other Counter Strike weapons, notice how (example) lua/weapons/weapon_ak47/shared.lua line 24 declares the base. And how small, easy and quick it looks to make that swep.
They basically provide a back bone, and you just add on the fore bits to make some thing usable. there are SEnt bases, gamemode bases and more.
Cool. Thanks.
So basically every line included in the base is in the script that uses it?
[QUOTE=braxus;17149440]Cool. Thanks.
So basically every line included in the base is in the script that uses it?[/QUOTE]
Yes you can put it that way.
Can I replace the variables in the base? As if the base has a variable named ENT.Health and is set to 0...can an entity using the base have it be different? Will it replace the base's variable?
[QUOTE=braxus;17149534]Can I replace the variables in the base? As if the base has a variable named ENT.Health and is set to 0...can an entity using the base have it be different? Will it replace the base's variable?[/QUOTE]
Yes I do believe so. If you don't declare/override, the SEnt/Weapon/etc will use the bases default set value.
It doesn't replace the bases actual variable. If in one SWep you set the SWEP.Primary.ClipSize to 25, it will only be set to 25 within that one SWep. Any other swep will either use it's own value, or the bases default.
Like I said, take a look at the weapon_cs_base and see how other cs sweps are made with it.
Ok. Thank you very much! :)
You can also make things happen in the base which can hook onto a custom function for each swep, like making a SWEP:TertiaryFire() function (which is a custom function) and then hooking it into the sweps primary fire or secondary fire, letting you have special effects for each weapon, but also keeping it's normal primary or secondary features without copypasting the sections you need into your swep from the base.
Sorry, you need to Log In to post a reply to this thread.