Go to Page... |
Compatibility: | Necrom (9.0.0) |
Updated: | 05/22/23 09:03 AM |
Created: | 05/10/20 05:35 PM |
Monthly downloads: | 4,281 |
Total downloads: | 392,559 |
Favorites: | 194 |
MD5: |
--input table of effect names for example {"RestoreHealth","RestoreMagicka","RestoreStamina"} --you can also add prolonged effect - an effect that will last longer because it appears in the combination 3 times, instead of 2 --prolonged effect always has to have key = 4 --for example, if you want a combination with only 2 effects and one of them to be prolonged you input {"RestoreHealth","RestoreMagicka",[4] = "RestoreHealth"} --outputs IDs (1st number in itemLinks, not actual itemLinks) for reagents that will create desired combination for cheapest price function LibAlchemy:getBestCombination(tableOfEffects) local effect1,effect2,effect3,prolongedEffect, Combinations if tableOfEffects[1] then effect1 = tableOfEffects[1] length = 1 end if tableOfEffects[2] then effect2 = tableOfEffects[2] length = 2 end if tableOfEffects[3] then effect3 = tableOfEffects[3] length = 3 end if tableOfEffects[4] then prolongedEffect = tableOfEffects[4] end if length == 3 then Combinations = LibAlchemy:ThreeEffects(effect1,effect2,effect3) if Combinations[1] == nil then Combinations = LibAlchemy:ThreeEffectsAlt(effect1,effect2,effect3) end Combinations = LibAlchemy:sortOutWrongCombinations3(Combinations,{effect1,effect2,effect3}) if prolongedEffect then Combinations = LibAlchemy:sortOutAdditional(Combinations,prolongedEffect) end BestCombination = LibAlchemy:getCheapestCombination(Combinations) return BestCombination elseif length == 2 then Combinations = LibAlchemy:TwoEffects(effect1,effect2) Combinations = LibAlchemy:sortOutWrongCombinations3(Combinations,{effect1,effect2}) if effectAdditional then Combinations = LibAlchemy:sortOutAdditional(Combinations,effectAdditional) end return LibAlchemy:getCheapestCombination(Combinations) elseif length == 1 then Combinations = LibAlchemy:OneEffect(effect1) Combinations = LibAlchemy:sortOutWrongCombinations2(Combinations,effect1) if effectAdditional then Combinations = LibAlchemy:OneEffectAlt(effect1) Combinations = LibAlchemy:sortOutWrongCombinations3(Combinations,{effect1}) Combinations = LibAlchemy:sortOutAdditional(Combinations,effectAdditional) end if not Combinations[1] then Combinations = LibAlchemy:OneEffect(effect1) local Combinations2 = {} for key,value in pairs(Combinations) do local negativeEffect = LibAlchemy:checkIfAdditional2Effect(value,effect1) for key2,value2 in pairs(LibAlchemy.effects[LibAlchemy.opposites[negativeEffect]]) do if LibAlchemy:checkIfAdditionalCorrect({value[1],value[2],value2},effect1) and LibAlchemy:checkIfAdditional3({value[1],value[2],value2},{effect1}) then Combinations2[#Combinations2 + 1] = {value[1],value[2],value2} end end end Combinations = Combinations2 end return LibAlchemy:getCheapestCombination(Combinations) end end --input table of reagents' IDs for example {30148,30149,30150} and itemLink --outputs crafting cost function LibAlchemy:getCraftingCost(reagentsTable,itemLink) local x,mainID,solvent,CP if GetItemLinkItemType(itemLink) == ITEMTYPE_MASTER_WRIT then x = LibAlchemy:ATconvertItemLink(itemLink) mainID = x.solvent solvent = 50 CP = 258 else mainID = select(4,ZO_LinkHandler_ParseLink(itemLink)) CP = tonumber(select(5,ZO_LinkHandler_ParseLink(itemLink))-select(6,ZO_LinkHandler_ParseLink(itemLink))) solvent = tonumber(select(6,ZO_LinkHandler_ParseLink(itemLink))-select(7,ZO_LinkHandler_ParseLink(itemLink))) end local result = 0 local type = 2 for key1,value1 in pairs(reagentsTable) do result = result + LibAlchemy.reagents[value1][2] end if solvent == 50 then result = result + LibAlchemy.solvents["CP"][CP][type] else result = result + LibAlchemy.solvents[solvent][type] end if mainID == 239 then return result elseif mainID == 199 then return result*4 elseif GetItemLinkItemType(itemLink) == 7 then return result/4 else return result/16 end end --input itemLink --outputs cheapest combination of reagents that will craft potion/poison required to fulfill master writ function LibAlchemy:getBestCombinationMasterWrit(itemLink) local x = LibAlchemy:ATconvertItemLink(itemLink) if x.solvent == 199 or x.solvent == 239 then local effect1 = LibAlchemy.effectsByWritID[x.effect1] local effect2 = LibAlchemy.effectsByWritID[x.effect2] local effect3 = LibAlchemy.effectsByWritID[x.effect3] if table.effect3 == 0 then local Combinations = LibAlchemy:TwoEffects(effect1,effect2) Combinations = LibAlchemy:sortOutWrongCombinations3(Combinations,{effect1,effect2}) return LibAlchemy:getCheapestCombination(Combinations) else local Combinations = LibAlchemy:ThreeEffects(effect1,effect2,effect3) if Combinations[1] == nil then Combinations = LibAlchemy:ThreeEffectsAlt(effect1,effect2,effect3) end return LibAlchemy:getCheapestCombination(Combinations) end end return nil end
LibAlchemy.effects = { ["RestoreHealth"] = { [1] = 30148, --Blue Entoloma [2] = 30160, --Bugloss [3] = 77585, --Butterfly Wing [4] = 30164, --Columbine [5] = 30163, --Mountain Flower [6] = 30166, --Water Hyacinth [7] = 30155, --Luminous Russula [8] = 150672, --Crimson Nirnroot }, ["LingeringHealth"] = { [1] = 77585, --Butterfly Wing [2] = 150731, --Dragon Blood [3] = 139019, --Powdered Mother of Pearl [4] = 77584, --Spider Egg [5] = 77589, --Scrib Jelly }, ["RestoreMagicka"] = { [1] = 30160, --Bugloss [2] = 30164, --Columbine [3] = 30161, --Corn Flower [4] = 30158, --Lady's Smock [5] = 150671, --Dragon Rheum [6] = 150670, --Vile Coagulant }, ["RestoreStamina"] = { [1] = 30163, --Mountain Flower [2] = 30164, --Columbine [3] = 30162, --Dragonthorn [4] = 30157, --Blessed Thistle [5] = 150731, --Dragon Blood [6] = 150669, --Chaurus Egg }, ["Unstoppable"] = { [1] = 30164, --Columbine [2] = 30153, --Namira's Rot [3] = 30159, --Wormwood }, ["Invisible"] = { [1] = 30148, --Blue Entoloma [2] = 30153, --Namira's Rot [3] = 150789, --Dragon Bile [4] = 30165, --Nirnroot [5] = 77584, --Spider Egg }, -- and more
File Name |
Version |
Size |
Uploader |
Date |
1.4 |
7kB |
Hyperioxes |
12/05/20 01:57 AM |
|
1.3 |
8kB |
Hyperioxes |
11/27/20 07:02 AM |
|
1.2a |
7kB |
Hyperioxes |
09/23/20 11:34 AM |
|
1.2 |
7kB |
Hyperioxes |
05/28/20 12:29 PM |
|
1.1 |
7kB |
Hyperioxes |
05/27/20 04:13 PM |
|
1.0 |
10kB |
05/10/20 05:35 PM |
Comment Options |
Hyperioxes |
View Public Profile |
Send a private message to Hyperioxes |
Find More Posts by Hyperioxes |
Add Hyperioxes to Your Buddy List |
12/04/20, 04:18 AM | |
Forum posts: 0
File comments: 26
Uploads: 0
|
New Issue with LibAlchemy:getCraftingCost
in Alchemy Tooltips with Master Writs |
|
DrakeRulo |
View Public Profile |
Send a private message to DrakeRulo |
Find More Posts by DrakeRulo |
Add DrakeRulo to Your Buddy List |
06/14/20, 12:30 PM | ||
|
||
|
Hyperioxes |
View Public Profile |
Send a private message to Hyperioxes |
Find More Posts by Hyperioxes |
Add Hyperioxes to Your Buddy List |
06/09/20, 04:13 AM | |
Forum posts: 1
File comments: 11
Uploads: 0
|
bad argument #1 to 'pairs' (table/struct expected, got nil)
stack traceback: [C]: in function 'pairs' user:/AddOns/LibAlchemy/LibAlchemy.lua:480: in function 'LibAlchemy:OneEffect' |caaaaaa<Locals> self = [table:1]{} </Locals>|r user:/AddOns/LibAlchemy/LibAlchemy.lua:574: in function 'LibAlchemy:ThreeEffects' |caaaaaa<Locals> self = [table:1], first = "RavageHealth", third = "Breach", firstConnectedIngredients = [table:2]{} </Locals>|r user:/AddOns/LibAlchemy/LibAlchemy.lua:104: in function 'LibAlchemy:getBestCombination' |caaaaaa<Locals> self = [table:1], tableOfEffects = [table:3]{1 = "RavageHealth"}, effect1 = "RavageHealth", effect3 = "Breach" </Locals>|r user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:228: in function 'checkPotion' |caaaaaa<Locals> itemLink = "|H0:item:44812:30:3:0:0:0:0:0:...", id = 166664, mainID = 44812, effect1 = "RavageHealth", effect3 = "Breach", calculation = 2 </Locals>|r user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:295: in function '(anonymous)' |caaaaaa<Locals> self = ud </Locals>|r (tail call): ? (tail call): ? user:/AddOns/WritWorthy/WritWorthy.lua:361: in function 'BagItemTooltip' |caaaaaa<Locals> control = ud, bagId = 1, slotIndex = 1 </Locals>|r user:/AddOns/TraitBuddy/TraitBuddy.lua:121: in function 'SetBagItem' |caaaaaa<Locals> control = ud, bagId = 1, slotIndex = 1 </Locals>|r EsoUI/Ingame/Inventory/InventorySlot.lua:2042: in function '(anonymous)' |caaaaaa<Locals> inventorySlot = ud, bag = 1, index = 1 </Locals>|r EsoUI/Ingame/Utility/ZO_SlotUtil.lua:14: in function 'RunHandlers' |caaaaaa<Locals> handlerTable = [table:4]{}, slot = ud, handlers = [table:5]{}, i = 1 </Locals>|r EsoUI/Ingame/Inventory/InventorySlot.lua:2403: in function 'ZO_InventorySlot_OnMouseEnter' |caaaaaa<Locals> inventorySlot = ud, buttonPart = ud, listPart = ud </Locals>|r ZO_StackSplitSource_MouseEnter:3: in function '(main chunk)' |caaaaaa<Locals> self = ud </Locals>|r Any ideas? |
|
SkamzA |
View Public Profile |
Send a private message to SkamzA |
Find More Posts by SkamzA |
Add SkamzA to Your Buddy List |
05/28/20, 12:30 PM | ||
|
||
|
Hyperioxes |
View Public Profile |
Send a private message to Hyperioxes |
Find More Posts by Hyperioxes |
Add Hyperioxes to Your Buddy List |
05/28/20, 09:26 AM | ||
Re: Error with Guild Tabard
|
||
|
Hyperioxes |
View Public Profile |
Send a private message to Hyperioxes |
Find More Posts by Hyperioxes |
Add Hyperioxes to Your Buddy List |
05/28/20, 05:29 AM | |
Forum posts: 16
File comments: 62
Uploads: 0
|
Got this error when my mouse goes over Brutality-Draining Poison IX :
bad argument #1 to 'pairs' (table/struct expected, got nil) stack traceback: [C]: in function 'pairs' user:/AddOns/LibAlchemy/LibAlchemy.lua:150: in function 'LibAlchemy:getCraftingCost' user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:226: in function 'checkPotion' user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:292: in function 'TooltipSetBagItem' |
|
sarousse |
View Public Profile |
Send a private message to sarousse |
Find More Posts by sarousse |
Add sarousse to Your Buddy List |
05/28/20, 04:44 AM | |
Forum posts: 2
File comments: 367
Uploads: 0
|
Error with Guild Tabard
When I mouse over my Guild Tabards, I receive the following error:
Code:
user:/AddOns/LibAlchemy/LibAlchemy.lua:157: attempt to index a nil value stack traceback: user:/AddOns/LibAlchemy/LibAlchemy.lua:157: in function 'LibAlchemy:getCraftingCost' |caaaaaa<Locals> self = [table:1]{}, reagentsTable = [table:2]{1 = 30163}, itemLink = "|H0:item:55262:4:1:0:0:0:0:0:0...", mainID = 55262, solvent = 1, CP = 3, result = 123.27288307769, type = 2 </Locals>|r user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:226: in function 'checkPotion' |caaaaaa<Locals> itemLink = "|H0:item:55262:4:1:0:0:0:0:0:0...", id = 375495, mainID = 55262, effect1 = "RestoreStamina", calculation = 5, BestCombination = [table:2] </Locals>|r user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:292: in function 'orgFunc' |caaaaaa<Locals> self = ud </Locals>|r user:/AddOns/HarvensTraitAndStyle/HarvensTraitAndStyle.lua:296: in function 'HarvensTraitAndStyle_SetBagItem' |caaaaaa<Locals> orgFunc = user:/AddOns/AlchemyTooltips/AlchemyTooltips.lua:290, tooltip = ud, bagId = 2, slotIndex = 145, unhackTraitName = user:/AddOns/HarvensTraitAndStyle/HarvensTraitAndStyle.lua:107 </Locals>|r (tail call): ? user:/AddOns/WritWorthy/WritWorthy.lua:361: in function 'TooltipSetBagItem' |caaaaaa<Locals> control = ud, bagId = 2, slotIndex = 145 </Locals>|r user:/AddOns/ArkadiusTradeToolsSales/ArkadiusTradeToolsSalesTooltipExtensions.lua:225: in function 'self.tooltip.SetBagItem' |caaaaaa<Locals> tooltip = ud, bag = 2, index = 145, itemLink = "|H0:item:55262:4:1:0:0:0:0:0:0..." </Locals>|r user:/AddOns/LibMarify/LibMarify.lua:419: in function 'SetBagItem' EsoUI/Ingame/Inventory/InventorySlot.lua:2050: in function '(anonymous)' |caaaaaa<Locals> inventorySlot = ud, bag = 2, index = 145 </Locals>|r EsoUI/Ingame/Utility/ZO_SlotUtil.lua:14: in function 'RunHandlers' |caaaaaa<Locals> handlerTable = [table:3]{}, slot = ud, handlers = [table:4]{}, i = 1 </Locals>|r EsoUI/Ingame/Inventory/InventorySlot.lua:2403: in function 'ZO_InventorySlot_OnMouseEnter' |caaaaaa<Locals> inventorySlot = ud, buttonPart = ud, listPart = ud </Locals>|r (tail call): ? (tail call): ? ZO_StackSplitSource_MouseEnter:3: in function '(main chunk)' |caaaaaa<Locals> self = ud </Locals>|r |
|
hagermanj |
View Public Profile |
Send a private message to hagermanj |
Find More Posts by hagermanj |
Add hagermanj to Your Buddy List |
05/13/20, 10:07 PM | |
So, the database isn't necessary - there's a structure to the pots so that you can determine what the effects are instead of hardcoding all of them.
See the section on #21 Instance data here: https://wiki.esoui.com/ZO_LinkHandler_CreateLink Applying it would greatly simplify the database as well as make it easy to expand it to all potion types. Also, for crafting mats you only need to save the item ID instead of the entire link ; you can generate a link from that with this: local function getItemLinkFromItemId(itemId) return string.format("|H1:item:%d:%d:50:0:0:0:0:0:0:0:0:0:0:0:0:%d:%d:0:0:%d:0|h|h", itemId, 0, ITEMSTYLE_NONE, 0, 10000) end There's GetItemType which you can use to determine if an item is a potion (or poison) The checkIfNotIn and tableContains functions are inverses of each other, you only need one. Or have one just return not of the other one. You also have checkIfIn. For getTextureFromId you could use the previously mentioned function to get an item link, then get the texture from that item link. |
|
|
Dolgubon |
View Public Profile |
Send a private message to Dolgubon |
Find More Posts by Dolgubon |
Add Dolgubon to Your Buddy List |