From Garry's Mod
Jump to: navigation, search

This should be a function, not a hook. --NeatNit 10:42, 19 February 2017 (UTC)

Fixed --NeatNit 11:16, 19 February 2017 (UTC)

Why? These Weapon functions are meta functions defined by the engine. WEAPON:ShootBullet() is a lua defined callback for weapons. I think it should be left as hook. -- markusmarkusz

In concept, a hook is an event that you have the opportunity to act upon. In weapons, this is always done by creating/replacing the existing function of the same name in the weapon's meta table. In contrast, a function is something that you can call, but in general you're not supposed to replace it and redefine its behavior. It doesn't matter whether it's Lua defined or not. ShootBullet is not a callback.
See also Entity/SetAutomaticFrameAdvance for an identical situation.
--NeatNit 05:06, 20 February 2017 (UTC)

Page category defines method availability, not its status as a hook or not. Category:WEAPON_Hooks (Although WEAPON_Hooks isn't a great name) contains all methods that are only usable on SWEPs by default, Category:Weapon contains all methods usable on all weapons. --Robotboy655 10:07, 22 February 2017 (UTC)

The real issue is stuff like this: ENTITY/SetTask behing put into ENTITY_Hooks category. This really makes me wish this whole wiki thing was better thought out when it was made. --Robotboy655 10:18, 22 February 2017 (UTC)
And changing this all yet again will require backend changes for sidebar, again. --Robotboy655 10:20, 22 February 2017 (UTC)
Renaming WEAPON_Hooks to SWEP is not possible, is it? -- markusmarkusz 14:54 (CET), 22 February 2017
I see it completely differently. Hooks are relevant for those who are defining a weapon/entity/etc or defining new behavior, and almost always are supposed to be overridden where applicable, but NEVER called by the user. A key example is Initialize - you initialize your entity in there, but if you actually call ent:Initialize then you've gone mad.
The availability of a method - and it doesn't sit right with me to call them all methods - has nothing to do with whether it's a hook or a function. The distinction between hooks as functions is trivial: hooks are called by the game to be handled by the user. Functions are exposed by the entity to be called by the user. Hooks are never called by the user, Functions are.
If you care about method availability, the first counterexample I could find is Entity/AddGesture, which states in a note that it doesn't actually work on all entities. If it's really important to you, then perhaps we should create a new class -- a functions class -- to hold SWEP functions (exposed by the lua weapon_base) and another for SENT functions, and another for BaseAnimatingOverlay functions. But they definitely shouldn't be under Hooks, because they're not hooks.
--NeatNit 15:15, 22 February 2017 (UTC)
I am not saying that every Lua defined SWEP/ENT hook/function should be in the hooks category, what I am saying is that it's wrong that everything currently is placed under *_Hooks, with the example of ENTITY/SetTask which is clearly not a hook.
What I am saying is that SENT/SWEP functions should be placed under WEAPON/ENTITY, not Weapon/Entity because if you'd try to use ShootBullet on a HL2 weapon, it will produce a Lua error, but if you'd use Entity/AddGesture on an unsupported entity, it will not produce a Lua error, but will instead just silently fail.
Yes, we should fix SWEP/ENT functions being placed under hooks. No, we should not be renaming the page name to do so. It is a matter of putting the pages into correct categories via correct templates. But this then splits all SWEP stuff into two categories which is also somewhat bad.
I guess this also brings back your point of Category:Tool vs Category:TOOL_Hooks which needs to be solved across TOOL/ENT/SWEP. I also guess some of the TOOL stuff might also be affected by this inconsistency.
I'd also argue that WEAPON/ShootBullet can be considered a hook, since you can override it to easily make the SWEP shoot something other than bullets without modifying the primary fire function (which will result in just copypasting most of the code, which is why certain actual hooks exist), but of course now with the addition of GM/EntityFireBullets it is obsolete to an extent
You should refrain from making mass edits on this without talking about it with me on Steam or w/e just so we both agree on how this should be done to avoid unnecessary edits --Robotboy655 21:57, 22 February 2017 (UTC)
Oh, I understand now. The "obvious" solution would be to put SWEP functions under Category:weapon_base (to reflect the actual metatable name where they're defined), but that's just ugly. It also would still mean renaming the pages, which you're against.
Worth noting that I don't think all-caps "ENT"/"WEAPON" should be associated with it being Lua-scripted or not. To me, it's an indication that something is a hook. I can definitely see why it makes sense to you, I just disagree. SWEP is possibly an exception because SWep just looks wrong, but SWEP isn't even used on this wiki besides the sidebar so it's moot.
Regarding 'mass edits', you're right of course. To me this seemed like an obviously and objectively correct move, I see now that it wasn't. I'll be more conservative in the future.
--NeatNit 06:19, 23 February 2017 (UTC)
Personal tools