Colshape decorators have typo in type name
Ponjimon opened this issue · 11 comments
I was wondering why the decorator isn't working. I noticed that it should be entityEnterColshape
instead of entityEnterColShape
.
Same for the entityLeave....Not sure if I'm just doing something wrong or if it's an actual bug, but when I use
alt.on('entityEnterColshape', () => {})
it works fine
There is already an example in the docs: https://atlas.abstractmedia.de/basic-knowledge/decorators/decorator
Yes, I used that but it does not work. The event never triggers.
Hey @Ponjimon,
can you create an example repo to reproduce this part? It would be faster for search where the error comes from.
Forget what i written, you are on the right way with you first intention for this bug.
I have a typo error inside the typename. Other words alt:V has this typo in his eventName XD
Colshape is not the right spelling it comes from Collision Shape and not from Collisionshape :D
I've been using the typeName as eventName and with the uppercase S it wouldn't work :D
I will fix this after work and bump the version 👍
Haha, nice, so I was right all along :P
Thanks for the PR! I'm fairly new to alt:v development and stumbled upon this repo, really nice work and helpful :)
For consistency's sake, might want to change the event names as well?
atlas/packages/atlas-shared/src/constants/event.contstant.ts
Lines 14 to 15 in 51a1fed
Not sure if I should open a new issue for this or not, I'll just ask this here since it's related.
How exactly do you set the name of a colshape?
Because I'm using the decorator as stated in the documentation:
// Would be triggered if colshape is cylinder
@EntityEnterColShape(ColShapeType.Cylinder)
public testEnter3(colshape: Colshape, entity: Entity): void {
UtilsService.log('cylinder');
}
The problem is this line:
Both event.validationOptions.name
and colShape.name
are undefined
for me, meaning, it will always return here and won't actually trigger the listener method.
So either is this some bug or I don't know how to set a name for a colshape? From what I can see, neither the Colshape
class nor the classes it extends have a name
property, so what exactly is used here? The class name itself?
ENTITY_ENTER_COLSHAPE = 'atlas-shared:events:entityEnterColShape',
ENTITY_LEAVE_COLSHAPE = 'atlas-shared:events:entityLeaveColShape',
This is not the eventName ;) This is the Reflection Key, no need for change here
Not sure if I should open a new issue for this or not, I'll just ask this here since it's related.
How exactly do you set the name of a colshape?
Because I'm using the decorator as stated in the documentation:
// Would be triggered if colshape is cylinder @EntityEnterColShape(ColShapeType.Cylinder) public testEnter3(colshape: Colshape, entity: Entity): void { UtilsService.log('cylinder'); }The problem is this line:
Both
event.validationOptions.name
andcolShape.name
areundefined
for me, meaning, it will always return here and won't actually trigger the listener method.So either is this some bug or I don't know how to set a name for a colshape? From what I can see, neither the
Colshape
class nor the classes it extends have aname
property, so what exactly is used here? The class name itself?
Please note, the internal event usage is not the same as alt:V provides. the validationOptions.name would be set by Decorator and you must do nothing, the colShape.name is setup automatically for you if you set it up.
https://atlas.abstractmedia.de/basic-knowledge/decorators/decorator#colshape-decorator
This prevent other colshape events for call if the name does not exists. The main reason why it is not working right now, is the wrong eventName the fixed in #11
I will review and merge later and bump up the framework version.
This prevent other colshape events for call if the name does not exists. The main reason why it is not working right now, is the wrong eventName the fixed in #11
When debugging, I already changed the types to the correct capitalization and now I just updated to the latest version, but as I said, it is still not working because of this:
Both event.validationOptions.name and colShape.name are undefined for me, meaning, it will always return here and won't actually trigger the listener method.
I get why you're doing this but the Colshape
class in the alt typings does not have (or at least expose) a name
property. Because of this, I cannot set a name for the colshape, so my question is: How did you intend this to be used? Having the decorator decorating a method is only one side of a coin, there's no example in the documentation regarding the creating of a Colshape.
I know that creating it is out of the scope of this project, but given that the default usage does not work, an example would be helpful.
Please come to our discord, there is a better place for help you
You will find the link on the Docs Page bottom left
Fixed with version 2.0.7