Closed TetraTheta closed 2 months ago
It's not impossible, but it is unfeasible.
The way scripted entities work is that there's a special entity class internally that calls all those Lua entity hooks. Getting what you want to work would require to have every single entity in the whole game call those Lua hooks separately. This is not only is a huge amount of work, it is also far less maintainable.
Thank you for the detailed explanation about why it is not implemented yet!
All I've heard so far were just "no you can't" or "you have to re-implement vital functions in Lua way"...
I 100% understand about your explanation and stance. Thank you for the kind answer!
The description of
ENT.Base
says 'The base entity to derive from. This must be a valid Lua entity'.This is frustrating because I want to make a separate SENT/SNPC that the differences between origianl entity are just few functions. Some may be implemented by using hook, but some won't be able to implement becuase there is no corresponding hook for it.
For example:
npc_turret_floor_g
derived fromnpc_turret_floor
Can be done with
EntityFireBullets
hook, but I personally don't think this is good implementation, because the hooked function will be called every time any entity fires a bullet, instead of certain entity fires a bullet.CLASS_NONE
whenNPC:Classify()
is calledThere is no corresponding hook for this.
npc_manhack_g
derived fromnpc_manhack
TranslateSchedule
hook, the entity must be SNPC, but SNPC can't use Engine Entity as its base, so I must re-write wholenpc_manhack
code into Lua in order to use this.But how to call
BaseClass::TranslateSchedule(scheduleType)
in Lua way?As far as I know, to override few aspects of Engine Entity, I have to either re-write its code into Lua and modify it, or use hook that might not be available.
Entity:AddCallback
exists, but it seems this is only available forOnAngleChange
,BuildBonePositions
,PhysicsCollide
,BuildFlexWeights
, according to Entity Callbacks that is linked inEntity:AddCallback
. If then, this is not what I should use.If there is a way to implement these things currently, please tell me how to do it.
If this isn't possible at all, it would be very nice to tell me the detailed reason of why it can't be implemented, not just 'impossible'.