1. Until a recent rust update, I used to be able to use OnItemDeployed to get code lock information when placing a lock on a door, but, now I only get the door information. Is there another way to get code lock information when placed? A OnCodeLockDeployed or something similar? Thanks.
     
  2. You can get CodeLock via Reflection.
    Code:
    void OnItemDeployed(Deployer deployer, BaseEntity entity)
    {
        Door door = (Door)entity;    FieldInfo info = typeof(BaseEntity).GetField("entitySlots", BindingFlags.Instance | BindingFlags.NonPublic);    EntityRef[] entitySlots = (EntityRef[])info.GetValue(door);    CodeLock codeLock = (CodeLock)entitySlots[0].Get(true);
    }
    [DOUBLEPOST=1469296098][/DOUBLEPOST]Or just
    Code:
    Door door = (Door)entity;
    CodeLock codeLock = (CodeLock)door.GetSlot(BaseEntity.Slot.Lock);
    :D
     
  3. Yea..CodeLock fun :p

     
  4. Thanks for the help and code, could you help me with a lua translation (yes I still use lua).

    Code:
    local buildingBlock = entity:GetComponentInParent(global.Door._type)
    local lock = buildingBlock:GetComponent("BaseEntity"):GetSlot(0)
    Thats a cool idea, never seen or thought of that before.
     
  5. .... ;)
     
  6. Sorry, been away. Can anyone lend some assistance with lua translations? Thanks.
     
  7. Im not the best in lua but I managed to get something without any errors:
    Code:
    function PLUGIN:DoStuff(player, entity)
        local door = entity(Door)
        local codeLock = (CodeLock)door:GetSlot(BaseEntity.Slot.Lock)
    end
    [DOUBLEPOST=1470600649][/DOUBLEPOST]or @deer_SWAG 's option:
    Code:
    function PLUGIN:DoStuff(player, entity)
        local door = entity(Door)
        local info = typeof(BaseEntity).GetField("entitySlots", BindingFlags.Instance and BindingFlags.NonPublic)
        local entitySlots = (EntityRef)info.GetValue(door)
        local codeLock = (CodeLock)entitySlots[0].Get(true);
    end
     
  8. Thank you :) Will give it a go when I get back to my computer.
     
  9. I'm sure i'm missing something simple but I keep running into these errors.

    Code:
    attempt to call local 'entity' (a userdata value)
    attempt to call global 'typeof' (a nil value)
    I provide the entity information from OnItemDeployed.