XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 10 of 18

Thread: Open door with key.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Senior Member Aristeus's Avatar
    Join Date
    Jun 2013
    Location
    Sweden
    Posts
    600
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    There are better ways to do it.

    Something like this might work.

    lua code:


    LockedID = ID of the locked door.
    KeyID = ID of the key.

    Walker.Stop()
    wait(800,1600)
    if Map.GetTopUseItem(X, Y, Z).id == LockedID then --- checks the id of the locked door
    useKeyOnDoor(KeyID, X, Y, Z) --- opens if locked.
    wait(400,600)
    Walker.Start()
    else
    if not Map.IsTileWalkable(X, Y, Z) then Self.UseDoor(X, Y, Z) --- opens door if unlocked
    Walker.Start()
    end
    Walker.Start() ---- If door is neither locked or closed it'll just go to the next node and walk through it
    end




    This is the function for "useKeyOnDoor" (paste it in the same script.)

    lua code:

    function useKeyOnDoor(keyID, x, y, z) --- from forgee's library
    local Cont = Container.New(0) -- check in main backpack (index is 0)
    if Cont:CountItemsOfID(keyID) > 0 then
    for s = 0, Cont:ItemCount() do --find specific itemid spot
    local item = Cont:GetItemData(s)
    if item.id == keyID then
    Cont:UseItemWithGround(s, x, y, z)
    end
    end
    end
    end

    Last edited by Aristeus; 12-23-2015 at 01:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •