View Single Post
04/18/18, 11:44 AM   #5
Phuein
 
Phuein's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 132
Originally Posted by Rhyono View Post
So your goal is to lock the item? I haven't tested this, but is this what you want?

lua Code:
  1. if CanItemBePlayerLocked(slotId,bagId) then
  2.     SetItemIsPlayerLocked(slotId,bagId,true)
  3. else
  4.     d("Item cannot be locked.")
  5. end

That was what I was looking for - although bag and slot are reversed, should be:
Code:
	local bag, index = bagId, slotId
	local locking = not IsItemPlayerLocked(bag, index) -- The locking state to apply.
	if CanItemBePlayerLocked(bag, index) then
	    SetItemIsPlayerLocked(bag, index, locking)
	end

And the above works! BUT with that I saw the code calls to:
http://esodata.uesp.net/100015/src/i....lua.html#1179

SO, I would like to implement the original call into mine:
http://esodata.uesp.net/100022/src/i....lua.html#1630

I mimicked it for myself, but I get an unexpected error about:
Code:
Checking type on argument slotIndex failed in IsSlotLocked_lua
stack traceback:
	[C]: in function 'IsSlotLocked'
My code just copies from original and all values check out, but I can't find a .slotType anywhere, in control, nowhere. Thus my code:
Code:
	local inventorySlot = slotControl
	local bag, index = bagId, slotId -- ZO_Inventory_GetBagAndIndex(inventorySlot)
	local locking = not IsItemPlayerLocked(bag, index) -- The locking state to apply.
	local action
	
	if locking then
		action = SI_ITEM_ACTION_MARK_AS_LOCKED
		-- Can't lock these.
		if IsItemAlreadySlottedToCraft(inventorySlot) then return end
	else
		action = SI_ITEM_ACTION_UNMARK_AS_LOCKED
	end
	
    if not IsSlotLocked(inventorySlot) and CanItemBePlayerLocked(bag, index) and 
    	not QUICKSLOT_WINDOW:AreQuickSlotsShowing() then
        slotActions:AddSlotAction(action, 
        	function() MarkAsPlayerLockedHelper(bag, index, locking) end, 
        	"secondary")
    end

Last edited by Phuein : 04/18/18 at 07:53 PM.
  Reply With Quote