wiremod / wire

Garry's Mod add-on that allows users to wire up components in order to make more elaborate automatic and user-controlled contraptions.
http://www.wiremod.com
Apache License 2.0
551 stars 331 forks source link

`entity:aimBone()` does not return a valid bone #3018

Open Denneisk opened 5 months ago

Denneisk commented 5 months ago

Description When using entity:aimBone(), the bone will be null despite looking at a proper ragdoll. Using entity:bone(number) on an entity does not cause this.

To Reproduce Steps to reproduce the behavior:

  1. Put this code on a chip
    @strict
    event keyPressed(_:entity, _:string, Down:number, KeyBind:string) {
       if(Down & KeyBind == "use") {
           print(owner():aimBone())
       }
    }
  2. Press E on a ragdoll
  3. Observe the print statement will say (null)

Expected behavior The print statement should show something like Entity [100][prop_ragdoll]:bone(1).

Notes: In testing this, entity:aimBone() does return a valid bone, but in isValidBone, the bone gets invalidated wrongly. When performing bone2entity[b], this returns nil even when an equivalent reference to the bone is in the table. Annoyingly, this only happens when using aimBone. This shouldn't happen since getBone uses a cached value which is guaranteed to be in bone2index, bone2entity, and entity2bone.