Log in

View Full Version : need help finishing something



FiestaMan
12-27-2015, 07:03 PM
can someone please tell me why when i execute this lua it wont use the key on the door?

LockedID = 1631
KeyID = 2969

--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------

Looter.Start()
Targeting.Start()
registerEventListener(WALKER_SELECTLABEL, "onLabel")
--========FUNCTIONS====================--
function onLabel(label)
if (label == "key") then
Walker.Stop()
wait(1600,3200)
end
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(1600,3200)
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
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
end