Portal Inventory Clean Up Optimization

Code setup to dump inventory data into a new temporary table. Once table is full, I parse that table against the PortalInventory table and create a PortalList table which is all portals that need to be put away.
master
icecool 6 years ago
parent ddfffea399
commit b851921ea9

@ -74,7 +74,7 @@ WISH LIST:
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger> match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
<trigger name="InvDataPortCleanData" group="GroupPortalCleanUp" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddInvPortalListItem" <trigger name="InvDataPortCleanData" group="GroupPortalCleanUp" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_AddInvPortalListItem"
match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger> match="^(?<objid>\d+),\w+,.*,(?<objlevel>\d+),(?<objtype>\d+),\d+,(?<objwear>.*),.*$" ></trigger>
<!-- Triggers for Portal Inventory Clean Up --> <!-- Triggers for InvData end -->
<trigger name="InvDataEnd" group="GroupEqSync" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData" <trigger name="InvDataEnd" group="GroupEqSync" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
match="^\{\/invdata\}$"></trigger> match="^\{\/invdata\}$"></trigger>
<trigger name="InvDataInvCleanUpEnd" group="GroupInventoryCleanup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData" <trigger name="InvDataInvCleanUpEnd" group="GroupInventoryCleanup" enabled="n" regexp="y" omit_from_output="y" sequence="100" script="TRIGGER_EndInvData"
@ -449,8 +449,7 @@ function TRIGGER_AddPortalInvItem( name, line, args )
dnote(("%s TRIGGER_AddPortalItem did not provide an argument for objid"):format(Prepend)) dnote(("%s TRIGGER_AddPortalItem did not provide an argument for objid"):format(Prepend))
return return
end end
local obj_id = tostring(args.objid) table.insert(PortalInventory, 1, tostring(args.objid))
table.insert(PortalInventory, 1, obj_id)
dnote(("%s TRIGGER_AddPortalItem(%s) called. Added %s to PortalInventory table."):format(Prepend, obj_id, obj_id)) dnote(("%s TRIGGER_AddPortalItem(%s) called. Added %s to PortalInventory table."):format(Prepend, obj_id, obj_id))
cnote(("%s Portal(%s) was added Portal Inventory."):format(Prepend, obj_id)) cnote(("%s Portal(%s) was added Portal Inventory."):format(Prepend, obj_id))
end end
@ -459,14 +458,8 @@ function TRIGGER_AddInvPortalListItem( name, line, args )
dnote(("%s TRIGGER_CreateInventoryPortalListItem() did not have an args.objid argument."):format(Prepend)) dnote(("%s TRIGGER_CreateInventoryPortalListItem() did not have an args.objid argument."):format(Prepend))
return return
end end
local objid = tostring(args.objid) if not temporaryPortalList then temporaryPortalList = {} end
for obj, list in pairs(PortalInventory) do table.insert( temporaryPortalList, 1, tostring(args.objid) )
if PortalInventory[obj] == objid then
table.insert(PortalList, 1, objid)
dnote(("%s TRIGGER_CreateInventoryPortalListItem added Object ID#%s to PortalList table."):format(Prepend,objid))
return
end
end
end end
function TRIGGER_EndInvData( name, line, args ) function TRIGGER_EndInvData( name, line, args )
if name == "InvDataEnd" then if name == "InvDataEnd" then
@ -486,7 +479,8 @@ function TRIGGER_EndInvData( name, line, args )
elseif name == "InvDataPortCleanEnd" then elseif name == "InvDataPortCleanEnd" then
EnableTriggerGroup("GroupInvDataStart", false) EnableTriggerGroup("GroupInvDataStart", false)
EnableTriggerGroup("GroupPortalCleanUp", false) EnableTriggerGroup("GroupPortalCleanUp", false)
InventoryManager.PortalCleanUp() dnote(("%s Now creating a temporary 'inventory' table to then process against PortalInventory table."):format(Prepend))
InventoryManager.ProcessPortalCleanUpList()
end end
end end
]]> </script> ]]> </script>
@ -532,6 +526,18 @@ function InventoryManager.InventoryCleanUp()
end end
InvList = { } InvList = { }
end end
function InventoryManager.ProcessPortalCleanUpList()
for invdata, value in pairs(PortalInventory) do
for portal, objid in pairs(temporaryPortalList) do
if objid == value then
dnote(("%s @wInventoryManager.ProcessPortalCleanUpList added portal(@R%s@w) to PortalList for cleanup.@w"):format(Prepend, objid))
table.insert(PortalList, 1, objid)
break
end
end
end
InventoryManager.PortalCleanUp()
end
function InventoryManager.PortalCleanUp() function InventoryManager.PortalCleanUp()
if #PortalList == 0 then if #PortalList == 0 then
dnote(("%s InventoryManager.PortalCleanUp() is reporting PortalList as emtpy."):format(Prepend)) dnote(("%s InventoryManager.PortalCleanUp() is reporting PortalList as emtpy."):format(Prepend))
@ -543,6 +549,7 @@ function InventoryManager.PortalCleanUp()
SendNoEcho(("put %s %d"):format(PortalList[obj], EqCheckSettings.PortalBag)) SendNoEcho(("put %s %d"):format(PortalList[obj], EqCheckSettings.PortalBag))
end end
InvList = { } InvList = { }
end end
]]> </script> ]]> </script>
</muclient> </muclient>
Loading…
Cancel
Save