Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2021, 01:19 PM
Jizamuss
Fire Beetle
 
Join Date: Jul 2006
Posts: 3
Default items.lua issue and my resolution

In the current items.lua I was having issues with turning in stacks of items
I slightly modified this part and things started working as expected.
Hopefully someone will find this useful down the road.
(Nested while loop for multiple items worth different aa values was my project)

Changed if(inst.valid and trade_check[inst:GetID()] > 0)
TO if(inst.valid and trade_check[inst:GetID()] ~= nil)


-- trade_check contains item_id => qty mapping
-- for each item handed to us, check if it is in trade_check
for i = 1, 4 do
local inst = trade_return["item" .. i] -- get an item instance that was handed to us
if(inst.valid and trade_check[inst:GetID()] > 0) then -- we have a valid item and it's ID is in the trade_check map
if (inst:IsStackable()) then
while (trade_check[inst:GetID()] > 0 and inst:GetCharges() >= trade_check[inst:GetID()]) do
inst:SetCharges(inst:GetCharges() - 1) -- remove one item from the stack
trade_check[inst:GetID()] = trade_check[inst:GetID()] - 1 -- decrement the count of required items in trade_check
end
if (inst:GetCharges() > 0) then -- still have items in the stack, return the remainder
trade_return["item" .. i] = inst
else
trade_return["item" .. i] = ItemInst() -- stack empty, return nothing
end
else
trade_return["item" .. i] = ItemInst() -- remove this item from our return queue
trade_check[inst:GetID()] = trade_check[inst:GetID()] - 1 -- decrement the count of required items in trade_check
end
end
end
Reply With Quote
Reply

Tags
items, items.lua, loop, nested, trade_check


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 03:23 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3